Having Trouble With M103 Lab!

Hi guys,

I am doing the following Lab right now. Lab: Logging to a Different Facility

I am using the following mongod.conf file -

storage:
  dbPath: /data/db
net:
  bindIp: localhost
  port: 27000
security:
  authorization: enabled
systemLog:
  destination: file
  logAppend: true
  path: var/mongodb/logs/mongod.log

processManagement:
  fork: true

When I try and log into a different facility with the following line:

user@M103# mongod --auth --port 27000 --config mongod.conf --logpath var/mongodb/logs/mongod.log --fork

Blockquote

I get this error message:

about to fork child process, waiting until server is ready for connections.
forked process: 469
ERROR: child process failed, exited with error number 48
To see additional information in this output, start without the “–fork” option.
user@M103# mongod --auth --port 27000 --config mongod.conf --logpath var/mongodb/logs/mongod.log
about to fork child process, waiting until server is ready for connections.
forked process: 474
ERROR: child process failed, exited with error number 48
To see additional information in this output, start without the “–fork” option.

Sometimes I get error numbers 1 or 100 instead of 48 for the child processes failing.

Please let me know what to do

Thnx

Quiet Services

We would need more than just exit codes to help. 48 usually means that there is another process running with the host/port combination and you would see Address already in use in the log file, but it could also mean that your bindIp addresses have an invalid IP address and you would see Can't assign requested address. There might be more reasons for that exit code as well.

I’ve seen exit code 100 when the path to the database files didn’t exist and you would see something like the following in the log "NonExistentPath: Data directory tmp/not/there not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file.

Without the context of the error it’s hard to state what’s really going on.

So what do you suggest I do then?

how do I open up the mongod.log file to read it then? Or has it even been created?

do you want to see screenshots?

Based of your earlier post, you pointed the --logpath to var/mongodb/logs/mongod.log. I would recommend taking a look to see if that file was created and has anything worthwhile in it. I don’t have access to the machine you’re running things on so I can’t see.

It’s also interesting that you are using both command line options and a config file. If you have options in both locations, the command line option overrides the config file if I remember correctly. Can you share the contents of the mongod.conf file? I’m curious as to why you’re using both config file and command line options.

If the log file doesn’t have anything written to it, then you can run your command again leaving off the --dbpath and --fork options which should allow the log to be written to the terminal (again, you would have to remove similar sections from the config file as well).

You can always check to see if the mongod process is running by typing ps aux | grep mongod in the terminal to see if there is a process listed. You can also type mongosh in the shell to see if you make a connection. Both will let you know if there is a process running.

Again without seeing log data it’s hard for us to tell you specifically what’s going on and how to fix it.

As a final note, I think you just needed to run with the correctly formatted config file for this lab to work correctly.

These, in addition to other things that I asked for earlier always help in trying to figure out what’s going on.

Thanks for your response!

Here are the contents of my mongod.conf file.

storage:
dbPath: /data/db
net:
bindIp: localhost
port: 27000
security:
authorization: enabled
systemLog:
destination: file
logAppend: true
path: var/mongodb/logs/mongod.log
processManagement:
fork: true

I have also confirmed that the mongod.log file has been created. Here are the contents of that file. Please have a look:

2022-09-12T20:59:24.064+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten] MongoDB starting : pid=377 port=27000 dbpath=/data/db 64-bit host=KKqaSeZlGLlLvcKPOB
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten] allocator: system
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten] modules: none
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten] build environment:
2022-09-12T20:59:24.070+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-12T20:59:24.071+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-12T20:59:24.071+0000 I CONTROL  [initandlisten] options: { config: "mongod.conf", net: { bindIp: "localhost", port: 27000 }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "var/mongodb/logs/mongod.log" } }
2022-09-12T20:59:24.071+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T20:59:24.071+0000 I CONTROL  [initandlisten] now exiting
2022-09-12T20:59:24.071+0000 I CONTROL  [initandlisten] shutting down with code:48
2022-09-12T20:59:35.500+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2022-09-12T20:59:35.500+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] MongoDB starting : pid=397 port=27000 dbpath=/data/db 64-bit host=KKqaSeZlGLlLvcKPOB
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] allocator: system
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] modules: none
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] build environment:
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-12T20:59:35.508+0000 I CONTROL  [initandlisten] options: { config: "mongod.conf", net: { bindIp: "localhost", port: 27000 }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "var/mongodb/logs/mongod.log" } }
2022-09-12T20:59:35.509+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T20:59:35.509+0000 I CONTROL  [initandlisten] now exiting
2022-09-12T20:59:35.509+0000 I CONTROL  [initandlisten] shutting down with code:48
2022-09-12T21:00:56.475+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2022-09-12T21:00:56.476+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-12T21:00:56.483+0000 I CONTROL  [initandlisten] MongoDB starting : pid=436 port=27000 dbpath=/data/db 64-bit host=KKqaSeZlGLlLvcKPOB
2022-09-12T21:00:56.483+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-12T21:00:56.483+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-12T21:00:56.483+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-12T21:00:56.483+0000 I CONTROL  [initandlisten] allocator: system
2022-09-12T21:00:56.483+0000 I CONTROL  [initandlisten] modules: none
2022-09-12T21:00:56.484+0000 I CONTROL  [initandlisten] build environment:
2022-09-12T21:00:56.484+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-12T21:00:56.484+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-12T21:00:56.484+0000 I CONTROL  [initandlisten] options: { config: "mongod.conf", net: { bindIp: "localhost", port: 27000 }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "var/mongodb/logs/mongod.log" } }
2022-09-12T21:00:56.484+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:00:56.484+0000 I CONTROL  [initandlisten] now exiting
2022-09-12T21:00:56.484+0000 I CONTROL  [initandlisten] shutting down with code:48
2022-09-12T21:01:36.929+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2022-09-12T21:01:36.930+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] MongoDB starting : pid=442 port=27000 dbpath=/data/db 64-bit host=KKqaSeZlGLlLvcKPOB
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] allocator: system
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] modules: none
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] build environment:
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] options: { config: "mongod.conf", net: { bindIp: "localhost", port: 27000 }, processManagement: { fork: true }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "var/mongodb/logs/mongod.log" } }
2022-09-12T21:01:36.937+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] now exiting
2022-09-12T21:01:36.937+0000 I CONTROL  [initandlisten] shutting down with code:48
2022-09-12T21:01:51.678+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2022-09-12T21:01:51.679+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten] MongoDB starting : pid=447 port=27000 dbpath=/data/db 64-bit host=KKqaSeZlGLlLvcKPOB
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten] allocator: system
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten] modules: none
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten] build environment:
2022-09-12T21:01:51.686+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-12T21:01:51.687+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-12T21:01:51.687+0000 I CONTROL  [initandlisten] options: { config: "mongod.conf", net: { bindIp: "localhost", port: 27000 }, processManagement: { fork: true }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "var/mongodb/logs/mongod.log" } }
2022-09-12T21:01:51.687+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:01:51.687+0000 I CONTROL  [initandlisten] now exiting
2022-09-12T21:01:51.687+0000 I CONTROL  [initandlisten] shutting down with code:48
2022-09-12T21:05:59.091+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2022-09-12T21:05:59.092+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] MongoDB starting : pid=469 port=27000 dbpath=/data/db 64-bit host=KKqaSeZlGLlLvcKPOB
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] allocator: system
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] modules: none
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] build environment:
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-12T21:05:59.099+0000 I CONTROL  [initandlisten] options: { config: "mongod.conf", net: { bindIp: "localhost", port: 27000 }, processManagement: { fork: true }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "var/mongodb/logs/mongod.log" } }
2022-09-12T21:05:59.100+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:05:59.100+0000 I CONTROL  [initandlisten] now exiting
2022-09-12T21:05:59.100+0000 I CONTROL  [initandlisten] shutting down with code:48
2022-09-12T21:06:04.262+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2022-09-12T21:06:04.263+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] MongoDB starting : pid=474 port=27000 dbpath=/data/db 64-bit host=KKqaSeZlGLlLvcKPOB
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] allocator: system
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] modules: none
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] build environment:
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] options: { config: "mongod.conf", net: { bindIp: "localhost", port: 27000 }, processManagement: { fork: true }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" }, systemLog: { destination: "file", logAppend: true, path: "var/mongodb/logs/mongod.log" } }
2022-09-12T21:06:04.271+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] now exiting
2022-09-12T21:06:04.271+0000 I CONTROL  [initandlisten] shutting down with code:48

Please try and have a look now and see if you can help me out or not!

Thanks a million Doug!

oh thanks!

I just got it to work!

i keep getting the same error code when I try and repeat it!

was that a fluke or a glitch in the terminal?

Taking a look at the interesting bits of the log file you pasted above, we have the following:

2022-09-12T20:59:24.071+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T20:59:24.071+0000 I CONTROL [initandlisten] shutting down with code:48
2022-09-12T20:59:35.500+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2022-09-12T20:59:35.509+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T20:59:35.509+0000 I CONTROL [initandlisten] shutting down with code:48
2022-09-12T21:00:56.475+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2022-09-12T21:00:56.484+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:00:56.484+0000 I CONTROL [initandlisten] shutting down with code:48
2022-09-12T21:01:36.929+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2022-09-12T21:01:36.937+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:01:36.937+0000 I CONTROL [initandlisten] shutting down with code:48
2022-09-12T21:01:51.678+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2022-09-12T21:01:51.687+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:01:51.687+0000 I CONTROL [initandlisten] shutting down with code:48
2022-09-12T21:05:59.091+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2022-09-12T21:05:59.100+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:05:59.100+0000 I CONTROL [initandlisten] shutting down with code:48
2022-09-12T21:06:04.262+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2022-09-12T21:06:04.271+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-12T21:06:04.271+0000 I CONTROL [initandlisten] shutting down with code:48

This shows that the service was restarted at least six time, and every time it failed with Address in use. This is generally a sign that another instance of MongoDB is running on the given port. That’s why I suggested you run ps aux | grep mongod to see if there was a process running already.

The command line options you were supplying all appear to be covered by options in your config file, with the exception of auth. No need to duplicate them. It’s best to put everything in the config file so you don’t have to do too much typing and your server starts the same way every time.

That’s great!

I wasn’t watching over your shoulder so not sure what changed. If you restarted the shell, or stopped a mongod process, then you would be able to run the mongod ... command without issue. You can not run mongod ... multiple times on the same machine unless you change the port option. If you don’t, then you get the error from your logs.

1 Like