配置nfs服务

服务端以只读方式配置共享目录是/nfs1 ,且只允许172.25.0.0/24域中主机访问,客户端实现自动挂载,挂载目录为/mnt/nfs1.

   94  yum -y install nfs-utils-*    这个包包括基本nfs命令和监控程序。
   95  mkdir /nfs1      
   96  vim /etc/exports    编辑配置文件

/nfs1   172.25.0.0/24(ro,sync)    


   97  systemctl enable rpcbind    在启动nfs服务之前,会先启用rpcbind服务程序。
   98  systemctl restart rpcbind
   99  systemctl enable nfs-server   将nfs-server服务开机自动启动
  100  systemctl restart  nfs-server
  101  showmount -e 172.25.0.11    测试是否能看到
  102  firewall-cmd --permanent --add-service=nfs
  103  firewall-cmd --reload

客户端配置

   19  mkdir /mnt/nfs1
   20  vim /etc/fstab

172.25.0.11:/nfs1 /mnt/nfs1 nfs defaults 0 0


   21  mount -a

在服务器上配置安全的nfs服务,以读写的模式共享/nfs2,仅允许172.25.0.0/24的主机访问,且/nfs2/private的目录所有者是haha,haha能写入文件到/mnt/nfs2/private中。

  120  yum -y install nfs-utils-*
 
  122  mkdir /nfs2            这个目录默认其他人只可读
  123  mkdir /nfs2/private
  124  chown haha /nfs2/private

  124  vim /etc/sysconfig/nfs

# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
RPCNFSDARGS="-V 4.2"                                                       修改 nfs 配置文件,强制使用 V4.2


  125  wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/desktop0.keytab     下载安全证书。必须先有证书服务才能起来
  126  vim /etc/exports

/nfs2   172.25.0.0/24(rw,sync,sec=krb5p)                        以读写方式共享/nfs2。。。 
  127  systemctl enable nfs-secure-server      使这个服务端的证书生效
  128  systemctl restart nfs-secure-server
 
  130  systemctl restart nfs-server.service       起来这个服务是为了读取/etc/exports中的配置文件
 
  132  showmount -e 172.25.0.11          测试是否出现共享目录。

客户端配置

   34  mkdir /mnt/nfs2
   35  wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/desktop0.keytab    下载客户端的安全证书
   36  systemctl enable nfs-secure.service    启动这个安全选项使客户端的证书生效
   37  systemctl restart nfs-secure.service
   38  vim /etc/fstab

172.25.0.11:/nfs2 /mnt/nfs2 nfs defaults,v4.2,sec=krb5p 0 0    


   39  mount -a

原文地址:https://www.cnblogs.com/xnb123/p/8006230.html