MONGNDB Master-slave replication

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.