Linux – rpcbind not started at boot on centos 7 with systemd

centoscentos-7linuxsystemd

I need rpcbind service to be active after boot, so I installed it with yum, then started it by:

systemctl start rpcbind

it works. However after reboot it did not start. So I checked it with:

systemctl is-enabled rpcbind

and it showed: static which mean that some other service need it to boot, the service is rpcbind.socket, so I checked it and the rpcbind.socked showed that it is enabled (systemctl is-enabled rpcbind.socket returned enabled) but it does not work how it should

after boot when i execute:

systemctl status rpcbind

it show: failed (dead)

I have been searching for a while now this but without any luck, if anybody know a solution to this or faced this problem in the past then please help.

I'm using centos 7.1

if you need more information i can get it when i get to work tomorow

Best Answer

I've got the same problem on Debian 8 aka Jessie and, although systems are different, this solution could help, if you don't mind to alter configuration files.

Create file /etc/tmpfiles.d/rpcbind.conf:

#Type Path        Mode UID  GID  Age Argument
d     /run/rpcbind 0755 root root - -
f     /run/rpcbind/rpcbind.xdr 0600 root root - -
f     /run/rpcbind/portmap.xdr 0600 root root - -

Create /etc/systemd/system/rpcbind.service:

[Unit]
Description=RPC bind portmap service
After=systemd-tmpfiles-setup.service
Wants=remote-fs-pre.target
Before=remote-fs-pre.target
DefaultDependencies=no

[Service]
ExecStart=/sbin/rpcbind -f -w
KillMode=process
Restart=on-failure

[Install]
WantedBy=sysinit.target
Alias=portmap

and enabled above unit:

# systemctl enable rpcbind.service

Create /etc/systemd/system/nfs-common.service:

[Unit]
Description=NFS Common daemons
Wants=remote-fs-pre.target
DefaultDependencies=no

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/init.d/nfs-common start
ExecStop=/etc/init.d/nfs-common stop

[Install]
WantedBy=sysinit.target

Enable it with:

# systemctl enable nfs-common

Presumably, that should do the trick for CentOS as well.

It also looks like there is a newer version of rpcbind-0.2.3, which has native systemd support, but haven't try it...