NFS 简单配置
欢迎来到 来到大浪涛天的博客 !
NFS 简单配置
1. 环境准备
1.1 防火墙关闭
/etc/init.d/iptables stop
1.2 selinux关闭
setenforce 0
1.3 确认本机ip
[root@server ~]# ifconfig eth1 |awk -F '[ :]+' 'NR==2 {print $4}'
192.168.50.3
2. NFS server 端和client安装软件包
[root@lamp02 ~]# yum install nfs-utils rpcbind -y
3. NFS server端配置文件,及创建共享目录,共享目录授权nfsnobody。
[root@server ~]#mkdir /aaa
[root@server ~]#chown 65534:65534 /aaa
[root@server ~]# cat /etc/exports
/aaa 192.168.50.0/24(rw,sync,all_squash)
[root@server ~]# exportfs
/aaa 192.168.50.0/24
[root@server ~]# showmount -e localhost
Export list for localhost:
/aaa 192.168.50.0/24
[root@server ~]# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
注意,一般的NFS服务端会要求所有用户都对NFS存储有读写的权限,因此要加上all_squash参数
4. NFS server 启动nfs服务和rpcbind服务,客户端启动rpc服务
/etc/init.d/rpcbind start
/etc/init.d/nfs start
注意必须先启动rpcbind服务,再启动nfs服务
5. 在测试机上测试共享是否成功
[root@lamp01 data]# mount -t nfs 192.168.50.3:/aaa /nfs-server/data
[root@lamp01 data]# touch abc
[root@lamp01 data]# ls -l abc
-rw-r--r--. 1 nfsnobody nfsnobody 0 Sep 6 17:27 abc
6. 将上述加入开机启动
服务端
[root@server ~]# echo "/etc/init.d/prcbind restart" >>/etc/rc.local
[root@server ~]# echo "/etc/init.d/nfs restart" >>/etc/rc.local
客户端
[root@backup ~]# echo "/etc/init.d/rpcbind restart " >>/etc/rc.local
[root@backup ~]# echo "mount -t nfs 192.168.50.3:/aaa /nfs-server/data" >>/etc/rc.local