CentOS 7快速安装配置NFS服务

服务器   发布日期:2025年05月10日   浏览次数:188
Server IP ADD:192.168.153.138
Client IP ADD:192.168.153.140
NFS Server安装配置:
关闭selinux
vim /etc/selinux/config
#SELINUX=enforcing
#SELINUXTYPE=targeted
SELINUX=disabled     //新增部分
systemctl stop firewalld
systemctl disable firewalld
yum remove firewalls
yum install iptables-services
vi /etc/sysconfig/iptables
-A INPUT -p udp -s 192.168.153.140/ -j ACCEPT    //新增两条访问策略
-A INPUT -p tcp -s 192.168.153.140/ -j ACCEPT
:wq!
service start iptables
systemctl enable iptables
yum install nfs-utils -y //会连同rpcbind依赖包一起安装。
/tmp/nfs 192.168.153.140(rw,sync,fsid=,no_root_squash,no_all_squash,anonuid=,anongid=)
exportfs -r  //使配置生效
./tmp/nfs  为共享目录
2.192.168.153.  //可以为一个网段或一个IP或多个IP
.rw表示可读写,ro只读;
.sync表示同步模式,内存中数据时写入磁盘;async表示不同步,把内存中数据定期写入磁盘中。
.no_root_squash:root用户会对共享目录拥有至高的权限控制,就像是对本机的目录操作一样,不安全,不建议使用;root_squash:root用户对共享目录的权限不高,只有普通用户的权限,
.all_squash:不管使用NFS用户是谁,他的身份将会被限定成为一个指定的普通用户身份;
.anonuid/anongid:要和root_squash以及all_squash一同使用,同于指定使用NFS用户限定后的uid和gid,前提本机的/etc/passwd中存在这个uid和gid。
.fsid=0表示将/tmp/nfs整个目录包装成根目录
nfs开机启动服务
systemctl enable rpcbind
systemctl enable nfs-server
启动nfs服务
systemctl start rpcbind
systemctl start nfs-server
确认NFS服务器启动成功:
rpcinfo -p
查看service列中是否有nfs服务来确认NFS是否启动
showmount -e 192.168.153.138     //在nfs server操作
NFS Client安装配置
关闭selinux
vim /etc/selinux/config
#SELINUX=enforcing
#SELINUXTYPE=targeted
SELINUX=disabled     //新增部分
systemctl stop firewalld
systemctl disable firewalld
yum remove firewalls
yum install iptables-services
vi /etc/sysconfig/iptables
-A INPUT -p udp -s 192.168.153.138/ -j ACCEPT    //新增两条访问策略
-A INPUT -p tcp -s 192.168.153.138/ -j ACCEPT
:wq!
service start iptables
systemctl enable iptables
yum install nfs-utils -y //会连同rpcbind依赖包一起安装。
systemctl enable rpcbind
systemctl start rpcbind
mkdir /tmp/nfs
mount -t nfs 192.168.153.138:/tmp/nfs /tmp/nfs/
vim /etc/fstab       //mount永久生效,重启后mount不消失
192.168.153.138:/tmp/nfs  /tmp/nfs              nfs     nolock           
:wq!

 

以上就是CentOS 7快速安装配置NFS服务的详细内容,更多关于CentOS 7快速安装配置NFS服务的资料请关注九品源码其它相关文章!