启用 NFS 文件系统: [root@test ~]# yum install -y nfs-utils
将 /data 文件夹设置共享。在 /etc/exports文件中添加 /data *(rw,no_root_squash,insecure): [root@test ~]# vi /etc/exports
#若mountd端口大于1024,则需要加入'insecure':
/data *(rw,no_root_squash,insecure)
说明
请严格按照/etc/exports文件格式进行配置,您可执行man 5 exports命令查看具体的格式要求。
如果配置错误,会导致客户端中挂载文件系统失败。
启动 NFS 服务: [root@test ~]# systemctl start nfs.service
检查 NFS 服务显示如下状态,表示服务已正常: [root@test ~]# systemctl status nfs.service
â— nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
Active: active (exited) since Thu 2018-12-06 15:47:03 CST; 58s ago
Process: 10641 ExecStartPost=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl restart gssproxy ; fi (code=exited, status=0/SUCCESS)
Process: 10623 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 10621 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 10623 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
Dec 06 15:47:03 test systemd[1]: Starting NFS server and s...
Dec 06 15:47:03 test systemd[1]: Started NFS server and se...
Hint: Some lines were ellipsized, use -l to show in full.
添加开机启动: [root@test ~]# systemctl enable nfs.service
检查 rpcbind 服务显示如下状态,表示服务已正常: [root@test ~]# systemctl status rpcbind.service
â— rpcbind.service - RPC bind service
Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-12-06 15:47:03 CST; 7min ago
Main PID: 10598 (rpcbind)
CGroup: /system.slice/rpcbind.service
└─10598 /sbin/rpcbind -w
Dec 06 15:47:03 test systemd[1]: Starting RPC bind service...
Dec 06 15:47:03 test systemd[1]: Started RPC bind service.
Hint: Some lines were ellipsized, use -l to show in full.