rs.initiate(config); {"ok" : 0, "errmsg" : "couldn't initiate : need all members up to initiate, not

一:问题描述


今天在初始化mongodb副本集时报错:

[root@ser6-51 ~]# mongo

MongoDB shell version: 2.6.9

connecting to: test

> use admin;

switched to db admin

 

> config = { _id:"MyReplset", members:[

...  {_id:0,host:"192.168.6.51:27017"},

...  {_id:1,host:"192.168.6.52:27017"},

...  {_id:2,host:"192.168.6.70:27017"}]

...  }

{

"_id" : "MyReplset",

"members" : [

{

"_id" : 0,

"host" : "192.168.6.51:27017"

},

{

"_id" : 1,

"host" : "192.168.6.52:27017"

},

{

"_id" : 2,

"host" : "192.168.6.70:27017"

}

]

}

> rs.initiate(config);

{

"ok" : 0,

"errmsg" : "couldn't initiate : need all members up to initiate, not ok : 192.168.6.52:27017"

}

二:出错原因


mongodb没有启动或者没有开放防火墙端口


三:解决办法

开启mongodb.
我这里出错的原因是没有开放防火墙端口。
 vi /etc/sysconfig/iptables

添加一行:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT

重启防火墙

[root@ser6-52 mongodb]# /etc/init.d/iptables restart

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]

iptables: Applying firewall rules:                         [  OK  ]

 

--本篇文章参考自:Mongodb2.4.3集群安装笔记


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值