> db.runCommand({"replSetInitiate" : { "_id" : "hnrconfig" ,"members" : [ { "_id" : 1, "host" : "192.168.115.11:10000"},{ "_id" : 2, "host" : "192.168.115.12:10000"},{"_id" : 3, "host" : "192.168.115.11:10001"}]}})
8.启动mongos服务,此时没有任何数据
9.导入备份的config数据
/usr/local/mongodb/bin/mongorestore -h 192.168.115.11:10000 -d config configdata/config/
在mongos查询,但是查询数据会出现超时,数据无法查询
10.在mongos执行如下命令
mongos> sh.enableSharding("shardtest")
{ "ok" : 0, "errmsg" : "Operation timed out", "code" : 50 }
mongos日志
2016-11-17T14:46:21.197+0800 I SHARDING [Balancer] about to log metadata event into actionlog: { _id: "node1.hnr.com-2016-11-17T14:46:21.197+0800-582d523ded1c4b679a84877b", server: "node1.hnr.com", clientAddr: "", time: new Date(1479365181197), what: "balancer.round", ns: "", details: { executionTimeMillis: 30007, errorOccured: true, errmsg: "could not get updated shard list from config server due to ExceededTimeLimit Operation timed out" } }
官网上说是bug,恢复失败
https://jira.mongodb.org/browse/SERVER-22392
更多MongoDB相关教程见以下内容:
CentOS 编译安装 MongoDB与mongoDB的php扩展
CentOS 6 使用 yum 安装MongoDB及服务器端配置
Ubuntu 13.04下安装MongoDB2.4.3