私は、ローカルマシン上でMongoDBデータベースをシャードする方法について、Youtube tutorialに従っています。このチュートリアルはMongo 2.2のためのもので、私はMongo 3.4です。ですから、以下のbashスクリプトを使ってシャードを起動しています。設定サーバーとシャードは正常に起動しますが、mongosプロセスは接続できず、印刷されたエラーもありません。 Mongo 3.2以降に変更されたことは、レプリカセットの接続文字列を含める必要があることです。これは私がやったと思ったが、明らかに動作していません。MongoDBシャーディングが応答しない
#!/bin/bash
# Create the directories that the shards will run in
# We will have 4 shards, with a replication factor of 3
mkdir a0 a1 a2
mkdir b0 b1 b2
mkdir c0 c1 c2
mkdir d0 d1 d2
# Create the three configuration server folders
mkdir cfg0 cfg1 cfg2
# Common variables
replSet="configReplSet"
hostname="127.0.0.1"
# Configure the config servers
mongod --configsvr --replSet ${replSet} --dbpath cfg0 --port 26050 --fork --logpath log.cfg0 --logappend
mongod --configsvr --replSet ${replSet} --dbpath cfg1 --port 26051 --fork --logpath log.cfg1 --logappend
mongod --configsvr --replSet ${replSet} --dbpath cfg2 --port 26052 --fork --logpath log.cfg2 --logappend
# Set up shard servers
mongod --shardsvr --replSet a --dbpath a0 --logpath log.a0 --port 27000 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet a --dbpath a1 --logpath log.a1 --port 27001 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet a --dbpath a2 --logpath log.a2 --port 27002 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet b --dbpath b0 --logpath log.b0 --port 27100 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet b --dbpath b1 --logpath log.b1 --port 27101 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet b --dbpath b2 --logpath log.b2 --port 27102 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet c --dbpath c0 --logpath log.c0 --port 27200 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet c --dbpath c1 --logpath log.c1 --port 27201 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet c --dbpath c2 --logpath log.c2 --port 27202 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet d --dbpath d0 --logpath log.d0 --port 27300 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet d --dbpath d1 --logpath log.d1 --port 27301 --fork --logappend --oplogSize 50
mongod --shardsvr --replSet d --dbpath d2 --logpath log.d2 --port 27302 --fork --logappend --oplogSize 50
mongos --configdb ${replSet}/${hostname}:26050,${hostname}:26051,${hostname}:26052 --fork --logappend --logpath log.mongos0 --port 27017
mongos --configdb ${replSet}/${hostname}:26050,${hostname}:26051,${hostname}:26052 --fork --logappend --logpath log.mongos1 --port 26061
mongos --configdb ${replSet}/${hostname}:26050,${hostname}:26051,${hostname}:26052 --fork --logappend --logpath log.mongos2 --port 26062
mongos --configdb ${replSet}/${hostname}:26050,${hostname}:26051,${hostname}:26052 --fork --logappend --logpath log.mongos3 --port 26063
最初のmongosコマンドの後に実行を停止します。 log.mongo0で次のようなエラーが繰り返されます。
.841-0400 W NETWORK [mongosMain] Failed to connect to 127.0.0.1:26050, in(checking socket for error after poll), reason: Connection refused
2017-06-28T15:38:01.841-0400 W NETWORK [mongosMain] Failed to connect to 127.0.0.1:26051, in(checking socket for error after poll), reason: Connection refused
2017-06-28T15:38:01.841-0400 W NETWORK [mongosMain] No primary detected for set configReplSet
何か助けていただければ幸いです。ありがとうございます
が実際に開いているポート26050と26051です破片の作成を開始することができました - 私は? –
コードの入力ミスを修正しました。mkdirコマンドの間にカンマを追加しました。その後、現在、/ tmp/mongodb-26050.sock(および他のすべてのパス)にLISTENINGというタイプのストリームがあると言います。 – MANA624
ローカルアドレスの下に0.0.0.0、次に26050と26051、リスニング – MANA624