Deploy a replica set

Source: Internet
Author: User
Tags mongo shell

A Three-member Replica Set

Server info: scdbm06~08

MongoDB Info: mongodb-linux-x86_64-2.6.6.tgz   1. Create a folder on the on scdbm06 that holds data and log

Mkdir-p/mongodb/data

Mkdir-p/mongodb/log

Uploading Files to/mongodb

2. On scdbm06

Cd/mongodb

TAR–ZXVF mongodb-linux-x86_64-2.6.6.tgz

3. On scdbm07~8 copy extracted MongoDB file

scp-r [Email Protected]:/mongodb/

4. On scdbm06~08 start Mongod

/mongodb/mongodb-linux-x86_64-2.6.6/bin/mongod--fork--port 27017--dbpath/mongodb/data--logpath=/mongodb/log/ Mongodb.log--replset repset--smallfiles--oplogsize

5. On scdbm06 Connect a MONGO shell to a replica set member.

/mongodb/mongodb-linux-x86_64-2.6.6/bin/mongo--port 27017

6. On scdbm06 Initiate the replica set.

Use Rs.initiate () on the replica set member:

Rs.initiate ()

7. On scdbm06 Verify The initial replica set configuration.

Use Rs.conf () to display the replica set configuration object:

Rs.conf ()

8. On scdbm06 ADD The remaining members to the replica set.

Add the remaining members with the Rs.add () method.

The following example adds:

Rs.add ("Scdbm07")

Rs.add ("scdbm08")

9. On scdbm06 Check The status of the replica set.

Use the Rs.status () operation:

Rs.status ()

--ps-aux | grep MongoDB

The above (6.7.8) can be replaced with the following

Use admin

Config = {_id: "Repset", members:[

{_id:0,host: "scdbm06:27017"},

{_id:1,host: "scdbm07:27017"},

{_id:2,host: "scdbm08:27017"}]

}

Rs.initiate (config);

/*

* Close Mongod

/mongodb/mongodb-linux-x86_64-2.6.6/bin/mongod--fork--port 27017--dbpath/mongodb/data--logpath=/mongodb/log/ Mongodb.log--replset repset--smallfiles--oplogsize---httpinterface--shutdown

*/

Deploy a replica set

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.