MongoDB ERROr: child process failed, exited with error number 48

created at 08-13-2021 views: 132

error

startup error after installing mongodb as follows:

root@inspur-CE3000F:/usr/local/mongodb# /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 8485
ERROR: child process failed, exited with error number 48
To see additional information in this output, start without the "--fork" option.

solution

case1

In this case the reason is that the MongoDB service has already be opened one:

[root@localhost mongodb]# ps -ef | grep mongo
root       3429      1  1 01:06 ?        00:00:05 mongod --port=27017 --logpath=./log/mongodb.log --dbpath=./db --fork
root       4001   2124  0 01:15 pts/0    00:00:00 grep --color=auto mongo

The solution is very simple, close this MongoDB service

[root@localhost mongodb]# mongo
MongoDB shell version v5.0.8
> use admin
switched to db admin
> db.shutdownServer() #Shutdown MongoDB service
server should be down...
> exit #exit
# The following methods are also possible
[root@localhost mongodb]# mongod --dbpath=./db --shutdown

After closing it can be restarted

[root@localhost config]# cat mongodb.conf #Configuration file
systemLog:
   destination: file
   path: /usr/mongodb/log/mongodb.log
   logAppend: true
storage:
   dbPath: /usr/mongodb/db
   engine: wiredTiger
   journal:
     enabled: true
net:
   port: 27017
processManagement:
   fork: true


[root@localhost config]# mongod -f mongodb.conf #This is started using the configuration file
about to fork child process, waiting until server is ready for connections.
forked process: 4092
child process started successfully, parent exiting
[root@localhost config]#

case2

if the case1 is not your case, try this one.

1. First delete all files generated in data/ and log/

root@inspur-CE3000F:/usr/local/mongodb# cd data/
root@inspur-CE3000F:/usr/local/mongodb/data# ll
Total amount 168
drwxr-xr-x 3 root root  4096 8月  13 14:34 ./
drwxr-xr-x 5 root root  4096 8月  13 14:31 ../
-rw------- 1 root root 16384 8月  13 14:34 collection-0--5967688409628326018.wt
-rw------- 1 root root 16384 8月  13 14:34 index-0--3870810806853258746.wt
drwx------ 2 root root  4096 8月  13 14:34 journal/
-rw------- 1 root root 32768 8月  13 14:34 _mdb_catalog.wt
-rw------- 1 root root     0 8月  13 14:34 mongod.lock
-rw------- 1 root root 32768 8月  13 14:34 sizeStorer.wt
-rw------- 1 root root   114 8月  13 14:34 storage.bson
-rw------- 1 root root    45 8月  13 14:34 WiredTiger
-rw------- 1 root root  4096 8月  13 14:34 WiredTigerLAS.wt
-rw------- 1 root root    21 8月  13 14:34 WiredTiger.lock
-rw------- 1 root root  1063 8月  13 14:34 WiredTiger.turtle
-rw------- 1 root root 36864 8月  13 14:34 WiredTiger.wt
root@inspur-CE3000F:/usr/local/mongodb/data# rm -rf *

root@inspur-CE3000F:/usr/local/mongodb# cd logs/
root@inspur-CE3000F:/usr/local/mongodb/logs# ll
Total amount 20
drwxr-xr-x 2 root root  4096 8月  13 14:30 ./
drwxr-xr-x 5 root root  4096 8月  13 14:31 ../
-rw------- 1 root root 10816 8月  13 14:34 mongodb.log
root@inspur-CE3000F:/usr/local/mongodb/logs# rm -rf *

2. Then execute:

root@inspur-CE3000F:/usr/local/mongodb/bin# ./mongod --repair
2021-08-13T14:36:43.833+0800 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] MongoDB starting : pid=8698 port=27017 dbpath=/data/db 64-bit host=inspur-CE3000F
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] db version v4.0.25
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] git version: 89306fde6167fa12ea6e30d61e05791e8e214e55
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] modules: none
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] build environment:
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten]     distmod: ubuntu1604
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten]     distarch: aarch64
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten]     target_arch: aarch64
2021-08-13T14:36:43.837+0800 I CONTROL  [initandlisten] options: { repair: true }
2021-08-13T14:36:43.838+0800 I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db 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., terminating
2021-08-13T14:36:43.838+0800 I CONTROL  [initandlisten] Shutdown started
2021-08-13T14:36:43.838+0800 I REPL     [initandlisten] Stepping down the ReplicationCoordinator for shutdown, waitTime: 10000ms
2021-08-13T14:36:43.838+0800 I NETWORK  [initandlisten] Shutting down the global connection pool
2021-08-13T14:36:43.838+0800 I -        [initandlisten] Killing all operations for shutdown
2021-08-13T14:36:43.838+0800 I NETWORK  [initandlisten] Shutting down the ReplicaSetMonitor
2021-08-13T14:36:43.838+0800 I CONTROL  [initandlisten] Shutting down free monitoring
2021-08-13T14:36:43.838+0800 I FTDC     [initandlisten] Shutting down full-time data capture
2021-08-13T14:36:43.838+0800 I STORAGE  [initandlisten] Shutting down the HealthLog
2021-08-13T14:36:43.838+0800 I -        [initandlisten] Dropping the scope cache for shutdown
2021-08-13T14:36:43.838+0800 I CONTROL  [initandlisten] now exiting
2021-08-13T14:36:43.838+0800 I CONTROL  [initandlisten] shutting down with code:100
root@inspur-CE3000F:/usr/local/mongodb/bin# ps -ef|grep mongodb
mongodb    881     1  0 13:54 ?        00:00:03 /usr/bin/mongod --config /etc/mongodb.conf
root      8706  3280  0 14:36 pts/1    00:00:00 grep --color=auto mongodb
root@inspur-CE3000F:/usr/local/mongodb/bin# kill -9 881
root@inspur-CE3000F:/usr/local/mongodb/bin# kill -9 881
-bash: kill: (881) - No process

3. Start mongodb again

root@inspur-CE3000F:/usr/local/mongodb/bin# /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 8731
child process started successfully, parent exiting
root@inspur-CE3000F:/usr/local/mongodb/bin# ps -ef|grep mongodb
root      8731     1  0 14:37 ?        00:00:00 /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
root      8765  3280  0 14:37 pts/1    00:00:00 grep --color=auto mongodb

Successfully started

created at:08-13-2021
edited at: 06-06-2022: