18

Linux で 3 ノードの mongodb レプリカ セットを構成しています。次の構成を使用しています

fork = true
bind_ip = 127.0.0.1
port = 27017
verbose = true
dbpath =  /opt/mongoDB/data/db
logpath = /opt/mongoDB/log/mongod.log
logappend = true
journal = true
replSet = rs1
keyFile = /opt/mongoDB/mongodb/bin/conf/keyfile

サーバーを起動します。サーバーを起動し、mongoコマンドラインツールを使用してサーバーに接続して実行しました。

私がしたとき、私はrs.initiate()得ました

{
    "info2" : "no configuration explicitly specified -- making one",
    "me" : "host-ip:27017",
    "ok" : 0,
    "errmsg" : "couldn't initiate : can't find self in the replset config"
}

cfg を提供しようとしましたがinitiate()、それでも同じエラーが発生します。

これは、ログ ファイルに表示されるものです。

Mon Oct 14 13:27:33.218 [rsStart] replSet info no seed hosts were specified on the --replSet command line
Mon Oct 14 13:27:34.118 [conn1] run command admin.$cmd { replSetInitiate: { _id: "rs1", members: [ { _id: 0.0, host: "host-ip:27017" } ] } }
Mon Oct 14 13:27:34.118 [conn1] replSet replSetInitiate admin command received from client
Mon Oct 14 13:27:34.118 [conn1] replSet replSetInitiate config object parses ok, 1 members specified
Mon Oct 14 13:27:34.118 [conn1] getallIPs("host-ip"): [ip address]
Mon Oct 14 13:27:34.118 BackgroundJob starting: ConnectBG
Mon Oct 14 13:27:34.118 [conn1] User Assertion: 13279:can't find self in the replset config
Mon Oct 14 13:27:34.119 [conn1] replSet replSetInitiate exception: can't find self in the replset config
Mon Oct 14 13:27:34.119 [conn1] command admin.$cmd command: { replSetInitiate: { _id: "rs1", members: [ { _id: 0.0, host: "host-ip:27017" } ] } } ntoreturn:1 keyUpdates:0 locks(micros) W:230 reslen:107 1ms

このエラーを解決するには、いつ行う必要がありますか?

4

2 に答える 2

23

CentOS マシンで MongoDB のレプリカ セットを開始できませんでした。

http://docs.mongodb.org/manual/tutorial/deploy-replica-set

mongodb replset

rs.initiate()


{
    "errmsg":"couldn't initiate : can't find self in the replset config on port 27011"
}

次に、JSON オブジェクト パラメーターを使用してrs.initiate(rsconfig)

var rsconfig = {"_id":"rs1","members":[{"_id":1,"host":"127.0.0.1:27011"}]}

次に rs.add(..) または一度にすべて

var rsconfig = {"_id":"rs1","members":[{"_id":1,"host":"127.0.0.1:27011"},{"_id":2,"host":"127.0.0.1:27012"},{"_id":3,"host":"127.0.0.1:27013"}]}

確認してprint(JSON.stringify(rsconfig))から

rs.initiate(rsconfig)

数秒後にチェック

rs.status()

ここに画像の説明を入力

于 2013-11-12T08:52:39.203 に答える