First, installation environment
centos6.5
master:172.30.29.108
slave:172.30.29.107
Second, master installation
1 package Installation
#yum install-y MongoDB Mongodb-server
#/etc/init.d/mongod start
#chkconfig Mongod onf
2 Creating a user
#mongo
>use Admin
>db.adduser ("Roor", "Master") #创建全局管理账户
>use Local
>db.adduser ("Repl", "Repl") #创建主从复制账户
>exit
3 Modifying a configuration file
#vim/etc/mongodb.conf
Port = 27017
Fork = True
Pidfilepath =/var/run/mongodb/mongodb.pid
LogPath =/var/log/mongodb/mongodb.log
DBPath =/var/lib/mongodb
Journal = True
Logappend = True
Auth = True
Master = True
Oplogsize = 10000 #单位为M, normal size is hard disk size 5%
#/etc/init.d/mongod restart
Third, slave installation
1 package Installation
#yum install-y MongoDB Mongodb-server
#/etc/init.d/mongod start
#chkconfig Mongod onf
2 Creating a user
#mongo
>use Admin
>db.adduser ("Roor", "slave") #创建全局管理账户
>use Local
>db.adduser ("Repl", "Repl") #创建主从复制账户
>exit
3 Modifying a configuration file
#vim/etc/mongodb.conf
Port = 27017
Fork = True
Pidfilepath =/var/run/mongodb/mongodb.pid
LogPath =/var/log/mongodb/mongodb.log
DBPath =/var/lib/mongodb
Journal = True
Logappend = True
Auth = True
Slave = True
Source = 172.30.29.108
Autoresync = True
Oplogsize = 10000
#/etc/init.d/mongod restart
At this point, the master-slave service installation is complete, the default slave server only read-only permissions.
This article is from the "Bremen Band" blog, declined reprint!
MONGNDB Master-slave replication