Centos7启动rcpbind报错A dependency job for rpcbind.service failed一例

Centos7.4 rpcbind启动失败一例

问题描述

昨天,一台虚拟机重启后,/etc/rc.local里面的mount -t nfs ....发现没有正常执行。

问题排查

经过排查,发现rpcbind没有正常启动,导致无法正常mount。 于是执行以下命令:

# systemctl restart rpcbind

A dependency job for rpcbind.service failed. See 'journalctl -xe' for details.```

显然,提示rpcbind依赖的服务没启动,看下它依赖哪个服务

# cat /usr/lib/systemd/system/rpcbind.service 
[Unit]
Description=RPC bind service
Requires=rpcbind.socket
After=systemd-tmpfiles-setup.service

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/rpcbind
ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS

[Install]
Also=rpcbind.socket

看到依赖的是Requires=rpcbind.socketsystemctl restart rpcbind.socket试试

# systemctl restart rpcbind.socket
Job for rpcbind.socket failed. See "systemctl status rpcbind.socket" and "journalctl -xe" for details.
# systemctl status rpcbind.socket
● rpcbind.socket - RPCbind Server Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/rpcbind.socket; enabled; vendor preset: enabled)
   Active: failed (Result: resources)
   Listen: /var/run/rpcbind.sock (Stream)
           [::]:111 (Stream)
           0.0.0.0:111 (Stream)

May 22 10:25:30 szvxl4160 systemd[1]: Starting RPCbind Server Activation Socket.
May 22 10:26:56 szvxl4160 systemd[1]: rpcbind.socket failed to listen on sockets: Address family not supported by protocol
May 22 10:26:56 szvxl4160 systemd[1]: Failed to listen on RPCbind Server Activation Socket.
May 22 10:26:56 szvxl4160 systemd[1]: Starting RPCbind Server Activation Socket.
May 22 10:55:55 szvxl4160 systemd[1]: rpcbind.socket failed to listen on sockets: Address family not supported by protocol
May 22 10:55:55 szvxl4160 systemd[1]: Failed to listen on RPCbind Server Activation Socket.
May 22 10:55:55 szvxl4160 systemd[1]: Starting RPCbind Server Activation Socket.
May 22 10:56:07 szvxl4160 systemd[1]: rpcbind.socket failed to listen on sockets: Address family not supported by protocol
May 22 10:56:07 szvxl4160 systemd[1]: Failed to listen on RPCbind Server Activation Socket.
May 22 10:56:07 szvxl4160 systemd[1]: Starting RPCbind Server Activation Socket.

发现报错rpcbind.socket failed to listen on sockets: Address family not supported by protocol, 看下rpcbind.socketsystemd文件

# cat /usr/lib/systemd/system/rpcbind.socket 
[Unit]
Description=RPCbind Server Activation Socket

[Socket]
ListenStream=/var/run/rpcbind.sock
ListenStream=[::]:111
ListenStream=0.0.0.0:111
BindIPv6Only=ipv6-only

[Install]
WantedBy=sockets.target

可以看到这里依赖于ipv6, 到这里,猜测可能是sysctl.conf里面配置了禁止ipv6相关的参数

# cat /etc/sysctl.conf | grep ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

果然如此,修改一下/etc/sysctl.conf,将

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
修改为
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 0

执行sysctl -p让其生效, 再次执行systemctl restart rpcbind ,可正常启动。

当然还有另一种思路,就是修改/usr/lib/systemd/system/rpcbind.socket,改成如下:

# cat  /usr/lib/systemd/system/rpcbind.socket   
[Unit]
Description=RPCbind Server Activation Socket

[Socket]
ListenStream=/var/run/rpcbind.sock

[Install]
WantedBy=sockets.target

然后重启rpcbind, 继续使用mount挂载nfs即可。

posted @ 2023-05-22 11:11  xuege  阅读(839)  评论(0编辑  收藏  举报