This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo nano /etc/systemd/system/startup.service | |
[Unit] | |
Description=Startup | |
[Service] | |
ExecStart=/usr/local/bin/startup.sh | |
[Install] | |
WantedBy=default.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Backup and restore to local | |
$ mongodump --host localhost --port 27017 --db db-name -u XXX -p YYY --out db-backup | |
$ zip -r db-backup.zip db-backup | |
$ scp -i keys/key.pem ubuntu@ip:app/db-backup.zip ~/Downloads | |
$ mongorestore --db db-name --drop db-backup/db-name | |
// Dump from mongo cloud | |
$ mongod --dbpath [db-path] --replSet [replset-name] | |
$ mongo | |
> rs.initiate({ _id: "db_name", members: [{ _id: 1, host: "localhost:27017" }] }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build | |
docker build -t image-name . | |
# Tag & push | |
docker tag image-id account/image-name:latest | |
docker login | |
docker push account/image-name | |
# Launch MongoDB container | |
docker run -v /datadir:/data/db --name mongo-service -d mongo mongod --smallfiles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -v /datadir:/data/db --name mongo -p 27017:27017 -d mongo --auth | |
docker exec -it mongo mongo | |
> use admin | |
> db.system.users.find() | |
> db.createUser({ user: 'admin', pwd: 'admin', roles: [ { role: "root", db: "admin" } ] }); | |
> use some-db | |
> db.createUser({ user: 'user', pwd: 'user', roles: [ "readWrite" ] }); |
NewerOlder