NFS部暑

来自linux中国网wiki
跳到导航 跳到搜索


这个是2019年刚刚写的 Nfs实现日志集中查看

info

NFS服务端 10.3.10.141 NFS client 10.3.10.142 10.3.10.143

NFS服务端

 yum install nfs-utils  rpcbind -y
 
systemctl enable rpcbind
systemctl enable nfs-server

systemctl start rpcbind
 systemctl start nfs-server
 systemctl start nfs-lock
systemctl start nfs-idmap


 创建需要共享的目录
 mkdir -p /home/lxtx/files/cailu/
chmod -R  777 /home/lxtx/files/cailu/  更改share文件夹及其子文件夹权限为77
 
 配置需要共享的目录到 /etc/exports下,xxx.xxx.xxx.xxx为需要共享的对象ip地址。
echo "/home/lxtx/files/cailu/ 10.3.10.*(rw,sync,no_root_squash)" >> /etc/exports
  
echo "/home/lxtx/files/cailu/ 192.168.11.*(rw,sync,no_root_squash)" >> /etc/exports
exportfs -a      #    使exports的修改生效

  
 检查共享目录是否设置正确
 showmount -e
Export list for centos7:
/home/lxtx/files/cailu 10.3.10.*


firewall-cmd --add-service=nfs --permanent --zone=public
 firewall-cmd --add-service=mountd --permanent --zone=public
firewall-cmd --add-service=rpc-bind --permanent --zone=public
 firewall-cmd --reload   

NFS client

yum -y install nfs-utils
 
apt-get install nfs-common
 
检查共享目录是否设置正确,xxx.xxx.xxx.xxx 为共享服务器地址(nfs master)

[root@nfs_client ~]# showmount -e 10.3.10.141
Export list for 10.3.10.141:
/home/lxtx/files/cailu 10.3.10.*

 
 mkdir /home/lxtx/files/cailu 
 chown  -R  lxtx:lxtx  /home/lxtx/files/cailu
 
#NFS server 的IP 
 mount 10.3.10.141:/home/lxtx/files/cailu  /home/lxtx/files/cailu 
 
 
客户端开机自动挂载nfs共享目录

vi /etc/fstab
10.3.10.141:/home/lxtx/files/cailu  /home/lxtx/files/cailu nfs  defaults 0 0

#Oct 2023 
请确保任意节点都可成功挂载该 NFS 服务,可通过下面的命令测试:

mkdir /tmp/testnfs \
&& mount -t nfs 192.168.10.103:/data/k8s /tmp/testnfs \
&& echo "hello nfs" >> /tmp/testnfs/test.txt \
&& cat /tmp/testnfs/test.txt


see also

CentOS7搭建NFS服务

Debian Linux安装NFS

centos7配置nfs网络文件共享


Linux NFS服务器的安装与配置


Lvs+keepalived+httpd+NFS搭建高可用

NFS+sersync+Keepalived高可用方案