美文网首页
记一次mongodb启动不了的解决方法

记一次mongodb启动不了的解决方法

作者: W朱珠W | 来源:发表于2020-01-07 20:47 被阅读0次

    启动不了,分别报错如下:

    ERROR: child process failed, exited with error number 1

    ERROR: child process failed, exited with error number 51

    1,第一次尝试启动mongod,报错,取消执行,
    ai-learning-mongo-1-[root@ai-learning-mongo-1 mongodb]# su - mongo

    Last login: Tue Jan  7 16:40:11 CST 2020 on pts/1

    [mongo@ai-learning-mongo-1 ~]$ /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf &

    [1] 16477

    [mongo@ai-learning-mongo-1 ~]$ about to fork child process, waiting until server is ready for connections.

    forked process: 16479

    ERROR: child process failed, exited with error number 1

    To see additional information in this output, start without the "--fork" option.

    ^C

    [1]+  Exit 1                  /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf

    2,检查目录,发现配置文件权限不对,修改目录权限

    [mongo@ai-learning-mongo-1 ~]$ cd /app/mongodb/

    [mongo@ai-learning-mongo-1 mongodb]$ ll

    total 12

    drwxr-xr-x 2 mongo mongo  248 Feb 26  2019 bin

    drwxr-xr-x 8 mongo mongo  295 Jan  7 16:39 db

    -r-------- 1 mongo mongo 1024 Feb 26  2019 keyfile

    drwxr-xr-x 2 mongo mongo  24 Jan  7 15:46 logs

    -rw-r--r-- 1 root  root  785 Feb 26  2019 mongod.conf

    -rw-r--r-- 1 mongo mongo    6 Jan  7 16:39 mongod.pid

    [mongo@ai-learning-mongo-1 mongodb]$ chown -R  mongo:mongo mongod.conf

    chown: changing ownership of ‘mongod.conf’: Operation not permitted

    [mongo@ai-learning-mongo-1 mongodb]$ exit

    logout

    3,修改配置文件权限

    ai-learning-mongo-1-[root@ai-learning-mongo-1 ~]# chown -R mongo:mongo /app/mongodb/mongod.conf

    4,尝试重新启动,还是报一样的错,排查可能目录属主还有可能是其他用户,继续往下级目录查看,发现bin目录下还是没有改掉权限

    [2020/1/7 16:47:59] [mongo@ai-learning-mongo-1 mongodb]$ cd bin/

    [2020/1/7 16:48:00] [mongo@ai-learning-mongo-1 bin]$ ll

    [2020/1/7 16:48:00] total 285444

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 10546472 Nov 14  2018 bsondump

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root    7770 Nov 14  2018 install_compass

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 33750624 Nov 14  2018 mongo

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 59532264 Nov 14  2018 mongod

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 12848240 Nov 14  2018 mongodump

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 10884072 Nov 14  2018 mongoexport

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 10767240 Nov 14  2018 mongofiles

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 11024432 Nov 14  2018 mongoimport

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 59036976 Nov 14  2018 mongoperf

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 13955512 Nov 14  2018 mongoreplay

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 13941224 Nov 14  2018 mongorestore

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 34171112 Nov 14  2018 mongos

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 11080688 Nov 14  2018 mongostat

    [2020/1/7 16:48:00] -rwxr-xr-x 1 root root 10721912 Nov 14  2018 mongotop

    [2020/1/7 16:48:34] [mongo@ai-learning-mongo-1 bin]$ exit

    [2020/1/7 16:48:34] logout

    5,修改整个目录结构的权限

    [2020/1/7 16:49:07] ai-learning-mongo-1-[root@ai-learning-mongo-1 mongodb]# chown -R mongo:mongo /app/mongodb/

    6,尝试启动,报error number 51

    [2020/1/7 17:09:53] [mongo@ai-learning-mongo-1 db]$ /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf &

    [2020/1/7 17:09:53] [1] 18399

    [2020/1/7 17:09:53] [mongo@ai-learning-mongo-1 db]$ about to fork child process, waiting until server is ready for connections.

    [2020/1/7 17:09:53] forked process: 18401

    [2020/1/7 17:09:56] ERROR: child process failed, exited with error number 51

    [2020/1/7 17:09:56] To see additional information in this output, start without the "--fork" option.

    [2020/1/7 17:10:41] ^C

    [2020/1/7 17:10:41] [1]+  Exit 51                /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf

    7,启动不了mongodb,查看日志 less /app/mongodb/logs/mongod.log

    8,根据报错,open: too many open files ,认为应该是open files 数量不够,查阅资料修改

    https://blog.csdn.net/qq_26614295/article/details/81502338

    根据以上文章修改ulimit -HSn 102400 参数,并且删除lock文件,清空log/目录下日志,

    [2020/1/7 17:25:25] [mongo@ai-learning-mongo-1 db]$ rm -f mongod.lock

    [2020/1/7 17:25:29] [mongo@ai-learning-mongo-1 mongodb]$ cd logs

    [2020/1/7 17:25:30] [mongo@ai-learning-mongo-1 logs]$ ll

    [2020/1/7 17:25:30] total 24

    [2020/1/7 17:25:30] -rw-rw-r-- 1 mongo mongo 21997 Jan  7 17:09 mongod.log

    [2020/1/7 17:25:55] [mongo@ai-learning-mongo-1 logs]$ mv mongod.log /tmp/mongod.log.25

    9,重启启动,成功启动mongod 

    [2020/1/7 17:26:09] [mongo@ai-learning-mongo-1 logs]$ /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf &

    [2020/1/7 17:26:09] [1] 19549

    [2020/1/7 17:26:09] [mongo@ai-learning-mongo-1 logs]$ about to fork child process, waiting until server is ready for connections.

    [2020/1/7 17:26:09] forked process: 19552

    [2020/1/7 17:26:21] child process started successfully, parent exiting

    [2020/1/7 17:26:29]

    [2020/1/7 17:26:29] [1]+  Done                    /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf

    [2020/1/7 17:26:35] [mongo@ai-learning-mongo-1 logs]$ ps -ef | grep mongod

    [2020/1/7 17:26:35] appuser  13359  9538  0 16:01 pts/0    00:00:00 vi mongod.conf

    [2020/1/7 17:26:35] mongo    19552    1 50 17:26 ?        00:00:13 /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf

    [2020/1/7 17:26:35] mongo    19679 19442  0 17:26 pts/1    00:00:00 grep --color=auto mongod

    10,另外一台服务器修改以上参数,并且修改目录权限,重启发现报错error number 1

    11,查看mongod.log ,尝试提高--maxConnes,启动失败,报错error number 1

    [mongo@ai-learning-mongo-2 logs]$ /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf --maxConns=2000 & 

    12,根据日志钟第二行,permissions on /app/mongodb/keyfile are too open ,怀疑/app/mongodb/keyfile文件权限给多了,查看权限,果然给多了,收回权限改为400,

    [mongo@ai-learning-mongo-2 logs]$ ll /app/mongodb/keyfile

    [2020/1/7 17:39:47] -rwxrwxrwx 1 mongo mongo 1024 Feb 26  2019 /app/mongodb/keyfile

    [2020/1/7 17:40:12] [mongo@ai-learning-mongo-2 logs]$ exit

    [2020/1/7 17:40:12] logout

    [2020/1/7 17:40:23] ai-learning-mongo-2-[root@ai-learning-mongo-2 mongodb]# chmod 400 /app/mongodb/keyfile 

    13,再次尝试启动,此次启动成功

    [2020/1/7 17:41:14] ai-learning-mongo-2-[root@ai-learning-mongo-2 mongodb]# su - mongo

    [2020/1/7 17:41:15] Last login: Tue Jan  7 17:33:56 CST 2020 on pts/2

    [2020/1/7 17:41:27] [mongo@ai-learning-mongo-2 ~]$  /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf &

    [2020/1/7 17:41:27] [1] 21252

    [2020/1/7 17:41:27] [mongo@ai-learning-mongo-2 ~]$ about to fork child process, waiting until server is ready for connections.

    [2020/1/7 17:41:27] forked process: 21254

    [2020/1/7 17:41:34] child process started successfully, parent exiting

    [2020/1/7 17:42:01]

    [2020/1/7 17:42:01] [1]+  Done                    /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf

    [2020/1/7 17:42:01] [mongo@ai-learning-mongo-2 ~]$

    [2020/1/7 17:42:07] [mongo@ai-learning-mongo-2 ~]$ ps -ef | grep mongo

    [2020/1/7 17:42:07] root    21222 20426  0 17:41 pts/2    00:00:00 su - mongo

    [2020/1/7 17:42:07] mongo    21223 21222  0 17:41 pts/2    00:00:00 -bash

    [2020/1/7 17:42:07] mongo    21254    1 17 17:41 ?        00:00:06 /app/mongodb/bin/mongod --config /app/mongodb/mongod.conf

    [2020/1/7 17:42:07] mongo    21389 21223  0 17:42 pts/2    00:00:00 ps -ef

    [2020/1/7 17:42:07] mongo    21390 21223  0 17:42 pts/2    00:00:00 grep --color=auto mongo

    相关文章

      网友评论

          本文标题:记一次mongodb启动不了的解决方法

          本文链接:https://www.haomeiwen.com/subject/foddactx.html