@@ NFS install / NFS 설치

OS 환경

Linux version 2.6.32-642.el6.x86_64 (mockbuild@worker1.bsys.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) ) #1 SMP Tue May 10 17:27:01 UTC 2016

 

#### nfs-server install ####

## nfs install // nfs-server install

$ yum install nfs*

 

## confirm

$ rpm -qa nfs*

nfs-utils-1.2.3-78.el6_10.2.x86_64

nfs-utils-lib-devel-1.1.5-13.el6.x86_64

nfs-utils-lib-1.1.5-13.el6.x86_64

 

## nfs-client 허용 설정

$ vi /etc/exports

/nfs/data/  192.168.137.42(rw,sync,no_root_squash) 192.168.137.43(ro)

/nfs/data/   192.168.0.*(rw,sync)

 

## exportfs Reference

ro (읽기 전용)

root_squash (클라이언트의 root를 서버의 nobody 권한으로 설정)

no_root_squash (클라이언트의 root를 서버의 root 권한으로 설정)

all_squash (root를 제외한 일반사용자의 ID를 nobody 권한으로 설정)

no_all_squash (root를 제외한 일반사용자의 ID를 서버의 사용자ID 권한으로 설정)

insecure  (인증되지 않은 엑세스도 가능)

sync (클라이언트가 파일쓰기 완료후 디스크 동기화)

 

## 적용 & 확인

$ exportfs -a

$ exportfs

 

## rpcbind 설치

$ yum install rpcbind

$ rpm -qa | grep -i rpcbind

rpcbind-0.2.0-16.el6.x86_64

## 오래된 kernel 버전7은 portmap 설치 ## yum install portmap

 

시작 순서 중요

$ /etc/init.d/rpcbind start

$ /etc/init.d/nfs start

 

$ netstat -nlpt | grep -i rpcbind

tcp    0 0.0.0.0:111             0.0.0.0:*               LISTEN  1404/rpcbind

tcp    0 :::111                  :::*                    LISTEN  1404/rpcbind



## nfs-client

$ yum install nfs*

 

## 연결할 수 있는 지 확인

$ showmount -e 192.168.137.41

$ mount -t nfs 192.168.137.41:/nfs/data/ /nfs/data/

 

## reference

$ showmount -e 192.168.137.41

clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)

→ 방화벽 확인 해볼 것 / nfs port 고정 방법 찾아보기 

 

$ showmount -e 192.168.137.41

Export list for 192.168.137.41:

/nfs/data 192.168.137.43,192.168.137.42

→ 정상

 

$ mount -t nfs 192.168.137.41:/nfs/data/ /nfs/data/ 

$ mount -t nfs -o nolock 192.168.137.41:/nfs/data/ /nfs/data/

## ​-o nolock : 2개 이상의 클라이언트에서 동일한 파일의 엑세스할때, 잠금설정을 해제



$ vi /etc/fstab

192.168.137.41:/nfs/data/ /nfs/data/ nfs defaults 0.0 

## nfs계속 연결시도

 

192.168.137.41:/nfs/data/ /nfs/data/ nfs timeo=25,intr 0.0

## 25초 동안만 시도하고 없을경우 시도를 멈춤

 

## /etc/fstab /  NFS 마운트 옵션

rsize : NFS서버로부터 읽어 들이는 바이트수 지정 기본값 1024byte

wsize : NFS서버에 기록할 때 사용하는 바이트수 기본 지정값 1024byte

timeo : 클라이언트에서 타임아웃이 발생되고 나서, 다시 재전송 요구를 보낼때 시간

retrans : 재전송 횟수 지정

port : NFS서버에 연결시 사용하는 포트번호 지정

fg : NFS서버에 타임아웃이 발생되면 즉각 접속 중지

intr : 인터럽트 허용

hard : 타임아웃 발생시 "server not recording" 에러메시지 표시후 계속 재시도

soft : 타임아웃 발생시 I/O 에러 표시

 

확인

$ df -h 등 테스트 진행

두 서버가 공유된 모습









## URL

## 튜닝 관련

https://m.blog.naver.com/PostView.nhn?blogId=kmk1030&logNo=220992452346&proxyReferer=https:%2F%2Fwww.google.com%2F

##IBM 제공

https://www.ibm.com/support/knowledgecenter/ko/ssw_aix_71/performance/nfsstat_c_command.html



## 쓸만한 명령어

 

# nfs-client

$ nfsstat -m

/nfs/data from 192.168.137.41:/nfs/data

 Flags: rw,relatime,vers=4,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.137.42,minorversion=0,local_lock=none,addr=192.168.137.41

 

$ rpcinfo




# nfs-server

$ nfsstat  -r

Server rpc stats:

calls  badcalls   badclnt badauth xdrcall

176    3      0      3      0

 

Client rpc stats:

calls  retrans authrefrsh

2      3      2

 

$ rpcinfo















192.168.137.41 서버와 192.168.137.42 서버의 공유 디렉토리 설정 된 모습

192.168.137.41 / master-server1

192.168.137.42 / slave-server1

## 하나의 디렉토리를 공유하여 사용하기 때문에 아래와 같이 master 서버에서 파일 삭제하면 slave 서버도 함께 삭제가 된다. 

파일 추가도 동일하게 생성이 되며, 



+ Recent posts