最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】添加了IP限制的mongod重启出错:Job for mongod.service failed because the control process exited with error code

MongoDB crifan 15468浏览 0评论

折腾:

【已解决】给MongoDB限制IP访问

期间,去添加IP的限制:

<code>vi /etc/mongod.conf

     26 # network interfaces
     27 net:
     28   port: 32018
     29   bindIp: 127.0.0.1, 112.4.64.141 # Listen to specific IP
</code>

结果竟然重启mongod出错:

<code>[root@naturling-general-01 ~]# systemctl restart mongod
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
</code>

所以去试试:

<code>[root@naturling-general-01 ~]# journalctl -xe
Apr 09 17:50:01 naturling-general-01 systemd[1]: Started Session 185 of user root.
-- Subject: Unit session-185.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-185.scope has finished starting up.
-- 
-- The start-up result is done.
Apr 09 17:50:01 naturling-general-01 CROND[4627]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Apr 09 17:50:01 naturling-general-01 systemd[1]: Starting Session 185 of user root.
-- Subject: Unit session-185.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-185.scope has begun starting up.
Apr 09 17:57:17 naturling-general-01 polkitd[497]: Registered Authentication Agent for unix-process:4637:8872553 (system bus name :1.388 [/usr/bin/pkttyagent --notify-fd 5 --fallback], o
Apr 09 17:57:17 naturling-general-01 systemd[1]: Stopping SYSV: Mongo is a scalable, document-oriented database....
-- Subject: Unit mongod.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mongod.service has begun shutting down.
Apr 09 17:57:27 naturling-general-01 mongod[4643]: Stopping mongod: [  OK  ]
Apr 09 17:57:27 naturling-general-01 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
-- Subject: Unit mongod.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mongod.service has begun starting up.
Apr 09 17:57:27 naturling-general-01 runuser[4673]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Apr 09 17:57:27 naturling-general-01 runuser[4673]: pam_unix(runuser:session): session closed for user mongod
Apr 09 17:57:27 naturling-general-01 mongod[4662]: Starting mongod: [FAILED]
Apr 09 17:57:27 naturling-general-01 systemd[1]: mongod.service: control process exited, code=exited status=1
Apr 09 17:57:27 naturling-general-01 systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
-- Subject: Unit mongod.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mongod.service has failed.
-- 
-- The result is failed.
Apr 09 17:57:27 naturling-general-01 systemd[1]: Unit mongod.service entered failed state.
Apr 09 17:57:27 naturling-general-01 systemd[1]: mongod.service failed.
Apr 09 17:57:27 naturling-general-01 polkitd[497]: Unregistered Authentication Agent for unix-process:4637:8872553 (system bus name :1.388, object path /org/freedesktop/PolicyKit1/Authen
lines 4967-5010/5010 (END)
...
</code>

感觉是:

难道此处的127.0.0.1,不等于localhost?

然后本地重启mongod时,没有权限,所以报错了?

mongod Unregistered Authentication Agent for unix-process

mongo Unregistered Authentication Agent for unix-process

[Howto] Workaround failing MongoDB on RHEL/CentOS 7 – /home/liquidat

[SERVER-23863] MongoDB v3.2.5 crash due to permission denied execmem – SELinux CentOS 7 – MongoDB

说是和: SELinux有关?

linux – Mongodb not start because of polkitd – Stack Overflow

添加设置就可以了?

MongoDB 3.2.5 service fails to start in CentOS 7 – Google Groups

MongoDB fails starting as a service on CentOS 7 – Stack Overflow

“YAML files require spaces for indentation and not tabs.”

通过:

<code>[root@naturling-general-01 ~]# mongod -f /etc/mongod.conf 
about to fork child process, waiting until server is ready for connections.
forked process: 5574
ERROR: child process failed, exited with error number 48
[root@naturling-general-01 ~]# 
</code>

确定没有语法格式错误

然后去试试:

<code>[root@naturling-general-01 ~]# systemctl stop mongod
[root@naturling-general-01 ~]# systemctl start mongod
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
[root@naturling-general-01 ~]# systemctl status mongod
[0m mongod.service - SYSV: Mongo is a scalable, document-oriented database.
   Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-04-10 09:36:06 CST; 11s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4643 ExecStop=/etc/rc.d/init.d/mongod stop (code=exited, status=0/SUCCESS)
  Process: 5589 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)

Apr 10 09:36:06 naturling-general-01 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Apr 10 09:36:06 naturling-general-01 mongod[5589]: Error starting mongod. /var/run/mongodb/mongod.pid exists.
Apr 10 09:36:06 naturling-general-01 systemd[1]: mongod.service: control process exited, code=exited status=1
Apr 10 09:36:06 naturling-general-01 systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
Apr 10 09:36:06 naturling-general-01 systemd[1]: Unit mongod.service entered failed state.
Apr 10 09:36:06 naturling-general-01 systemd[1]: mongod.service failed.
</code>

Unable to start MongoDB 3.0.2 service on CentOS 7 – Stack Overflow

把IP限制的配置,再改回:

<code>     27 net:
     28   port: 32018
     29   bindIp: 0.0.0.0  # Listen to all interfaces
</code>

然后重启试试

结果问题依旧:

<code>[root@naturling-general-01 ~]# systemctl start mongod 
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
[root@naturling-general-01 ~]# systemctl restart mongod
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
[root@naturling-general-01 ~]# 
</code>

所以,看来是哪里出了问题了:

重启CentOS7试试

问题依旧

<code>[root@naturling-general-01 ~]# systemctl status mongod
[0m mongod.service - SYSV: Mongo is a scalable, document-oriented database.
   Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-04-10 09:40:26 CST; 20s ago
     Docs: man:systemd-sysv-generator(8)

Apr 10 09:40:25 naturling-general-01 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Apr 10 09:40:25 naturling-general-01 runuser[1069]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Apr 10 09:40:26 naturling-general-01 runuser[1069]: pam_unix(runuser:session): session closed for user mongod
Apr 10 09:40:26 naturling-general-01 mongod[1048]: Starting mongod: [FAILED]
Apr 10 09:40:26 naturling-general-01 systemd[1]: mongod.service: control process exited, code=exited status=1
Apr 10 09:40:26 naturling-general-01 systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
Apr 10 09:40:26 naturling-general-01 systemd[1]: Unit mongod.service entered failed state.
Apr 10 09:40:26 naturling-general-01 systemd[1]: mongod.service failed.
</code>

发现配置文件,所以去看看:

<code>[root@naturling-general-01 ~]# cat /etc/rc.d/init.d/mongod 
#!/bin/bash

# mongod - Startup script for mongod

# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf

. /etc/rc.d/init.d/functions

# NOTE: if you change any OPTIONS here, you get what you pay for:
# this script assumes all options are in the config file.
CONFIGFILE="/etc/mongod.conf"
OPTIONS=" -f $CONFIGFILE"

mongod=${MONGOD-/usr/bin/mongod}

MONGO_USER=mongod
MONGO_GROUP=mongod
...
</code>

Mongod service failed to start – Graylog – Graylog Community

去看看SELINUX的配置:

<code>[root@naturling-general-01 ~]# cat /etc/selinux/
config         final/         semanage.conf  targeted/      tmp/           
[root@naturling-general-01 ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@naturling-general-01 ~]# 
</code>

网上各种:

<code>SELINUX=permissive
semanage port -a -t mongod_port_t -p tcp 27017
</code>

但是此处SELINUX已经是disabled

没有开启SELinux了啊

去看看:

<code>[root@naturling-general-01 ~]# grep mongod /var/log/audit/audit.log
type=SERVICE_STOP msg=audit(1523158880.312:62481): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=mongod comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=CRED_ACQ msg=audit(1523158880.335:62482): pid=21353 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:setcred grantors=pam_rootok acct="mongod" exe="/usr/sbin/runuser" hostname=? addr=? terminal=? res=success’
…
</code>

type=USER_START msg=audit(1523324425.529:35): pid=1069 uid=0 auid=4294967295 ses=4294967295 msg=’op=PAM:session_open grantors=pam_keyinit,pam_limits,pam_unix acct=”mongod” exe=”/usr/sbin/runuser” hostname=? addr=? terminal=? res=success’

type=USER_END msg=audit(1523324426.254:36): pid=1069 uid=0 auid=4294967295 ses=4294967295 msg=’op=PAM:session_close grantors=pam_keyinit,pam_limits,pam_unix acct=”mongod” exe=”/usr/sbin/runuser” hostname=? addr=? terminal=? res=success’

type=CRED_DISP msg=audit(1523324426.254:37): pid=1069 uid=0 auid=4294967295 ses=4294967295 msg=’op=PAM:setcred grantors=pam_rootok acct=”mongod” exe=”/usr/sbin/runuser” hostname=? addr=? terminal=? res=success’

type=SERVICE_START msg=audit(1523324426.257:38): pid=1 uid=0 auid=4294967295 ses=4294967295 msg=’unit=mongod comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=failed’

type=SERVICE_START msg=audit(1523324583.115:71): pid=1 uid=0 auid=4294967295 ses=4294967295 msg=’unit=mongod comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=failed’

好像是最后几次的mongod的SERVICE_START是failed

然后去运行命令,结果找不到audit2allow:

<code>[root@naturling-general-01 ~]# grep mongod /var/log/audit/audit.log | audit2allow -m mongod &gt; mongod.te
-bash: audit2allow: command not found
</code>

SELINUX=disabled mongod Job for mongod.service failed because the control process exited with error code

Unable to start MongoDB 3.0.2 service on CentOS 7 – Stack Overflow

去试试:

<code>[root@naturling-general-01 ~]# sudo setenforce 0
setenforce: SELinux is disabled
</code>

问题依旧。

Can not start MongoDB 3.2.1 on CentOS 7 – Stack Overflow

linux – MongoDB Service Will Not Start After Initial Setup – Stack Overflow

configuration – MongoDB doesn’t start after changing the data directory – Database Administrators Stack Exchange

MongoDB无法在CentOS 7上作为服务启动 – 错误码

感觉最像的还是配置文件,可能有问题?

下载下来

<code>[root@naturling-general-01 ~]# sz /etc/mongod.conf 
rz
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring mongod.conf...
  100%     914 bytes  914 bytes/sec 00:00:01       0 Errors  

</code>

打开后:

没有看到问题,语法都是对的。

难道和端口变化有关系

去把端口改回27017

然后重启服务器,结果是可以的:

<code>[root@naturling-general-01 ~]# systemctl status mongod
[0m mongod.service - SYSV: Mongo is a scalable, document-oriented database.
   Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
   Active: active (running) since Tue 2018-04-10 10:23:53 CST; 18s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/mongod.service
           1096 /usr/bin/mongod -f /etc/mongod.conf

Apr 10 10:23:52 naturling-general-01 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Apr 10 10:23:52 naturling-general-01 runuser[1073]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Apr 10 10:23:53 naturling-general-01 mongod[1054]: Starting mongod: [  OK  ]
Apr 10 10:23:53 naturling-general-01 systemd[1]: Started SYSV: Mongo is a scalable, document-oriented database..
[root@naturling-general-01 ~]# netstat -lanp | grep 27017
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      1096/mongod         
unix  2      [ ACC ]     STREAM     LISTENING     12999    1096/mongod          /tmp/mongodb-27017.sock
[root@naturling-general-01 ~]# 
</code>

-》那就奇怪了,为何之前的:

改了端口,重启mongo或重启服务器,是正常的,

而现在改了端口重启就失败了???

不管了,再去改成我们要的端口:

<code>vi /etc/mongod.conf 

</code>

     26 # network interfaces

     27 net:

     28   port: 32018

     29   bindIp: 0.0.0.0  # Listen to all interfaces

     30 #  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.

     31 #  bindIp: 127.0.0.1, 112.4.64.141 # Listen to specific IP

     32 #  port: 27017

然后看看效果,然后果然出错了:

<code>[root@naturling-general-01 ~]# systemctl restart mongod
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
</code>

所以,现在锁定问题是端口改动,导致无法启动了

看来是端口需要加上访问权限?

【已解决】mongo启动失败:Failed to unlink socket file /tmp/mongodb-xxx.sock errno 1 Operation not permitted

最后证明是:sock文件没有权限,解决方案是删除掉sock文件,重启服务器即可。

【总结】

此处重启mongod出错:

Job for mongod.service failed because the control process exited with error code

的原因是:

现在mongod启用时mongod用户没有权限打开,之前某次用root创建的了sock文件

解决办法是:

删除掉改sock文件,重启服务器。

详见:

【已解决】mongo启动失败:Failed to unlink socket file /tmp/mongodb-xxx.sock errno 1 Operation not permitted

注意:

此处错误原因不是SELINUX(限制了端口)方面的问题,因为本身配置文件中:

/etc/selinux/config

已经是:

<code>SELINUX=disabled
</code>

表示已关闭了SELINUX

也因此后来的:

<code>sudo setenforce 0
</code>

是没有效果的,因为本身已关闭了SELINUX

【后记】

然后正常启动mongod后,去client中测试看看,是否别的IP访问就会出错

然后此处的对应的IP的client处的连接,至少是成功的:

然后再去PyCharm多连接一个,结果也是可以看到的:

<code>&gt; db.currentOp(true).inprog.forEach(function(d){if (d.client)printjson(d.client)})
"112.4.64.141:56260"
"127.0.0.1:34168"
&gt;
&gt; db.currentOp(true).inprog.forEach(function(d){if (d.client)printjson(d.client)})
"112.4.64.141:59012"
"112.4.64.141:59013"
"112.4.64.141:56260"
"127.0.0.1:34168"
</code>

然后才发现,mongod的配置中,此时是没有IP限制的:

<code>bindIp: 0.0.0.0
</code>

去加上IP限制:

<code>bindIp: 127.0.0.1, 112.4.64.141 # Listen to specific IP
</code>

看看效果,结果又出错了:

【已解决】mongo中给bindIp添加多个IP后出错:getaddrinfo failed Name or service not known

重启mongo后,还是出错:

<code>[root@naturling-general-01 ~]# systemctl restart mongod
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
</code>

问题还是没有解决。

然后解决了:

【已解决】mongo中给bindIp添加多个IP后出错:getaddrinfo failed Name or service not known

后,想要去重启,结果发现:

【未解决】systemctl或service无法重启或启动mongod的服务mongod

算了,用reboot去重启CentOS 7服务器吧,然后:

【无法解决】尝试用mongo的bindIp去实现限制特定IP才能连接mongo服务

然后再去:

【已解决】配置mongod以允许内网其他服务器访问mongo服务

但是还是没有完全成功:

<code>[root@naturling-general-01 ~]# systemctl status mongod
[0m mongod.service - SYSV: Mongo is a scalable, document-oriented database.
   Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-04-10 14:26:08 CST; 1min 31s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1270 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)

Apr 10 14:26:08 naturling-general-01 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Apr 10 14:26:08 naturling-general-01 mongod[1270]: Error starting mongod. /var/run/mongodb/mongod.pid exists.
Apr 10 14:26:08 naturling-general-01 systemd[1]: mongod.service: control process exited, code=exited status=1
Apr 10 14:26:08 naturling-general-01 systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
Apr 10 14:26:08 naturling-general-01 systemd[1]: Unit mongod.service entered failed state.
Apr 10 14:26:08 naturling-general-01 systemd[1]: mongod.service failed.
</code>

算了,重启CentOS7服务器,然后,还是失败,但是是别的错误:

【已解决】mongo启动失败:connection /var/lib/mongo/WiredTiger.turtle handle-open open Permission denied

那再去加上前面的,服务器本机的内网/局域网/私有IP,看看结果如何

<code>     27 net:
     28   port: 32018
     29   bindIp: 127.0.0.1,172.16.141.197 # Listen to specific IP
</code>

重启mongo,结果失败:

<code>[root@naturling-general-01 ~]# systemctl restart mongod
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
[root@naturling-general-01 ~]# systemctl stop mongod   
[root@naturling-general-01 ~]# sudo -u mongod mongod -f /etc/mongod.conf     
about to fork child process, waiting until server is ready for connections.
forked process: 1362
ERROR: child process failed, exited with error number 48
</code>

去看log,发现是127.0.0.1:32018已经正在运行了:

<code>2018-04-10T15:33:15.772+0800 E NETWORK  [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 127.0.0.1:32018
2018-04-10T15:33:15.772+0800 E NETWORK  [initandlisten]   addr already in use
2018-04-10T15:33:15.772+0800 E STORAGE  [initandlisten] Failed to set up sockets during startup.
2018-04-10T15:33:15.772+0800 I CONTROL  [initandlisten] dbexit:  rc: 48
</code>

所以,要去真正的停止掉mongod才可以

而此处的systemctl stop mongod 又没用。

去想办法,去试试,换成用户mongod去执行:

systemctl stop mongod  

是否可以?

结果需要root的密码:

<code>[root@naturling-general-01 ~]# sudo -u mongod systemctl stop mongod
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: Failed to stop mongod.service: Connection timed out
See system logs and 'systemctl status mongod.service' for details.
[root@naturling-general-01 ~]# polkit-agent-helper-1: pam_authenticate failed: Authentication failure
</code>

由于此处没有root密码,而是通过私钥登录服务器的

所以,干脆重启CentOS服务器吧

终于正常启动mongod了:

<code>[root@naturling-general-01 ~]# systemctl status mongod
[0m mongod.service - SYSV: Mongo is a scalable, document-oriented database.
   Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
   Active: active (running) since Tue 2018-04-10 15:37:29 CST; 20s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/mongod.service
           1096 /usr/bin/mongod -f /etc/mongod.conf

Apr 10 15:37:28 naturling-general-01 systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Apr 10 15:37:28 naturling-general-01 runuser[1077]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Apr 10 15:37:29 naturling-general-01 runuser[1077]: pam_unix(runuser:session): session closed for user mongod
Apr 10 15:37:29 naturling-general-01 mongod[1058]: Starting mongod: [  OK  ]
Apr 10 15:37:29 naturling-general-01 systemd[1]: Started SYSV: Mongo is a scalable, document-oriented database..
</code>

【总结】

此处的mongod启动出错:

Job for mongod.service failed because the control process exited with error code

的原因是:

其实有多种多样,具体的情况,需要根据实际情况去找原因,再去解决。

其中,辅助的办法是:

参考提提示的:

<code>Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
</code>

去运行:

<code>journalctl -xe
</code>

去看看具体的错误。

比如此处的:

<code>Unregistered Authentication Agent for unix-process:4637:8872553 
</code>

但是后来证明,无法根据此现象找到根本原因。

只是看起来像是:

端口权限方面的问题,有些人是SELINUX限制了端口导致的,而我此处没有开启SELINU,所以不是这方面的问题。

而真正解决问题的办法是:

此处主要是去看log文件

-》从中(先后多次)找到真正的具体的错误信息

-》然后才能知道错误原因

-〉然后才得以解决:

(1)错误:listen(): bind() failed errno:98 Address already in use for socket: 127.0.0.1:32018

办法:停止掉mongo后再重新启动:

  • 如果和我一样,没有root用户密码,则:reboot重启服务器

  • 有root密码:以mongod用户去停止mongo

    • sudo -u mongod systemctl stop mongod

(2)错误:getaddrinfo(” 112.4.64.141″) failed: Name or service not known

办法:确保bindIp中多个IP中间逗号分隔时,没有空格:

<code>bindIp: 127.0.0.1,112.4.64.141
</code>

详见:

【已解决】mongo中给bindIp添加多个IP后出错:getaddrinfo failed Name or service not known

(3)错误:WiredTiger (13) [1523341777:968015][1095:0x7fa3cf097dc0], file:WiredTiger.wt, connection: /var/lib/mongo/WiredTiger.turtle: handle-open: open: Permission denied

办法:确认

/var/lib/mongo

其下的所有的文件,包括此处的WiredTiger.turtle,对于此处的mongod用户,要有权限

-》可以考虑把所有文件的owner所有者,改为此处mongo 服务对应的所属用户:mongod:mongod

-》以及后续还有另外一个相关的:

/var/lib/mongo/journal/

中的文件,也是要确保有操作权限

-》具体写法:

<code>chown mongod:mongod /var/lib/mongo/WiredTiger.turtle
chown mongod:mongod /var/lib/mongo/WiredTigerLAS.wt 
chown mongod:mongod /var/lib/mongo/journal/*
</code>

详见:

【已解决】mongo启动失败:connection /var/lib/mongo/WiredTiger.turtle handle-open open Permission denied

(4)错误:Failed to unlink socket file /tmp/mongodb-32018.sock errno:1 Operation not permitted

办法:

删除这个sock文件:

<code>sudo rm /tmp/mongodb-32018.sock
</code>

后,重启mongod服务,或直接重启服务器-》启动服务器会去启动mongod服务的

详见:

【已解决】mongo启动失败:Failed to unlink socket file /tmp/mongodb-xxx.sock errno 1 Operation not permitted

转载请注明:在路上 » 【已解决】添加了IP限制的mongod重启出错:Job for mongod.service failed because the control process exited with error code

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (3)

  1. 也太长了吧,我看完journalctl -xe之后发现配置文件line 29语法出错,之前是按照注释里改的0.0.0.0,::,改成0.0.0.0就好了
    小黎4年前 (2020-09-16)回复
  2. 完全不知道在表达些什么,一堆废话
    15年前 (2019-10-08)回复
  3. 这么详细的note,多谢了! 我改了file ownership,解决了!
    redevil5年前 (2019-02-20)回复
92 queries in 0.188 seconds, using 22.25MB memory