問題描述
在使用 “sudo systemctl restart nfs” 命令啓動 nfs 服務時報錯,/var/log/message 文件中有如下錯誤
Sep 29 09:39:47 myhost systemd: Starting Preprocess NFS configuration...
Sep 29 09:39:47 myhost systemd: rpcbind.socket failed to listen on sockets: Address family not supported by protocol
Sep 29 09:39:47 myhost systemd: Failed to listen on RPCbind Server Activation Socket.
解決辦法
-
修改 /etc/sysctl.conf 文件
添加如下兩行
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
-
修改 rpcbind.socket 文件
首先查找 rpcbind.socket 文件路徑
$ sudo find /etc/ -name '*rpcbind.socket*' /etc/systemd/system/sockets.target.wants/rpcbind.socket
編輯 /etc/systemd/system/sockets.target.wants/rpcbind.socket 文件,將其中 ListenStream 關於IPv6的部分註釋掉,如下:
[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
-
重新啓動 nfs 服務
$ sudo systemctl daemon-reload $ sudo systemctl restart nfs