Lab - Configure a sharded cluster - issue starting mongos

Hi,

I have been trying to complete the lab but I am having issues starting mongos. I am using the following -

mongos -config/shared/mongos.cfg

Each time I do this I am getting -

about to fork child process, waiting until the server is ready for connections

I can’t get past this stage. I have stopped and re-tried but the same thing is happening.

Is anyone able to assist?

Many thanks,
Nicole

Hi @Nicole_17827,

In order to see the proper error message on the screen, you’ll need to comment out (using #) the entire processManagement and systemLog sections in your config file. Run it again and it should point you in the right direction. Or you could look at the tail of the mongos log file instead.

Hi @Nicole_17827,

In order to be able to help you, we need to look at the logs. Please run the following command to see the last 100 lines of your log file. If you are unable to figure it out then please share the output with us.

tail -n 100 <path to the log file as mentioned in your mongos.cfg file>

For instance this is what it looks like for me.

tail -n 100 /var/mongodb/db/mongos.log

Thanks,
Shubham Ranjan
Curriculum Services Engineer

Hi,

Thank you for getting back to me.

I went with the first suggestion and I found this was the issue ‘surprised to discover that 192.168.103.100:26001 does not believe it is a config server’. I think the issue was they had to be started with the clusterRole set to configsvr rather than shardsvr which is what my config files had. I have amended this and attempted to start but I am now having further issues.

I am now getting this when attempting to start the third config file although the first and second were ok -

vagrant@m103:~ mongod -config /shared/mongod-csrs-1.cfg about to fork child process, waiting until server is ready for connections. forked process: 25956 child process started successfully, parent exiting vagrant@m103:~ mongod -config /shared/mongod-csrs-2.cfg
about to fork child process, waiting until server is ready for connections.
forked process: 25997
child process started successfully, parent exiting
vagrant@m103:~ mongod -config /shared/mongod-csrs-3.cfg about to fork child process, waiting until server is ready for connections. forked process: 26039 ERROR: child process failed, exited with error number 14 To see additional information in this output, start without the "--fork" option. vagrant@m103:~ tail -n 100 /var/mongodb/db/mongos.log
2020-01-10T08:55:01.378+0000 W NETWORK [monitoring keys for HMAC] Unable to reach primary for set m103-csrs
2020-01-10T08:55:01.378+0000 I NETWORK [monitoring keys for HMAC] Cannot reach any nodes for set m103-csrs. Please check network connectivity and the status of the set. This has happened for 6 checks in a row.
2020-01-10T08:55:01.548+0000 W NETWORK [mongosMain] Failed to connect to 192.168.103.100:26001, in(checking socket for error after poll), reason: Connection refused
2020-01-10T08:55:01.549+0000 W NETWORK [mongosMain] Failed to connect to 192.168.103.100:26002, in(checking socket for error after poll), reason: Connection refused
2020-01-10T08:55:01.550+0000 W NETWORK [mongosMain] Failed to connect to 192.168.103.100:26003, in(checking socket for error after poll), reason: Connection refused
2020-01-10T08:55:01.550+0000 W NETWORK [mongosMain] Unable to reach primary for set m103-csrs
2020-01-10T08:55:01.551+0000 I NETWORK [mongosMain] Cannot reach any nodes for set m103-csrs. Please check network connectivity and the status of the set. This has happened for 7 checks in a row.
2020-01-10T08:55:01.879+0000 W NETWORK [monitoring keys for HMAC] Failed to connect to 192.168.103.100:26001, in(checking socket for error after poll), reason: Connection refused
2020-01-10T08:55:01.880+0000 W NETWORK [monitoring keys for HMAC] Failed to connect to 192.168.103.100:26003, in(checking socket for error after poll), reason: Connection refused
2020-01-10T08:55:01.881+0000 W NETWORK [monitoring keys for HMAC] Failed to connect to 192.168.103.100:26002, in(checking socket for error after poll), reason: Connection refused

I appreciate any help you can give me.

Best Regards,
Nicole

Hi @Nicole_17827,

I think you might have to delete the associated dbPath directories of the csrs config files and recreate it if you started it with the shardsvr cluster role. This is so because you cannot repurpose an existing replica set into config servers because of the additional restrictions on the replica set config servers.

In addition to this, please share the output of this command :

ping m103

Thanks,
Shubham Ranjan
Curriculum Services Engineer

Hi @Shubham_Ranjan,

This is the result of ping m103 -

vagrant@m103:~ ps -ef | grep [m]ongod vagrant@m103:~ ping m103
PING m103.mongodb.university (127.0.1.1) 56(84) bytes of data.
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=2 ttl=64 time=0.073 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=3 ttl=64 time=0.064 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=4 ttl=64 time=0.085 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=5 ttl=64 time=0.070 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=6 ttl=64 time=0.069 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=7 ttl=64 time=0.068 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=8 ttl=64 time=0.069 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=9 ttl=64 time=0.024 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=10 ttl=64 time=0.068 ms…

64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=522 ttl=64 time=0.063 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=523 ttl=64 time=0.081 ms
64 bytes from m103.mongodb.university (127.0.1.1): icmp_seq=524 ttl=64 time=0.033 ms

— m103.mongodb.university ping statistics —
524 packets transmitted, 524 received, 0% packet loss, time 523043ms
rtt min/avg/max/mdev = 0.000/0.050/0.683/0.048 ms

I stopped as it seemed to be going on indefinitely.

I also removed all the csrs1/2/3 directories and re-created -
vagrant@m103:~ cd /var/mongodb/db/ vagrant@m103:/var/mongodb/db dir
csrs1 csrs2 csrs3 mongod1.log mongos.log
vagrant@m103:/var/mongodb/db$ rm -r csrs1
vagrant@m103:/var/mongodb/db$ dir
csrs2 csrs3 mongod1.log mongos.log
vagrant@m103:/var/mongodb/db$ rm -r csrs2
vagrant@m103:/var/mongodb/db$ rm -r csrs3
vagrant@m103:/var/mongodb/db$ dir
mongod1.log mongos.log
vagrant@m103:/var/mongodb/db$ mkdir csrs1
vagrant@m103:/var/mongodb/db$ mkdir csrs2
vagrant@m103:/var/mongodb/db$ mkdir csrs3
vagrant@m103:/var/mongodb/db$ dir
csrs1 csrs2 csrs3 mongod1.log mongos.log

I was then able to start the mongod-csrs-1.cfg/mongod-csrs-2.cfg and mongod-csrs-3.cfg without any issue but when I attempt to start mongos I am getting this -

vagrant@m103:/var/mongodb/db$ mongos -config /shared/mongos.cfg
about to fork child process, waiting until server is ready for connections.
forked process: 26673
ERROR: child process failed, exited with error number 48
To see additional information in this output, start without the “–fork” option.

I have amended the config file and removed the --fork option and when I try to run this nothing happens -

vagrant@m103:/var/mongodb/db$ mongos -config /shared/mongos.cfg

I have checked the log file and this is what I am seeing -

2020-01-10T10:09:29.714+0000 I CONTROL [mongosMain] options: { config: “/shared/mongos.cfg”, net: { bindIp: “localhost,192.168.103.100”, port: 26000 }, security: { keyFile: “/var/mongodb/pki/m103-keyfile” }, sharding: { configDB: “m103-csrs/192.168.103.100:26001,192.168.103.100:26002,192.168.103.100:26003” }, systemLog: { destination: “file”, logAppend: true, path: “/var/mongodb/db/mongos.log” } }
2020-01-10T10:09:29.715+0000 E SHARDING [mongosMain] Failed to set up listener: SocketException: Address already in use
2020-01-10T10:09:29.715+0000 I CONTROL [mongosMain] shutting down with code:48

Many thanks,
Nicole

Hi @Nicole_17827,

The mapping between hostname and IP address is not happening correctly. Please refer this post for fixing the issue.

For the issue regarding your mongos, here is what the output says :

It looks like you already have the mongos process running on this port i.e. 26000. You can confirm it by running this command :

ps -ef | grep mongos

Hope it helps!

Please feel free to get back to us if you have any other query.

Thanks,
Shubham Ranjan
Curriculum Services Engineer

Hi @Shubham_Ranjan,

Thanks for getting back to me.

I have amended the hostname/IP address issue and this is the result when I now ping m103 -

vagrant@m103:/var/mongodb/db$ ping m103
PING m103.mongodb.university (192.168.103.100) 56(84) bytes of data.
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=1 ttl=64 time=0.024 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=2 ttl=64 time=0.070 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=3 ttl=64 time=0.069 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=4 ttl=64 time=0.069 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=5 ttl=64 time=0.071 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=6 ttl=64 time=0.024 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=7 ttl=64 time=0.085 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=8 ttl=64 time=0.034 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=9 ttl=64 time=0.034 ms
64 bytes from m103.mongodb.university (192.168.103.100): icmp_seq=10 ttl=64 time=0.048 ms…

When I run the ps -ef | grep mongos I see there was a mongos process already running.

I have closed everything and started again and I am now able to get the mongos process running as the steps indicate.

Thanks again for your help with this.

Best Regards,
Nicole