errmsg has data already, cannot initiate set

回复 收藏
本帖最后由 m.chang 于 2016-4-25 15:16 编辑

今天在做mongoDB主从的时候,遇到了"has data already, cannot initiate set"的问题,正好看到之前同学也遇到这个问题,老师回答说是要把从的数据全部清空,结果我在从上清空,也会报错。(:<(, woops)
主上初始化的时候提示信息如下:
> rs.initiate(config)
{
    "ok" : 0,
    "errmsg" : "'192.168.3.220:27017' has data already, cannot initiate set.",
    "code" : 110
}
从上清空数据报错信息如下:
> db.dropDatabase()
{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" } ## CAUTION: 已经配置主从了,赶紧把主从配置取消掉,怀疑就是主从配置导致数据无法正常清空。
>
> show dbs
2016-04-25T22:18:50.226+0800 E QUERY    Error: listDatabases failed:{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
    at Error ()
    at Mongo.getDBs (src/mongo/shell/mongo.js:47:15)
    at shellHelper.show (src/mongo/shell/utils.js:630:33)
    at shellHelper (src/mongo/shell/utils.js:524:36)
    at (shellhelp2):1:1 at src/mongo/shell/mongo.js:47
排错步骤:
1、把从配置文件主从配置去掉
2、重启服务
3、在从上执行db.dropDatabase(),清空所有的数据库,一个也不要留,直到show dbs为空
4、主上初始化,执行rs.initiate(config),这个时候又开悲摧了,
holy shit!!!!! ^__^
> rs.initiate(config)
{
    "ok" : 0,
    "errmsg" : "replSetInitiate quorum check failed because not all proposed set members responded affirmatively: 192.168.3.221:27017 failed with Failed attempt to connect to 192.168.3.221:27017; couldn't connect to server 192.168.3.221:27017 (192.168.3.221), connection attempt failed",
    "code" : 74
}
"errmsg" : "replSetInitiate quorum check failed because not all proposed set members responded affirmatively: ##这里说是不是所有的成员都已经果断的响应,我英文不怎么样就直译了,离成功不远了,再去从上找问题。
参考同学的帖子:
配置mongoDB:rs.initiate(config)时报错: replSetInitiate quorum check failed
http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=10659&fromuid=6891
(出处: 【阿铭Linux】)

a、查看selinux是关闭的,这个先排除
b、iptables -nvL, wps, 天呐,这么多防火墙规则,关了它。
[root@A ~]# getenforce
Disabled
[root@A ~]# iptables -nvL
Chain INPUT (policy ACCEPT 3058 packets, 344K bytes)
pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           udp dpt:53
    0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           tcp dpt:53
    0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           udp dpt:67
    0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           tcp dpt:67

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      virbr0  0.0.0.0/0            192.168.122.0/24    state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  virbr0 *       192.168.122.0/24     0.0.0.0/0           
    0     0 ACCEPT     all  --  virbr0 virbr0  0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     all  --  *      virbr0  0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable
    0     0 REJECT     all  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT 3499 packets, 375K bytes)
pkts bytes target     prot opt in     out     source               destination         
[root@A ~]# iptables -F
[root@A ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@A ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: nat mangle filte[  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]

c、重新启动mongod服务
d、在主上继续执行初始化命令,成功了。
> rs.initiate(config)
{ "ok" : 1 }


好了,遇到问题不要着急,先静下心来,保持平静,一步一步的查。肯定有解决的时候。加油。
2016-04-25 14:58 举报
已邀请:
0

gaofeng2456

赞同来自:

看看
0

m.chang

赞同来自:


其实今天弄这个是有点头大的, php连接mongodb又出来了版本不兼容的问题。
{:4_97:}
:)
0

gaofeng2456

赞同来自:

据需努力吧

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: