Mongo S server can't start up!

Hello guys,

I am doing the lab for course M103 Chapter 3 during the last few days and I can’t seem to be able to get to start up when initiating it through the config server replica set -

The configuration I used for the mongos.conf file is the following:

sharding:
   configDB: csrs/localhost:27004, localhost:27005, localhost:27006  
security:
  keyFile: /var/mongodb/pki/m103-keyfile
net:
  bindIp: localhost
  port: 26000
systemLog:
  destination: file
  path: /var/mongodb/logs/mongos.log
  logAppend: true
processManagement:
  fork: true

The command I tried running it with is the following:

mongos -f mongos.conf


The output is an error message that says the following:

user@M103# mongos -f mongos.conf
Unrecognized option: sharding.clusterRole
try 'mongos --help' for more information
user@M103# mongos -f mongos.conf
2022-10-12T13:05:36.679+0000 I NETWORK  [main] getaddrinfo(" localhost") failed: Try again
2022-10-12T13:05:41.685+0000 I NETWORK  [main] getaddrinfo(" localhost") failed: Try again
about to fork child process, waiting until server is ready for connections.
forked process: 861
ERROR: child process failed, exited with error number 2
To see additional information in this output, start without the "--fork" option.

Please tell me why I am getting these errors!

Thnx

QUIET Services!

Anyone home? why am I getting the error? It says exited with error number 2…

any ideas?

Hi @Quiet_Services, can you share the log entries? With that we will be more able to help determine why the mognod process didn’t start up properly.

where do I find the log entries?

this is for the lab IDE…i don’t think I will be able to get log entries for that…

any ideas why its causing me issues?

You config file shows the log to be located at /var/mongodb/logs/mongos.log.

so how will i be able to access that log then?

what code do I need to enter to grab that?

what commands do I use? and do I use them after logging into a node or what?

cat /var/mongodb/logs/mongos.log

This will print the entire contents of the log file. You will need to copy and paste that here.

You said this was in the course IDE. If that’s the case there is no node to log in to.

I get this message now from the IDE course lab -

Blockquote user@M103# cat /var/mongodb/logs/mongos.log
cat: can’t open ‘/var/mongodb/logs/mongos.log’: No such file or directory
user@M103#

Blockquote

Here is an attached image with the screenshot showing the error message.

I am confused as to what I should do now.

Have you tried running mongod -f mongos.conf during this session? If not then the log file would not have been created. Each time you start the IDE you get a brand new session and everything is reverted back to a clean state.

If you have ran the command then there’s something wrong as that is where you told the mongod process to write the log to. Without log info we can’t tell you what’s going on.

should I try a mongod with it instead?

What do you mean? The only way to get logs in that path is to run the mongod -f mongos.conf command. You could also remove the the four lines for systemLog and two lines for processManagement from your config file. This will print all the log entries directly to the screen.

Ok I did that and this is what I got:

Blockquote user@M103# mongod -f mongos.conf
2022-10-12T18:15:17.281+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] MongoDB starting : pid=954 port=26000 dbpath=/data/db 64-bit host=TE75TgEkwdxPQcEIl0
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] db version v4.0.5
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] allocator: system
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] modules: none
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] build environment:
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] distarch: x86_64
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] target_arch: x86_64
2022-10-12T18:15:17.325+0000 I CONTROL [initandlisten] options: { config: “mongos.conf”, net: { bindIp: “localhost”, port: 26000 }, security: { keyFile: “/var/mongodb/pki/m103-keyfile” } }
2022-10-12T18:15:17.366+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2022-10-12T18:15:17.366+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets…
2022-10-12T18:15:17.366+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-26000.sock
2022-10-12T18:15:17.366+0000 I CONTROL [initandlisten] now exiting
2022-10-12T18:15:17.366+0000 I CONTROL [initandlisten] shutting down with code:100

Blockquote

Please let me know what to do next.

Thanks

I can’t get mongos -f mongos.conf to work right now.

It says the following:

Blockquote user@M103# mongos -f mongos.conf
BadValue: error: no args for --configdb
try ‘mongos --help’ for more information
user@M103#

Blockquote

How do I get this entire thing to work now. Thanks

so what do I do next Doug?

If you look at the fifth line from the bottom you see:

MongoDB is trying to create its data files in /data/db and that path doesn’t exist.

Run mkdir -p /data/db and this issue will go away.

Here the terminal is telling you what the issue is. You have no --configdb command line parameter (or corresponding config option) passed to the mongos process.

It seems like you need to go back and watch the videos as you seem to be missing a lot of information to make the process run.

yessss!

thanks a million bud!

i finally managed to get it done!

yippy!