obe*_*beq 17 replication mongodb
I did a mistake when configuring replica sets in mongodb. I think that what I did wrong is that I did a rs.initialize() on both nodes, which made them confused in some way. I'm not sure.
Now all I want to do is start over, but I couldn't find a way to de-initialize a node. So I followed the advice to delete the local*db files, thus resetting the configurations. I did that, and now nothing works.
> rs.initiate()
{
"info2" : "no configuration explicitly specified -- making one",
"me" : "0.0.0.0:27017",
"errmsg" : "couldn't initiate : can't find self in the replset config",
"ok" : 0
}
> rs.conf()
null
Run Code Online (Sandbox Code Playgroud)
I tried to remove and reinstall the package (I'm doing this on Ubuntu servers) which just meant that my mongodb.conf disappeared and my init script stopped working. This is of course easy enough to solve.
So how do I start over?
注意:我确实看过这个答案,但由于rs.conf()不起作用,这也不起作用.
rbr*_*brc 54
如果您的计算机的主机名未映射回127.0.0.1,您也会收到此错误.更新你的/ etc/hosts和/或你的/ etc/hostname,没有配置的rs.initiate()应该可行.
And*_*ere 25
如果使用生成的配置强制重新配置,是否可以解决问题?
您可以执行类似于{{mongo}} shell中的以下操作:
> cfg = {
... "_id" : "rs0",
... "version" : 1,
... "members" : [
... {
... "_id" : 0,
... "host" : "0.0.0.0:27017"
... }
... ]
... }
>rs.reconfig(cfg, {force:true})
Run Code Online (Sandbox Code Playgroud)
您可能需要调整cfg
变量以获取主机名和端口名,因为can't find self in new replset config
如果repl集在配置中找不到它正在运行的节点,则错误将返回到shell.
归档时间: |
|
查看次数: |
21455 次 |
最近记录: |