linux centos NFS 服务器配置 - com:/data/gbxc /mnt nfs rw,soft 0 0
1、环境介绍 操作系统:centos 7.9 cpu:4核心 内存:8G 磁盘:100G
2、更改主机名和域名解析 3、关闭selinux
4、安装nfs服务
yum install -y nfs-utils
5、安装rpc服务(如果提示安装了 直接跳过)
yum install -y rpcbind
6、启动rpcbind
systemctl start rpcbind
systemctl enable rpcbind
7、启动nfs
systemctl start nfs-server
systemctl enable nfs-server
8、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld 拼多多帮助力入口
9、创建数据目录并更改权限
mkdir -p /data/gbxc
chmod 777 /data/gbxc/
10、配置nfs配置文件
vi /etc/exports
添加如下
/data/gbxc 10.99.24.201(rw,sync,root_squash)
#exports配置常用参数 #ro 只读 #rw 读写 #root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的匿名用户 #no_root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员 #all_squash 无论NFS客户端使用什么账户访问,均映射为NFS服务器的匿名用户 #sync 同时将数据写入到内存与硬盘中,保证不丢失数据 #async 优先将数据保存到内存,然后再写入硬盘;这样效率更高,但可能会丢失数据
重启服务器生效
systemctl restart nfs-server
11、客户端挂载 也安装这个包 ,包含showmount
yum install -y nfs-utils
查看
showmount -e nfs.wtown.com
挂载
mount -t nfs nfs.wtown.com:/data/gbxc /mnt/
12、编写fstab文件,开机自动挂载(可选)
nfs.wtown.com:/data/gbxc /mnt nfs rw,soft 0 0
编写完 mount -a一下,不报错就可以,如果报错了,还重启了,就无法进入系统了,需要进入单用户模式进行更改
mount -a