mongdb

# mongo 服务器配置
MONGO_HOST = "3.113.95.240"
MONGO_USER = "saas"
MONGO_PASSWORD = "NOUmr64I84BTVvO"
MONGO_PORT = "27077"
MONGO_DATABASE = "VideoInfoDB"
MONGO_MAX_NUM = 100
MONGO_TIMEOUT = 10s

mongo --host 127.0.0.1 -u “user” --authenticationDatabase “db” -p’pwd’

mongodb://saas:NOUmr64I84BTVvO@3.113.95.240/test
mongo --host 3.113.95.240 --port 27077 --authenticationDatabase "VideoInfoDB" -u "saas" -p "NOUmr64I84BTVvO"


mongo -host 127.0.0.1
mongo 127.0.0.1:27017/admin -u admin -p

mongo 3.113.95.240:27017/admin -u saas -p

db.createUser({user:"liugang",pwd:"liugang1234!",roles:[{role:"dbOwner",db:"tesataa"}]})
db.auth("liugang","liugang1234!")
mongodump -h 127.0.0.1 -d polygonImageMark -o c:/mongo/1m/
> show dbs
VideoInfoDB 0.687GB
admin 0.000GB
config 0.000GB
local 0.000GB
proxy_pool 0.003GB
> show collections
system.users
system.version


mongodump -u superuser -p 123456 --authenticationDatabase admin --port 27017 -o /root/bak

mongodump -h --port 27017 --oplog -o /root/bak

mongodump -h 127.0.0.1 --port 27017 --oplog -o /root/bak

mongodump -u admin -p 123456 --authenticationDatabase admin --port 27017 -o /root/bak
mongodump -h 172.31.46.177 -u admin -p --port 27077 -oplog --authenticationDatabase admin -o /backup/mongodb/

mongodump -u -p --port 27077--authenticationDatabase admin -o /tmp/backup
mongodump -uadmin -p4WToeACRAZu6tVXg --host=172.31.46.177 --port=27077 --oplog --authenticationDatabase=admin -o /backup/mongodb/

mongodump -uadmin -p4WToeACRAZu6tVXg --host=172.31.46.177 --port=27077 --authenticationDatabase=VideoInfoDB -o /backup/mongodb/
mongodump -h 172.27.137.26:36137 -d ssdb -o f:datassdb170505 -u=administrator -p=qqddd.222 --authenticationDatabase=admin


mongodump -uadmin -p4WToeACRAZu6tVXg --host=172.31.46.177 --port=27077 -d VideoInfoDB --authenticationDatabase=admin -o /backup/mongodb/
mongorestore -u $DB_USER -p $DB_PASS --authenticationDatabase "admin" --noIndexRestore --dir /data/mongodb_bak/mongodb_bak_now/2016_12_17/

mongo 172.31.46.177:27017/admin -u admin -p
27078

mongo 127.0.0.1:27078/admin -u admin -p

db.createUser(
{
user:"admin",
pwd:"4WToeACRAZu6tVXg",
roles:[{role:"root",db:"admin"}]
}
)

use admin,db.createUser({user:"admin",pwd:"4WToeACRAZu6tVXg",roles:[{"role":"userAdminAnyDatabase","db":"admin"}]})
mongorestore -uadmin --host=172.31.19.115 --port=27078 -p4WToeACRAZu6tVXg --authenticationDatabase "admin" -noIndexRestore --dir
db.createUser({user:"admin",pwd:"4WToeACRAZu6tVXg",roles:["root"]})

db.system.users.find()

mongorestore -uadmin --host=172.31.19.115 --port=27078 -p4WToeACRAZu6tVXg --authenticationDatabase "admin" --noIndexRestore --dir /home/qqc/backup/mongodb/ --drop

 

 

 

mongo迁移数据

1、为数据库写数据(同步到磁盘)加锁
db.runCommand({fsync:1,lock:1})

2.查看当前锁状态
db.currentOp()


3.解锁

use admin
db.$cmd.sys.unlock.findOne()

4.
指定库备份mongodump -uadmin -p4WToeACRAZu6tVXg --host=172.31.46.177 --port=27077 -d VideoInfoDB --authenticationDatabase=admin -o /backup/mongodb/
全备 mongodump -uadmin -p4WToeACRAZu6tVXg --host=172.31.46.177 --port=27077 --authenticationDatabase=admin -o /backup/mongodb/

还原数据
mongorestore -uadmin --host=172.31.19.115 --port=27078 -p4WToeACRAZu6tVXg --authenticationDatabase "admin" --noIndexRestore --dir /home/qqc/backup/mongodb/ --drop

jk.4f1a47.com
jk.161abe.com
jk.10cb1c.com

posted @ 2022-12-02 17:23  人生信条~~  阅读(61)  评论(0编辑  收藏  举报