인디노트

Linux NFS 파일 공유 본문

개발 플랫폼 및 언어

Linux NFS 파일 공유

인디개발자 2018. 3. 10. 10:37

리눅스 nfs 파일 공유 


레포지토리 연결 (옵션)

# yum install epel-release -y



설치

# yum -y install rpcbind nfs-utils nfs-utils-lib



접속을 허용할 PC 입력

# vi /etc/exports


# 예제 /home/starkapin 192.168.10.1(rw, sync)

/공유폴더 허용IP(rw, sync) 허용IP(rw, sync, no_root_squash, all_squash)

(rw,no_root_squash) <= Read Write 설정

(ro,all_squash) <= Read Only 설정



---------------------------------------------------------------------

참고 사항

-------

ro : (Default) Read Only Mode

rw : Read Write Mode

sync : (Default) 동기 - 안전함

async : 비동기 - 속도빠름

root_squash : (Default) Client 의 root 를 익명 사용자(nobody)로 매핑

no_root_squash : Client 의 root 를 Server 의 root 로 매핑

all_squash : 모든 사용자를 익명 사용자(nobody) 로 매핑

secure : (Default) 마운트 요펑시 1024 포트 이하로 할당 허용

insecure : 마운트 요청시 1024 포트 이상도 할당 허용



서버쪽

-----

systemctl restart rpcbind

systemctl enable rpcbind

systemctl restart nfs-server

systemctl enable nfs-server



클라이언트쪽

---------

systemctl restart rpcbind

systemctl enable rpcbind


mkdir -p /data

mount -t nfs 192.168.0.100:/data /data   <= 일회성 마운트


vi /etc/fstab

192.168.0.100:/data /data nfs defaults 0 0    <= 부팅시 마운트

---------------------------------------------------------------------





NFS 서버 실행

# service nfs start




부팅시 자동시작

# chkconfig nfs on

# chkconfig --list | grep nfs




서비스 확인

# exportfs -v

/home/starkapin 192.168.10.1(rw,wdelay,root_squash,no_subtree_check)



다시 읽어들인다

# exportfs -a




NSF 설정을 확인

# showmount -e






방화벽 설정

TCP/UDP 111 - ROC 4.0 portmapper

TCP/UDP 2049 - NFSD (nfs server)





# vi /etc/sysconfig/nfs

LOCKD_TCPPORT=32803

LOCKD_UDPPORT=32769

MOUNTD_PORT=892

RQUOTAD_PORT=875

STATD_PORT=662

STATD_OUTGOING_PORT=2020



주석을 해제 한 후 서비스를 재시작

# service rpcbind restart

# service nfs restart




방화벽에 허용할 목록을 추가 (TCP 111, TCP 2049 만 열어줘도 되는것 같다.)

-A INPUT -s 0.0.0.0/0 -m state --state NEW -p udp --dport 111 -j ACCEPT

-A INPUT -s 0.0.0.0/0 -m state --state NEW -p tcp --dport 111 -j ACCEPT

-A INPUT -s 0.0.0.0/0 -m state --state NEW -p tcp --dport 2049 -j ACCEPT

-A INPUT -s 0.0.0.0/0  -m state --state NEW -p tcp --dport 32803 -j ACCEPT

-A INPUT -s 0.0.0.0/0  -m state --state NEW -p udp --dport 32769 -j ACCEPT

-A INPUT -s 0.0.0.0/0  -m state --state NEW -p tcp --dport 892 -j ACCEPT

-A INPUT -s 0.0.0.0/0  -m state --state NEW -p udp --dport 892 -j ACCEPT

-A INPUT -s 0.0.0.0/0  -m state --state NEW -p tcp --dport 875 -j ACCEPT

-A INPUT -s 0.0.0.0/0  -m state --state NEW -p udp --dport 875 -j ACCEPT

-A INPUT -s 0.0.0.0/0  -m state --state NEW -p tcp --dport 662 -j ACCEPT

-A INPUT -s 0.0.0.0/0 -m state --state NEW -p udp --dport 662 -j ACCEPT








클라이언트


레파지토리 연결

# yum install epel-release -y


# yum install nfs-utils nfs-utils-lib nfs-utils-lib-devel nfs4-acl-tools libgssglue-devel


# showmount -e 서버IP

Export list for 168.102.10.1:

/transcoding 168.102.10.2




마운트

# mount -t nfs4 168.102.10.2:/transconding /home/starkapin/transcoding




마운트 해제

# umount /home/starkapin/transcoding




재부팅해서도 자동 마운트 시키기

# vi /etc/fstab

서버IP:/transcoding /home/starkapin/transcoding nfs defaults 0 0















반응형
Comments