To create a path:
mkdir
-p
/datassd/mongo_20011/
{data,conf,log}
Example configuration file:
#mongo.conf
dbpath=
/datassd/mongo/data/
logpath=
/datassd/mongo_20011/log/mongo_20011
.log
pidfilepath=
/datassd/mongo_20011/mongo_20011
.pid
directoryperdb=
true
logappend=
true
replSet=testrs
port=20011
oplogSize=10000
fork=
true
noprealloc=
true
Parameter explanation:
DBPath: Data Storage Directory
LogPath: Log Storage path
Pidfilepath: Process files, easy to stop MongoDB
Directoryperdb: Set up a folder for each database according to the database name
Logappend: Logging in Append mode
Replset:replica Set's name
IP address that is bound by Bind_ip:mongodb
The port number used by the PORT:MONGODB process, which defaults to 20011
Oplogsize:mongodb the maximum size of the operation log file. The unit is MB, which defaults to 5% of the remaining space on the hard disk. Shard scenes can only be fragmented if they exceed this size
Fork: Run the process in the next stage mode
Noprealloc: No pre-allocated storage
Reference configuration:
Master
config={_id: ' Shard1 ', members:[{_id:0,host: ' 10.2.1.61:20011 '},{_id:1,host: ' 10.2.2.13:20011 '},{_id:2,host: ' 10.2.2.31:20011 ', Arbiteronly:true}]}
#双节点情况下需要有仲裁节点才能实现故障转移, it is also possible to replace the quorum node with another one from
Master
Rs.initiate (config)
#db. Printreplicationinfo ()
#rs. Status ()
Slave
#rs. Slaveok ()
To add a delete node:
Rs.add ("Ip:port")
Rs.remove ("Ip:port")
MongoDB master-slave replica set configuration