0
我正在关注如何在本地机器上分割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,当您运行“netstat的-l”或“SS实际打开 - L“? –
我只是修复了代码中的错字 - 我在mkdir命令之间添加了逗号。之后,它现在说有类型STREAM在路径/tmp/mongodb-26050.sock(及所有其他)上侦听 – MANA624
在本地地址下有0.0.0.0,然后是26050和26051,监听 – MANA624