启动nfs服务时报错 systemd: rpcbind.socket failed to listen on sockets: Address family not supported by ...

问题描述

在使用 “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
    

你可能感兴趣的:(启动nfs服务时报错 systemd: rpcbind.socket failed to listen on sockets: Address family not supported by ...)