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()