mongodb master-slave configuration master-slave configuration mongodb

master-slave configuration mongodb

 

1. Create /etc/yum.repos.d/ from under the main directory on the server file mongodb.repo, which contains configuration information MongoDB warehouse, as follows:

[mongodb] 
name=MongoDB Repository 
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ 
gpgcheck=0 
enabled=1  

2. Run the install command from the main server

yum -y install mongodb-org

3. In the main storage path from the custom server and db log

New DB storage directory, modify the permissions

mkdir -p /data0/mongodb
chown -R  mongod:mongod /data0/mongodb

Master server modifies /etc/mongod.conf

Copy the code

= logpath / DATA0 / MongoDB / mongod.log
logappend = # use additional way to true to write the log
fork = true # daemon to run
master = true # main library
dbpath = / DATA0 / MongoDB
pidfilepath = / var / RUN / MongoDB /mongod.pid
bind_ip = 172.16.225.111 # binding service IP, does not specify a default for all local IP
auth = # to true to enable user password authentication

Copy the code

Modify /etc/mongod.conf from the server

Copy the code
logpath=/data0/mongodb/mongod.log
logappend=true
fork=true
slave=true  #从库
source=172.16.225.111:27017  #主库IP和端口
dbpath=/data0/mongodb
pidfilepath=/var/run/mongodb/mongod.pid
bind_ip=172.16.59.190
auth=true
Copy the code

 4. Master Boot mongodb service from the server

/etc/init.d/mongod start

Add the system startup scripts

1
2
find  / -name redis_init_script
cp  /opt/redis/utils/redis_init_script  /etc/init .d /redis

 

1. Create /etc/yum.repos.d/ from under the main directory on the server file mongodb.repo, which contains configuration information MongoDB warehouse, as follows:

[mongodb] 
name=MongoDB Repository 
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ 
gpgcheck=0 
enabled=1  

2. Run the install command from the main server

yum -y install mongodb-org

3. In the main storage path from the custom server and db log

New DB storage directory, modify the permissions

mkdir -p /data0/mongodb
chown -R  mongod:mongod /data0/mongodb

Master server modifies /etc/mongod.conf

Copy the code

= logpath / DATA0 / MongoDB / mongod.log
logappend = # use additional way to true to write the log
fork = true # daemon to run
master = true # main library
dbpath = / DATA0 / MongoDB
pidfilepath = / var / RUN / MongoDB /mongod.pid
bind_ip = 172.16.225.111 # binding service IP, does not specify a default for all local IP
auth = # to true to enable user password authentication

Copy the code

Modify /etc/mongod.conf from the server

Copy the code
logpath=/data0/mongodb/mongod.log
logappend=true
fork=true
slave=true  #从库
source=172.16.225.111:27017  #主库IP和端口
dbpath=/data0/mongodb
pidfilepath=/var/run/mongodb/mongod.pid
bind_ip=172.16.59.190
auth=true
Copy the code

 4. Master Boot mongodb service from the server

/etc/init.d/mongod start

Add the system startup scripts

1
2
find  / -name redis_init_script
cp  /opt/redis/utils/redis_init_script  /etc/init .d /redis

 

Guess you like

Origin www.cnblogs.com/vilenx/p/12373607.html