NFS服务端部署
1、安装nfs 和 rpcbind
安装nfs-utils ,rpcbind:
yum -y install nfs-utils ,rpcbind
查看是否安装:
rpm -qa |grep nfs
rpm -qa |grep rpcbind
2、关闭防火墙:
关闭防火墙
systemctl stop firewalld.service
禁止防火墙开机自启动
systemctl disable firewalld.service
3、启动服务:一定要先启动rpc,然后启动nfs
nfs需要向rpc注册,rpc一旦重启,所以注册的文件都丢失,其他向注册的服务都需要重启
启动rpc服务:
systemctl start rpcbind.service
启动nfs服务:
systemctl start nfs.service
4、设置开机自启动
设置rpc自己自启动:
systemctl enable rpcbind.service
设置rpc自己自启动 :
systemctl enable nfs.service
5、查看rpc ,nfs状态
查看rpc状态:active
systemctl status rpcbind.service
查看nfs状态:active
systemctl status nfs.service
NFS服务端配置
1、在/etc/exports设置NFS服务共享文件夹的位置
vim /etc/exports:
/etc/exports追加:/share *(rw,sync,no_root_squash)
/share 共享的目录
* :任何人
rw :读写权限
sync:资料会先暂存于内存中,而非直接写入硬盘。
no_root_squash:当登录NFS主机使用共享目录的使用者是root时,其权限将被转换成为匿名使用者,通常它的UID与GID 都会变成nobody身份。
2、重启rpcbind 然后重启 nfs:
重启rpc服务:
systemctl restart rpcbind.service
重启nfs服务:
systemctl restart nfs.service
1、安装nfs 和 rpcbind
安装nfs-utils ,rpcbind:
yum -y install nfs-utils ,rpcbind
查看是否安装:
rpm -qa |grep nfs
rpm -qa |grep rpcbind
2、关闭防火墙:
关闭防火墙
systemctl stop firewalld.service
禁止防火墙开机自启动
systemctl disable firewalld.service
3.创NFS文件系统服务端目录(例:/opt/nfs),并赋予用户权限
mkdir /opt/nfs
chown nastors:storage /opt/nfs
chmod 777 /opt/nfs
4.编辑配置文件/etc/exports,加入以下语句:
/opt/nfs *(rw,sync,no_root_squash)
注:①/opt/nfs为服务器挂载目录
②IP:*处指定客户端IP,*表示所有IP
5.启动服务:一定要先启动rpc,然后启动nfs
nfs需要向rpc注册,rpc一旦重启,所以注册的文件都丢失,其他向注册的服务都需要重启
启动rpc服务:
systemctl start rpcbind.service
启动nfs服务:
systemctl start nfs.service
6、设置开机自启动
设置rpc自己自启动:
systemctl enable rpcbind.service
设置rpc自己自启动 :
systemctl enable nfs.service
7、查看rpc ,nfs状态
查看rpc状态:active
systemctl status rpcbind.service
查看nfs状态:active
systemctl status nfs.service
8.查看端口和服务
rpcinfo –p localhost 看到portmap,nfs,mountd进程都已经开启
9.查看nfs的设置
showmount -e localhost 查看exports文件
showmount -a localhost 查看nfs与主机连接情况
NFS客户端配置
1.安装nfs-utils查看挂载目录
yum -y install nfs-utils
在所有客户端挂载服务器192.168.20.128的/home/grid目录
查看192.168.20.128服务器可挂载的目录:
showmount -e 192.168.20.128
在客户端的根目录下建立nfs_share目录,注意不是/home/grid目录下,是根目录下 :
cd /
mkdir /nfs_share
进行挂载:
mount -t nfs 192.168.20.128:/home/grid /nfs_share
2、设置客户端开机时自动挂载192.168.20.128:/home/grid到本地的/nfs_share
在root用户下:
vim /etc/fstab
追加:192.168.20.128:/home/grid /nfs_share #开机时自动将/home/grid挂在到nfs_share