Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i in username password address;do kubectl -n octarine-cp get secrets docdb -o "jsonpath={.data.$i}" | base64 --decode | xargs echo " --$i "; done
- echo "apiVersion: v1
- kind: Pod
- metadata:
- name: pavel-test-mongo
- spec:
- containers:
- - name: pavel-test-mongo
- image: mongo:6.0
- imagePullPolicy: Always
- command: ["/bin/sh", "-c"]
- args:
- - apt-get -y update && apt-get -y install wget;
- while true; do sleep 86400; done;" | kubectl apply -f -
- ; wait 60;kubectl exec -it pavel-test-mongo -- bash
- rs.initiate( {
- _id : "rs0",
- members: [
- { _id: 0, host: "mongodb-skyler-cook-node-0:27017" },
- { _id: 1, host: "mongodb-skyler-cook-node-1:27017" }
- ]
- })
- rs.add( { host: "mongodb3.example.net:27017", priority: 0, votes: 0 } )
- db.createUser({user: "<username>", pwd: "<password>", roles: [{ role: "clusterMonitor", db: "admin"}, { role: "read", db: "local" }]})
- db.createUser({user: "<username>", pwd: "<password>", roles: [{ role: "readAnyDatabase", db: "admin"}]})
- db.createUser({user: "<username>", pwd: "<password>", roles: [{ role: "readWriteAnyDatabase", db: "admin"}]})
- db.createUser({ user: "<>", pwd: "<>", roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] })
- db.createUser( { user: "<>", pwd: "<>", roles: [ { role: "readWrite", db: "app-db" } , { role: "readWrite", db: "app-fs" } ] } )
- db.createUser( { user: "<>", pwd: "<>", roles: [ "root" ] } )
- db.updateUser("platform", {roles: [ { role: "readWrite", db: "app-db" } , { role: "readWrite", db: "app-fs" } ] })
- kubectl exec -it mongodb-0 -- /bin/bash -c "mongodump --db app-staging-fs --archive | mongorestore -vvvvvv --host <> --port 27017 --username <> --password <> --authenticationDatabase admin --drop --archive --db app-fs"
- for i in staging release; do kubectl -n $i exec -it mongodb-0 -- bash -c 'mongo --eval "Mongo().getDB(\"app-staging-db\").dropDatabase()"';done
- mongodump --host mongodb.next.svc.cluster.local --db app-fs --archive | mongorestore --host localhost --drop --archive
- mongodump --uri mongodb://<USER>:<PASSWORD>@127.0.0.1 --oplog --gzip --archive=/data/db/mongo_skyler.`date +%F_%H-%M-%S`.gz
- mongodump --host 10.47.245.51 --port 27017 --oplog --gzip --archive=/usr/mongodb/db/mongo_skyler.`date +%F_%H-%M-%S`.gz
- mongodump --host 10.142.0.13 --port 27017 --out /usr/mongodb/db/test12
- mongorestore -vvvvvv --host 10.44.0.87 --port 27017 -j 1 --drop /usr/mongodb/db/test12/
- mongodump --db app-staging-fs --archive | mongorestore --host [] --port 27017 --username [] --password [] --authenticationDatabase admin --nsFrom app-staging-fs.* --nsTo app-fs.* --drop --archive
- docker run -it --rm -v ~/data:/data mongo mongodump --ssl --sslAllowInvalidCertificates --host <> --port <> --authenticationDatabase admin --username <> --password <> --db currencies --collection currencies --gzip --archive=/data/currencies.currencies.`date +%F`.gz
- db = db.getSiblingDB("admin");dbs = db.runCommand({ "listDatabases": 1 }).databases;dbs.forEach(function(database) {db = db.getSiblingDB(database.name);stats = db.stats();printjson(stats)});
- db.getCollection('runningCommands').find({status:'failed'}).sort({_id:-1})
- var db = db.getSiblingDB("admin");
- var dbs = db.runCommand({ "listDatabases": 1 }).databases;
- var sum = 0
- dbs.forEach(function(database) {
- db = db.getSiblingDB(database.name);
- var size = db.stats().indexSize
- print(size)
- sum += size
- });
- print("#######")
- print(sum/(1000000000));
Add Comment
Please, Sign In to add comment