1. Enter into the/usr/java, Cd/usr/java
2. New Mongodbmaster-slave,mkdir Mongodbmaster-slave
3. Go to the Mongodbmaster-slave folder, create a new master and slave folder, mkdir master slave
4. Enter the master and slave, create a new data and log file, mkdir data log, enter into data, create a new db file, MkDir db
5. Go to Mongodbmaster-slave, configure temporary environment variables, export path=/usr/java/mongodb/bin: $PATH
6. See if the staging environment variable is configured successfully: Echo $PATH
7. Perform Mongod--help to view help information
--master: Specifies the master node;
--slave: Specifies the slave node;
--source: The port that points to the service.
8. Copy the MongoDB configuration file to master and slave:
CP mongodb.conf. /mongodbmaster-slave/master/mongodb.conf
CP mongodb.conf. /mongodbmaster-slave/slave/mongodb.conf
9. Modify the mongodb.conf in master, vim mongodb.conf
dbpath=/usr/java/mongodbmaster-slave/master/data/Dblogpath=/usr/java/mongodbmaster-slave/master/log/ mongodb.loglogappend=trueFork=truebind_ip=192.168.80.128Port =27020Master=truesource=192.168.80.128:27021 # slave IP and port
Modify the paths of DBPath and LogPath, modify bind_ip and port.
MongoDB (iv)--master-Slave construction