Centos7는 NFS 파일 공유 스토리지를 설정
NFS 개요;
개요 : NFS는 원래 SUN에 의해 개발 된 TCP / IP 전송을 기반으로 네트워크 파일 시스템 프로토콜입니다. NFS 프로토콜에 의해, 클라이언트는 로컬 액세스와 같은 디렉토리에 원격 서버의 공유 리소스에 액세스 할 수 있습니다. NFS는 우수한지지 장치 및 NAS 저장 영역 네트워크와 같은 예이다. LVS는 또한 선택의 스토리지를 공유됩니다.
환경 : Centos7.6 서버 IP : 192.168.4.84 클라이언트 IP : 192.168.4.83
서버는 NFS 유틸, rcpbind 패키지를 설치;
[ root@nfs ~ ] # yum - y install nfs- utils rpcbind
처음부터 설정 부팅;
[ root@nfs ~ ] # for i in rpcbind nfs; do systemctl enable $i; done
공유 파일 디렉토리를 작성;
[ root@nfs ~ ] # mkdir / opt/ docx
공유 디렉토리 권한;
[ root@nfs ~ ] # chmod 777 / opt/ docx/
권한을 부여, 구성 파일을 수정;
[ root@nfs ~ ] # vi / etc/ exports
/ opt/ docx 192.168 .4 . *( rw, sync, no_root_squash)
#注解:
#文件格式:目录 主机(权限)
#权限:rw读写 ro只读 sync同步写入 no_root_squash表示客户机以root身份访问时,赋予其本地root权限,默认是root_squash,表示以nfsnobody用户降权使用
서비스 시작
[ root@nfs ~ ] # systemctl start rpcbind
[ root@nfs ~ ] # systemctl start nfs
보기 포트
[ root@nfs ~ ] # netstat - utpln | grep rpc
tcp 0 0 0.0 .0 .0 : 20048 0.0 .0 .0 : * LISTEN 19822 / rpc. mountd
tcp 0 0 0.0 .0 .0 : 38173 0.0 .0 .0 : * LISTEN 19794 / rpc. statd
tcp6 0 0 : : : 20048 : : : * LISTEN 19822 / rpc. mountd
tcp6 0 0 : : : 52574 : : : * LISTEN 19794 / rpc. statd
udp 0 0 0.0 .0 .0 : 54577 0.0 .0 .0 : * 19794 / rpc. statd
udp 0 0 0.0 .0 .0 : 20048 0.0 .0 .0 : * 19822 / rpc. mountd
udp 0 0 0.0 .0 .0 : 869 0.0 .0 .0 : * 19774 / rpcbind
udp 0 0 127.0 .0 .1 : 890 0.0 .0 .0 : * 19794 / rpc. statd
udp6 0 0 : : : 20048 : : : * 19822 / rpc. mountd
udp6 0 0 : : : 43494 : : : * 19794 / rpc. statd
udp6 0 0 : : : 869 : : : * 19774 / rpcbind
기본 공유 디렉토리보기
[ root@nfs ~ ] # showmount - e 192.168 .4 .84
Export list for 192.168 .4 .84 :
/ opt/ docx 192.168 .4 .0 / 24
클라이언트 설치 NFS 클라이언트 프로그램;
[root@client ~]# yum -y install nfs-utils ##安装nfs程序
[root@client ~]# showmount -e 192.168.4.84
Export list for 192.168.4.84:
/opt/docx 192.168.4.*
[root@client ~]# echo 3 >/proc/sys/vm/drop_caches ##清除缓存
[root@client ~]# mkdir -p /var/docx ##创建挂载目录
[root@client ~]# vi /etc/fstab ##编写fstab永久挂载
192.168.4.84:/opt/docx /var/docx nfs defaults,_netdev 0 0 ##在末行添加
#注:_netdev表示设备需要网络
[root@client ~]# mount -a ##挂载
[root@client ~]# mount |tail -1
192.168.4.84:/opt/docx on /var/docx type nfs4 (rw,relatime,vers=4.1,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.4.83,local_lock=none,addr=192.168.4.84,_netdev) ##查看是否挂载
서버 저장 디렉토리 성공적으로 저장된 문서 여부를 확인합니다;
클라이언트가 파일을 생성
[ root@client ~ ] # cd / var/ docx/
[ root@client docx] # touch aaa. txt
[ root@client docx] # touch aaa. file
[ root@client docx] # touch aaa. docx
[ root@client docx] # touch aaa. pdf
보기 공유 디렉토리 서버
[ root@nfs ~ ] # ls / opt/ docx/
aaa. docx aaa. file aaa. pdf aaaa. txt
NFS는 파일 공유 성공을 구축