Mongodb master-slave configuration, mongodb master-slave Configuration
1. Create the file mongodb. repo in the/etc/yum. repos. d/directory on the Master/Slave server, which contains the configuration information of the MongoDB repository. The content is as follows:
[mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1
2. Run the installation command on the Master/Slave server.
yum -y install mongodb-org
3. Customize the db and log storage path on the Master/Slave Server
Create a new database directory and modify permissions
mkdir -p /data0/mongodbchown -R mongod:mongod /data0/mongodb
Modify/etc/mongod. conf on the master server
Logpath =/data0/mongodb/mongod. log
Logappend = true # Use APPEND to write logs
Fork = true # Run as a daemon
Master = true # master database
Dbpath =/data0/mongodb
Pidfilepath =/var/run/mongodb/mongod. pid
Bind_ip = 172.16.225.111 # bind the service IP address. All local IP addresses are not specified by default.
Auth = true # enable user password verification
Modify/etc/mongod. conf from the server
Logpath =/data0/mongodb/mongod. loglogappend = truefork = trueslave = true # slave database source = 172.16.225.111: 27017 # master database IP address and port dbpath =/data0/mongodbpidfilepath =/var/run/mongodb/mongod. pidbind_ip = 172.16.59.20.auth = true
4. The Master/Slave server starts the mongodb service.
/etc/init.d/mongod start