mongodb 複製集

mongodb指定配置文件啓動
mongodb.conf

dbpath = /data/db
rest = true
fork = ture
logpath = /data/db/mongodb.log
replSet = tmp

/ABT/sys/mongodb-linux-x86_64-1.8.2/bin/mongod --config /ABT/sys/mongodb-linux-x86_64-1.8.2/mongodb.conf

mongdb 命令行啓動

/ABT/sys/mongodb-linux-x86_64-1.8.2/bin/mongodmongod --replSet tmp --port 27017 --dbpath /data/db


設置複製集
在master上執行


方法一
use admin
db.runCommand({"replSetInitiate": {"_id": "tmp", "members": [{"_id":0, "host":"10.0.2.1:27017"},

{"_id":1,"host":"10.0.2.2:27017"}]}})
方法二
use admin
config = {_id: 'tmp', members: [
                              {_id: 0, host: '10.0.4.11:27017'},
                              {_id: 1, host: '10.0.4.16:27017'},
                              {_id: 2, host: '10.0.4.17:27017'}]
}

rs.initiate(config);

查看狀態

rs.status()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章