您好,登录后才能下订单哦!
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<<EOF
export PATH=/usr/local/mongo/bin:$PATH
EOF
source /etc/profile
mongotest1
vi start27017.sh
mkdir /opt/mongo1_1
cat >>/etc/mongo_27017.conf<<EOF
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" }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。