您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。