Lab - Configure a sharded cluster - ERROR connecting with mongo

I believe I started the Lab the wrong way.

Now I can’t connect to mongo. Is there a way to start from scratch?

vagrant@m103:~$ mongod -f “/shared/csrs_1.conf”
about to fork child process, waiting until server is ready for connections.
forked process: 2953
child process started successfully, parent exiting

vagrant@m103:~$ mongo --port 26001 -u m103-admin -p m103-pass
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:26001/?gssapiServiceName=mongodb
2019-07-31T21:36:34.519+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:26001, in(checking socket for error after poll), reason: Connection refused
2019-07-31T21:36:34.519+0000 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:26001, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6
exception: connect failed

I was able reach mongo, but there is one node that don’t connect. The node is not reachable, what can I do?

{
“_id” : 2,
“name” : “192.168.103.100:26001”,
“health” : 0,
“state” : 8,
“stateStr” : “(not reachable/healthy)”,
“uptime” : 0,
“optime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDurable” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDate” : ISODate(“1970-01-01T00:00:00Z”),
“optimeDurableDate” : ISODate(“1970-01-01T00:00:00Z”),
“lastHeartbeat” : ISODate(“2019-08-01T01:24:26.227Z”),
“lastHeartbeatRecv” : ISODate(“1970-01-01T00:00:00Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “Connection refused”,
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“configVersion” : -1
}

Is the mongod up and running on specified port?
ps -ef|grep mongod
Did you bring up 3 config servers
Connect to 26001
mongo --port 26001
rs.initiate()
Then create user
What does rs.status(),rs.conf(),rs.isMaster() show

2 Likes

The first time I tried to connect with csrs_1.conf it didn’t work.

vagrant@m103:~$ mongod -f /shared/csrs_1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 1997
ERROR: child process failed, exited with error number 14
To see additional information in this output, start without the “–fork” option.

I went to see if the dbpath and log path were there, and they were.

Afterwards I tried again and It seemed to work!

vagrant@m103:/ mongod -f /shared/csrs_1.conf about to fork child process, waiting until server is ready for connections. forked process: 2040 child process started successfully, parent exiting vagrant@m103:/ mongod -f /shared/csrs_2.conf
about to fork child process, waiting until server is ready for connections.
forked process: 2082
child process started successfully, parent exiting
vagrant@m103:/ mongod -f /shared/csrs_3.conf about to fork child process, waiting until server is ready for connections. forked process: 2165 child process started successfully, parent exiting vagrant@m103:/ mongo --port 26001 -u m103-admin -p m103-pass --authenticationDatabase “admin”
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:26001/?authSource=admin&gssapiServiceName=mongodb
2019-08-02T17:17:00.504+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:26001, in(checking socket for error after poll), reason: Connection refused
2019-08-02T17:17:00.541+0000 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:26001, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6
exception: connect failed
vagrant@m103:/ ps -ef|grep mongod vagrant 2082 1 3 17:15 ? 00:00:03 mongod -f /shared/csrs_2.conf vagrant 2165 1 3 17:15 ? 00:00:03 mongod -f /shared/csrs_3.conf vagrant 2265 1973 0 17:17 pts/0 00:00:00 grep --color=auto mongod vagrant@m103:/

But when I ran ps -ef|grep mongod, it wasn’t there

I’ve just retried and it continue the same way

vagrant@m103:/ mongod -f /shared/csrs_1.conf onDatabase "admin" about to fork child process, waiting until server is ready for connections. forked process: 2273 child process started successfully, parent exiting vagrant@m103:/ ps -ef|grep mongod
vagrant 2082 1 2 17:15 ? 00:00:10 mongod -f /shared/csrs_2.conf
vagrant 2165 1 2 17:15 ? 00:00:10 mongod -f /shared/csrs_3.conf
vagrant 2313 1973 0 17:22 pts/0 00:00:00 grep --color=auto mongod

{
“_id” : 2,
“name” : “192.168.103.100:26001”,
“health” : 0,
“state” : 8,
“stateStr” : “(not reachable/healthy)”,
“uptime” : 0,
“optime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDurable” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDate” : ISODate(“1970-01-01T00:00:00Z”),
“optimeDurableDate” : ISODate(“1970-01-01T00:00:00Z”),
“lastHeartbeat” : ISODate(“2019-08-02T18:04:01.736Z”),
“lastHeartbeatRecv” : ISODate(“1970-01-01T00:00:00Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “Connection refused”,
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“configVersion” : -1
}

It clearly says host on port 26001 is not healthy/not reachable
Did you start mongod on port 26001?
Your ps -ef|grep mongod shows only 2 mongods
You should have 3 mongods for 3 config servers up and running

Please check

Yes I did, the /shared/csrs_1.conf has
net:
bindIp: “localhost,192.168.103.100”
port: 26001

But i don’t see csrs_1.conf in your output
Please make sure all 3 config servers are up and running
Connect to primary and run rs.initiate()
Create user
Authenticate user
Then add other 2 nodes
Check rs.status(),rs.conf(),rs.isMaster()
You have pasted partial output
Please paste full output of rs.status()
Check our forum you will get clues/help

My problem is exactly that I can’t put the csrs_1.conf up and running. It appears to be running since the message that I receive when I run “mongod -f /shared/csrs_1.conf” is "
about to fork child process, waiting until server is ready for connections. forked process: 2273 child process started successfully, parent exiting"

After that I connect to the primary and run “rs.status()”, or when I run “ps -ef|grep mongod” outside the shell, I don’t see it running

I believe that I messed up when configuring the sharded cluster.

I might have done something wrong. Can I delete everything and restart from scratch?

Yes you can do that.Cleanup everything and restart
Also you can check mongod.log for more details on why crs1_conf not showing up
or killall mogod
Then try to start just the first crs1_conf
Verify if it is up then start other two one by one

1 Like

Still hasn’t work. How can I check mongod.log, to see why csrs_1.conf is not working?

Please open your config file.You should see this

systemLog:
destination: file
path: /var/mongodb/db/csrs1.log

1 Like