一、CentOS设置
1. 更换阿里源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoyum makecache
2. 安装网络工具
yum install net-tools wget -y
3. 使用阿里NTP服务
yum install chrony -y
sed -i "/server/d" /etc/chrony.conf
vi /etc/chrony.conf 增加 server ntp.aliyun.com iburst
systemctl restart chronyd
chronyc tracking
4. 设置主机名
hostnamectl set-hostname nfs
5. 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
二、安装NFS
1. 安装类库
yum install -y nfs-utils
2. 设置配置
vi /etc/exports
/home/nfs_root/ *(insecure,rw,sync,no_root_squash)
3. 启动NFS服务
mkdir /home/nfs_root
systemctl enable rpcbind
systemctl enable nfs-server
systemctl start rpcbind
systemctl start nfs-server
exportfs -r
4. 检查是否生效
exportfs
以上指令应该输出/home/nfs_root /home/nfs_root
三、客户端测试NFS
1. 安装软件包
yum install -y nfs-utils
2. 检查NFS服务
showmount -e 192.168.1.229
执行以上命令如果成功则输出
Export list for 192.168.1.229:
/root/nfs_root *
3. 挂载NFS
mkdir /root/nfsmount
mount -t nfs 192.168.1.229:/home/nfs_root /root/nfsmount
echo "hello nfs server" > /root/nfsmount/test.txt
4. NFS服务器执行
cat /root/nfs_root/test.txt
