1. MongoDB Backup
[Email protected] ~]# mongodump 192.168. 1.122 -D users-o/backup/20170228/users
2. MongoDB Recovery
192.168. 1.122 -D users/backup/20170228/users/users/
3. MongoDB Duplicate Name Set
Format: # db.copydatabase (' From database ', ' to database ', ' from Host:port ');
Rs0:primary> Db.copydatabase ('Users',' Person','192.168.1.122:27019') { "OK":1}rs0:primary>Show Dbslocal0. 006GBperson0. 000GBusers0. 000gbrs0:primary>Use usersswitched to DB usersrs0:primary>db.dropdatabase () {"dropped":"Users","OK":1}
4. mongdb replica centralization of weight
Mongdb front-end add Haproxy do ha, when a MongoDB service down, proxy can be connected to another service, because MongoDB initializes the same weight, so you need to modify the weight to determine the redundant node.
The greater the MongoDB weight, the more priority is given to the primary node
Rs0:primary> config=rs.conf () rs0:primary> config.members[0rs0:primary > config.members[19rs0:primary> config.members[28Rs0 :P rimary> rs.reconfig (config)
These operations must be on the primary process.
5. Mongdb Log Too big problem
MongoDB log files in the case of setting logappend=true, will continue to the same log file appended, long time, naturally become very large.
The solution is as follows: (Special note: The log path must be--logpath specified when booting)
rs0:primary> use adminrs0:primary> Db.runcommand ({logRotate:1})
This will generate a new log file.
[Mongodb] Problems