码迷,mamicode.com
首页 > 其他好文 > 详细

Deploy a replica set

时间:2014-12-31 17:52:41      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

A three-member replica set 

技术分享

server info: scdbm06~08

mongodb info: mongodb-linux-x86_64-2.6.6.tgz
 
1. 在On scdbm06上创建存放data和log的文件夹

mkdir -p /mongodb/data

mkdir -p /mongodb/log

上传文件到 /mongodb

2. On scdbm06 

cd /mongodb

tar –zxvf  mongodb-linux-x86_64-2.6.6.tgz

3. On scdbm07~8 copy 解压的mongodb文件

scp -r root@scdbm06:/mongodb     /

4. On scdbm06~08 启动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 128  --httpinterface 

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 two members:

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

 

上面的(6.7.8)可以使用下面的代替

 use admin

config = { _id:"repset", members:[

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

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

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

 }

rs.initiate(config);

/* 

*关闭 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 128  --httpinterface --shutdown

*/

 

Deploy a replica set

标签:

原文地址:http://www.cnblogs.com/llgg/p/4195964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!