MongoDB replication (1)
来源:互联网 发布:软件小品 编辑:程序博客网 时间:2024/05/22 03:24
MongoDB replication (1)
> rs.initiate(){ "ok" : 0, "errmsg" : "This node was not started with the replSet option", "code" : 76, "codeName" : "NoReplicationEnabled"}
启动时没有配置复制集,使用mongo –replSet <复制集名称> 启动。
> rs.initiate(){ "ok" : 0, "errmsg" : "assertion src/mongo/db/repl/replset_commands.cpp:274", "code" : 8, "codeName" : "UnknownError"}
该行断言失败的原因:host不能配置为localhost。
Assertion failure h != "localhost" src/mongo/db/repl/replset_commands.cpp 274
此时,配置复制集信息:
> config = {_id:"rs0", members:[ {_id:0, host:"127.0.0.1:27017"}]}{ "_id" : "rs0", "members" : [ { "_id" : 0, "host" : "127.0.0.1:27017" } ]}> rs.initiate(config){ "ok" : 1 }
或者:
rs0:PRIMARY> rs.add("localhost:27017")
现在执行rs0:PRIMARY> db.oplog.rs.find()
,结果如下:
{ "ts" : Timestamp(1487582277, 1), "t" : NumberLong(1), "h" : NumberLong("1421023485009824583"), "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "periodic noop" } }{ "ts" : Timestamp(1487582280, 1), "t" : NumberLong(1), "h" : NumberLong("353054299917983331"), "v" : 2, "op" : "c", "ns" : "test.$cmd", "o" : { "create" : "test", "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "test.test" } } }{ "ts" : Timestamp(1487582280, 2), "t" : NumberLong(1), "h" : NumberLong("3858332860662095118"), "v" : 2, "op" : "i", "ns" : "test.test", "o" : { "_id" : ObjectId("58aab4482f0f96c51f43205f"), "empno" : 100, "name" : 100, "address" : "it is a test!" } }
查看复制集状态:
rs0:PRIMARY> rs.printReplicationInfo()configured oplog size: 192MBlog length start to end: 811secs (0.23hrs)oplog first event time: Mon Feb 20 2017 17:13:36 GMT+0800 (CST)oplog last event time: Mon Feb 20 2017 17:27:07 GMT+0800 (CST)now: Mon Feb 20 2017 17:27:11 GMT+0800 (CST)
I
0 0
- MongoDB replication (1)
- mongodb replication
- mongoDB replication
- MongoDB Replication Oplog
- MongoDB Replication NetworkInterface
- MongoDB replication (2)
- mongodb 分片Replication
- MongoDB设置 Replication Sets
- 绝好的MongoDB学习资料之七. Replication (1)
- MongoDB的Replication简单介绍
- MongoDB Advance----> AutoSharding and Replication
- Mongodb replication set 复制集
- MongoDB学习十--MongoDB的Replication Introduction
- MongoDB学习十一 --MongoDB的Replication实践
- MongoDB集群的冗余机制(Replication)
- Mongodb 源码分析--Replication之OpLog
- MongoDB(AutoSharding+Replication sets 稳定性测试 )
- mongodb源码分析(十四)replication主从模式
- 安卓JNI/NDK开发3(进阶 在C代码中调用java方法)
- centos7.2+zabbix3.2+sedmail邮件告警
- magento 2.1.4 url出现版本号,怎样解决?
- 类继承中的一个知识点
- Codeforces 768C Jon Snow and his Favourite Number
- MongoDB replication (1)
- 【Android】用RecycleView实现可以横向滚动的ListView效果
- Navicat11全系列激活(注册机)
- Idea打包Jar文件
- Tomcat的简单认识
- 如何是linux服务器 下的tomcat能够支持中文文件名和中文路径
- MySQL分页查询
- 关于寻路算法的一些思考(1):A* 算法介绍
- MongoDB replication (2)