Centos NFS 서비스 및 자동 마운트

8090 단어 NFS
NFS 서비스 및 자동 마운트
파일 공유 서버 개념, 네트워크 파일 시스템, 네트워크를 통해 서로 다른 시스템, 기계가 파일 공유 작업 원리를 실현하도록 한다. 여러 모듈이 공동으로 완성하고 포트가 무작위이며 RPC 에이전트를 통해 NFS 서비스 연결을 돕는다.
환경
서비스 포트: 192.168.1.111
[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

클라이언트: 192.168.1.107
[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

2. nfs 설치 설정 - 서버
설치 환경 지원
[root@localhost ~]# yum install nfs-utils -y

NFS 공유 디렉토리 생성
[root@localhost ~]# mkdir -p /data/nfsshare

공유 디렉토리에 파일 복사
[root@localhost ~]# cp /etc/fstab /data/nfsshare

프로필, exports 이 파일 이름 고정
[root@localhost ~]# vim  /etc/exports   
/data/nfsshare 192.168.1.107(ro,sync)         ,ro   ,rw   

주: 세그먼트 형식으로도 쓸 수 있습니다. 24를 추가하고 0.0.0.0을 쓰면 안 됩니다. 여러 줄을 쓸 수 있습니다. 다음과 같습니다./data/nfsshare 192.168.1.0/24(ro,sync)
데이터 내보내기
[root@localhost ~]# exportfs -r

서비스 재시작
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl restart nfs 

주: #chmod o+w/data/nfsshare 만약 클라이언트가 공유 디렉터리와 같은 것을 쓸 수 있도록 요구한다면 이 문장을 더해서selinux와 방화벽을 닫아야 한다(여기는 방화벽 설정을 하지 않고 바로 닫는다)
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/selinux/config 
SELINUX=disabled
[root@localhost ~]# systemctl stop firewalld

3. nfs 설치 설정 - 클라이언트
설치 환경 지원
[root@localhost ~]#yum install nfs-utils -y

서버 마운트 정보 보기
[root@localhost ~]# showmount -e 192.168.1.111
Export list for 192.168.1.111:
/data/nfsshare 192.168.1.0/24

로컬 마운트 디렉토리 만들기
[root@localhost ~]# mkdir -p /data/nfs

임시 마운트
[root@localhost ~]# mount 192.168.1.111:/data/nfsshare /data/nfs

mount -t nfs 192.168.1.111:/data/nfsshare/data/nfs도 이렇게 쓸 수 있습니다.
[root@localhost nfs]# ll /data/nfs
total 4
-rw-r--r--. 1 root root 541 May 17 11:01 fstab
-rw-r--r--. 1 root root   0 May 17 11:29 test

4. 클라이언트 전원 켜기 자동 마운트(fstab 프로필은 전원 켜기 자동 마운트)
전원 켜기 자동 마운트 분 ** "fstab 프로필"수동 전원 켜기 자동 마운트 및 "autofs"도구 자동 마운트 ** fstab 프로필 수동 전원 켜기 자동 마운트 **
[root@localhost ~]# vim /etc/fstab         
192.168.1.111:/data/nfsshare /data/nfs  nfs  defaults 0 0 

5. 클라이언트 전원 켜기 자동 마운트(autofs 도구 자동 마운트 실현)
autofs는 수호 프로세스로 자동으로 마운트되며 클라이언트는 autofo 도구를 통해 접근할 때 자동으로 마운트됩니다. 사용하지 않으면 5분 동안 자동으로 끊기고 마운트 해제됩니다.마운트 디렉터리를 숨기고 autofs를 설치할 수 있다는 장점이 있습니다
[root@localhost ~]# yum install autofs -y

autofs 시작
[root@localhost ~]# systemctl start autofs

#rpm - qc autofs autofs 관련 파일 보기
[root@localhost ~]# rpm -qc autofs       autofs    
/etc/auto.master			             
/etc/auto.misc				      、       
/etc/auto.net
/etc/auto.smb
/etc/autofs.conf			autofs    ,          ,  300 ,5  
/etc/autofs_ldap_auth.conf
/etc/sysconfig/autofs
/usr/lib/systemd/system/autofs.service

설정 시작, 순서대로 1,vim/etc/autofs.conf 구성 2, vim/etc/auto.master 정의 마운트 지점 및 마운트 지점 설정 파일
[root@localhost ~]# vim /etc/auto.master	 
/data/nfs  /etc/auto.nfs

3、vim/etc/auto.nfs 마운트 지점의 가상 디렉터리 정의
[root@localhost ~]# vim /etc/auto.nfs		           ,     ,         ,           
cd -fstype=nfs,rw,sync  192.168.1.111:/data/nfsshare
cd1 -fstype=nfs,ro,sync  192.168.1.111:/data/nfsshare 

이렇게 하면 cd/data/nfs 아래에 파일이 없습니다. cd cd를 사용하면 가상 디렉터리 cd에 들어갈 수 있습니다.cd에 접근할 때, 예를 들어 ls는 자동으로 마운트되며, 그 안의 내용은 마운트된 후의 내용 리셋 서비스입니다
[root@localhost ~]# systemctl restart autofs

자동 마운트 설정 전원 켜기 자동 시작
[root@localhost ~]# systemctl enable autofs
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.

테스트
[root@localhost ~]# 
[root@localhost ~]# cd /data/nfs
[root@localhost nfs]# ls           
[root@localhost nfs]# ll cd        cd   ,       ,          
total 4
-rw-r--r--. 1 root root 541 May 17 11:01 fstab
-rw-r--r--. 1 root root   0 May 17 11:29 test

-------------------------end

좋은 웹페이지 즐겨찾기