当前位置:首页 > 行业动态 > 正文

centosnfs配置

CentOS NFS(网络文件系统)是一种在分布式计算环境中实现文件共享的协议,通过使用NFS,可以在不同的计算机之间共享文件和目录,从而实现数据和资源的高效利用,本文将介绍如何在CentOS 7上安装和配置NFS服务。

一、安装NFS服务

1. 确保系统已经更新到最新版本,在终端中输入以下命令:

sudo yum update

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

sudo yum install nfs-utils

3. 启动并设置NFS服务开机自启,在终端中输入以下命令:

sudo systemctl start nfs-server
sudo systemctl enable nfs-server

4. 查看NFS服务状态,在终端中输入以下命令:

sudo systemctl status nfs-server

二、配置NFS共享目录

1. 创建一个用于共享的目录,创建一个名为“/shared”的目录:

sudo mkdir /shared

2. 设置该目录的权限,以便其他用户可以访问和修改,设置为所有用户可读写:

sudo chmod 777 /shared

3. 在客户端计算机上创建一个挂载点,用于访问共享目录,创建一个名为“/mnt/nfs”的目录:

sudo mkdir /mnt/nfs

4. 将远程服务器上的共享目录挂载到客户端计算机上,假设远程服务器的IP地址为“192.168.1.100”,则执行以下命令:

sudo mount -t nfs 192.168.1.100:/shared /mnt/nfs

5. 若要使挂载在系统启动时自动生效,需要编辑“/etc/fstab”文件,备份文件:

sudo cp /etc/fstab /etc/fstab.bak

使用文本编辑器打开“/etc/fstab”文件,例如使用“vi”编辑器:

sudo vi /etc/fstab

在文件末尾添加以下行,其中“192.168.1.100”是远程服务器的IP地址,“/shared”是共享目录的路径:“192.168.1.100:/shared /mnt/nfs nfs defaults 0 0”

保存并关闭文件,执行以下命令使更改生效:

sudo mount -a

三、验证NFS共享是否成功

1. 在客户端计算机上运行以下命令,查看挂载点下的内容:

ls /mnt/nfs

如果可以看到共享目录中的文件和子目录,说明NFS共享已成功。

2. 在远程服务器上检查“/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

0