CentOS NFS(网络文件系统)是一种在分(fen)布式计算环境中实(shi)现(xian)文件共享的协议,通过使用NFS,可以在不同的计算机之间共享文件(jian)和目录,从而实(shi)现数据和资(zi)源的高效利用,本文将介绍如何在CentOS 7上安装和配置NFS服务。
一、安装NFS服务
1. 确保系统(tong)已经(jing)更新到最新版本,在终端中输入以下命令:


sudo yum update
2. 安装NFS服务所需的软件包,在(zai)终端中输入以下命令:

sudo yum install nfs-utils3. 启动并设置NFS服务开机自启,在终端中输入以下命令:
sudo systemctl start nfs-serversudo systemctl enable nfs-server
4. 查看NFS服务(wu)状态,在终端中输入以下命令:
sudo systemctl status nfs-server
二、配置NFS共享目录
1. 创建一个用于共享的(de)目录,创建一个名为“/shared”的目录:
sudo mkdir /shared
2. 设置该目录的权限,以便其他用户可以访问和修改,设置为所有用户可读写:
sudo chmod 777 /shared3. 在客户端计算机上(shang)创建(jian)一个挂载点,用于访问(wen)共享目录,创建一个(ge)名为“/mnt/nfs”的目录:
sudo mkdir /mnt/nfs
sudo mount -t nfs 192.168.1.100:/shared /mnt/nfs
5. 若要使挂载(zai)在(zai)系(xi)统启动时(shi)自动生效,需要编辑“/etc/fstab”文件,备份文(wen)件:
sudo cp /etc/fstab /etc/fstab.bak
使用文本编辑器打(da)开“/etc/fstab”文件(jian),例如使用“vi”编辑器:
sudo vi /etc/fstab
在文件末尾添加以下行(xing),其中“192.168.1.100”是远程服务(wu)器的IP地址,“/shared”是共享目录的路径:“192.168.1.100:/shared /mnt/nfs nfs defaults 0 0”
sudo mount -a
三、验证NFS共享是否成功
1. 在客户端计算(suan)机上运行以下命令,查看挂载点下的(de)内容:
ls /mnt/nfs
如果可以看到共享目录中的(de)文件和子目录,说明NFS共享已成功。
2. 在远程服务器上(shang)检查“/var/log/messages”文件,查找与NFS相关的日志信息,如果看到类似以下内容的日志,说明NFS服务正在正常运行:
“`
Mar 3 10:23:45 server kernel: NFS client version 3 called Mount(192.168.1.100://shared) from (192.168.1.200) at Mar 3 10:23:45 by user nobody on Linux version 3.10.0-514.el7.x86_64 (systemd-238) with TCP_NODELAY enabled (protocol in use PXE-RSP/MMU/HUD) using localtime(Crunchy) and nolock(vfs) options; protocol VFS_NOLOCK (tcp), Retry: yes (max=3), Timeout in isochronous mode set to 60 seconds (RPC_TIMEOUT=60). VFS error (device or resource busy), device or resource busy (192.168.1.100://shared) is not a directory or is empty. [kernel] IP table flush before namespace switch. [IPV4] NETLINK address family [genl]: autoconfig failed (-1): Checking for a default router now without sending any packets to the network! This might take a few minutes depending on your network setup! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unreachable (netlink)! [IPV4] Network is unReachablE(NETLINK): No route to host, disconnecting … done.[iproute2-default(7)]: REJECT xmit queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only; reject rcv queue full, statistics only


网站二维码
导航
电话
短信
咨询
地图
分享