mongodb副本集创建

公司主营业务:成都做网站、成都网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出扬中免费做网站回馈大家。

vi install_mongo.sh

tar -zxvf MongoDB-linux-x86_64-rhel62-3.2.9.tgz

mv mongodb-linux-x86_64-rhel62-3.2.9 /usr/local/mongo

cat>>/etc/profile<

export PATH=/usr/local/mongo/bin:$PATH

EOF

source /etc/profile

mongotest1

vi start27017.sh

mkdir /opt/mongo1_1

cat >>/etc/mongo_27017.conf<

port=27017

fork=true

storageEngine=wiredTiger

dbpath=/opt/mongo1_1

logpath=/opt/mongo1_1/mongo.log

wiredTigerDirectoryForIndexes=true

wiredTigerCacheSizeGB=0.3

logappend=true

replSet=rs1

oplogSize=100

EOF

mongod -f /etc/mongo_27017.conf

[root@mongotest3 etc]# cat mongo_2701

mongo_27017.conf  mongo_27018.conf  

[root@mongotest3 etc]# cat mongo_27018.conf 

port=27018

fork=true

storageEngine=mmapv1

dbpath=/opt/mongo1_2

logpath=/opt/mongo1_2/mongo.log

replSet=rs1

logappend=true

oplogSize=100

cfg = { _id: "rs1", members:[

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

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

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

};

rs.initiate(cfg);

use online

db.test1.insert({name:'aaa'})

db.test1.find()

添加节点

rs.add('192.168.0.111:27018')

[root@mongotest3 opt]# mongo --port 27018

rs1:SECONDARY> use admin

switched to db admin

rs1:SECONDARY> use online

switched to db online

rs1:SECONDARY> rs.slaveOk()

rs1:SECONDARY> db.test1.find()

{ "_id" : ObjectId("57e943faff931e363a5a0309"), "name" : "aaa" }


新闻名称:mongodb副本集创建
网站地址:http://myzitong.com/article/pdcjch.html