CentOS7.4设置NFS

Published by davidliu on

说明:操作系统版本不同,设置步骤可能有所差异,文档仅供参考。

环境:

ROLEIPOS
NFS server 192.168.188.199最小化安装RHEL7.4
NFS client192.168.188.207最小化安装RHEL7.4

步骤:

一、NFS服务器端设置(192.168.188.199)

1.1安装nfs-utils:

yum install nfs-utils

1.2创建NFS共享目录:

mkdir /var/nfsshare

1.3设置NFS共享目录权限:

chmod -R 755 /var/nfsshare
chown nfsnobody:nfsnobody /var/nfsshare

1.4设置并启动nfs服务:

systemctl enable nfs-server

systemctl start nfs-server

1.5NFS共享配置:

vi /etc/exports,添加如下配置:

/var/nfsshare    192.168.188.207(rw,all_squash)

设置完毕保存,运行exportfs -rv重新加载配置。

1.6防火墙设置:

firewall-cmd –permanent –zone=public –add-service=nfs

firewall-cmd –reload

至此NFS服务器设置完毕。

二、NFS客户端设置( 192.168.188.207)

2.1安装nfs-utils:

yum install nfs-utils

2.2创建NFS目录挂载点:

mkdir -p /mnt/nfs/var/nfsshare

2.3挂载NFS目录:

mount -t nfs 192.168.188.199:/var/nfsshare /mnt/nfs/var/nfsshare/

2.4检查并测试:

df -h

touch /mnt/nfs/var/nfsshare/test_nfs

三、客户端自动挂载NFS目录

可编辑fstab实现自动挂载:

vi /etc/fstab,添加如下配置:

192.168.188.199:/var/nfsshare    /mnt/nfs/var/nfsshare   nfs defaults 0 0

设置完毕保存即可。

附录1:服务器端常用命令

1.Show the NFS server’s export list:

# showmount -e 192.168.188.199

Export list for 192.168.188.199:

/var/nfsshare 192.168.188.207

2.Show current export list and options:

# exportfs -v

/var/nfsshare 192.168.188.207(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,all_squash)

3.停止共享:exportfs -av -u

重新共享:exportfs -av或exportfs -rv

附录2:NFS参考文档

1.https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-nfs

2.https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/nfs-serverconfig

3.http://linux-nfs.org/wiki/index.php/Main_Page

Categories: Uncategorized

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *