2011. 11. 28. 19:31 Log/Linux

NFS 서비스


NFS (Network File System)

- unix 또는 리눅스 host 간의 파일시스템 및 디렉토리 공유.
단. 파일은 공유 대상이 아니다. 공유대상은 파일시스템의
마운트 포인터이거나 단순한 디렉토리이다.

서버에서 공유자원을 걸어두면 nfs 클라이언트가 공유자원에
주어진 권한을 가지고 접근할 수 있다.

nfs 서비스 연결 과정

1. client 는 mount 가 mount 데몬의 포트 넘버를 알려달라고
portmap 데몬(111번 포트사용)에게 요청한다.
(rpc.mountd 는 동적포트를 사용하는 서비스이므로 포트넘버가 고정되어 있지 않고
올라올때 마다 바뀔수 있다)

- 대부분의 서비스는 미리정해진 정적포트를 사용하지만 mount 데몬같은 일부 서비스는
동적포트를 사용한다.
- 동적포트를 사용하는 서비스는 services 파일에 등록되어 있지 않다.
- 그래서 클라이언트는 동적포트를 사용하는 서비스에 접속하기위해서는 포트 넘버를
먼저 알수 있어야 하며 그래서 모든 동적 포트를 사용하는 서비스에 접속하는 클라이언트는
portmap 데몬에 먼저 접속하게 된다.

2. 서버측에서는 portmap 데몬이 mount데몬(rpc.mountd)의 포트넘버를 확인해서 알려준다.

3. client 는 mount 가 서버측에서 알려준 port 번호로 다시 접속을 시도한다.

4. 서버측의 mount 데몬은 client 가 mount 를 할 수 있도록 허용받은 주소인지를 확인하고
허용받은 주소라면 공유자원을 마운트 되게 한다. 그렇지 않으면 mount 를 거부한다.

5. 클라이언트는 마운트 한 서버측 자원을 읽기 또는 읽기/쓰기 권한으로 접근하여 파일을
읽거나 만들 수 있다.


nfs 서버 설정

nfs 서버는 standalone 방식으로 구동되며 /etc/init.d/nfs 스크립트 파일을 실행하면 된다.


- 설정파일은 /etc/exports 파일이며 설정 방법은 단순하다.

[root@star init.d]# cat /etc/exports
/share 192.168.37.10 => /share 자원을 마운트 할수 있는 클라이언트는 192.168.37.10 만 가능하다.
/share2 192.168.37.10(rw,sync) => 괄호안에 있는 것은 권한과 옵션이다. rw - 읽기쓰기권한.
sync 는 클라언트와 동기화 하기 위한 옵션. 디폴트값이다.
/share3 192.168.37.0/255.255.255.0(rw)
/share4 192.168.37.10(rw,no_root_squash) /share4 디렉토리는 192.168.37.10 에서 읽기 쓰기권한으로
마운트 할수 있으며 클라이언트의 root 가 공유자원에 접근시 root 권한을 가지고 접근할 수 있다.
디폴트 옵션은 root_squash 로서 root 가 공유자원에 접근시 nfsnobody 권한으로 접근하게 된다.

공유자원 확인(서버측에서)
[root@star init.d]# showmount -e
Export list for star:
/share3 192.168.37.0/255.255.255.0
/share 192.168.37.10
/share4 192.168.37.10
/share2 192.168.37.10
[root@star init.d]#

공유자원사용(클라이언트측에서)

mount -t nfs 서버ip(또는 도메인이나 host명):/share /mnt/nfs1

이렇게 mount 해서 사용하면 된다.

리부팅후에도 계속 공유자원을 사용하려면 /etc/fstab 파일에

server1:/share /mnt/nfs1 nfs defaults 0 0

<= 맨 끝에는 0 0 으로 한다. 이것은 nfs 자원은 자신의 것이 아니므로
부팅시 파일시스템 체크를 할 필요가 없기때문이다.


그리고 사용하지 않으려면 간단히 마운트 해제 하면 된다.

umount /mnt/nfs1

[root@star init.d]

===========================================
추가사항

sync : Reply to requests only after the changes have been committed to stable storage
nfs 마운트 포인터에 파일생성시 파일생성을 동기화 한후에 다음 요청을 받아들이게 한다.

async : This option allows the NFS server to violate the NFS protocol and reply to requests before any
changes made by that request have been committed to stable storage (e.g. disc drive).
Using this option might improve performance with version 2 only, but at the cost that an unclean
server restart (i.e. a crash) can cause data to be lost or corrupted.

nfs 마운트 포인터에 파일생성시 파일생성이 동기화 되기전에도 다음 요청을 받아들인다.
이럴경우 데이터 기록에 대한 안정성이 떨어진다.
그리고 nfs 서버 버전2일때만 성능향상을 기대할 수 있다.
그러므로 nfs 서버버전이 2 버전이 아니라면 이 옵션을 사용할 이유가 없다.

*. 현재 centos5.x 버전이라면 디폴트 nfs 서버버전은 3 버전이다.


all_squash : nfs 서버의 공유자원에 접근하는 모든 nfs 클라이언트 계정을 anonymous user 로 취급한다.
anonuid / anongid : anonymous 의 계정이나 그룹을 특정 uid 권한 또는 특정 gid 권한을 가지게 한다.

공유자원 설정예제.
# sample /etc/exports file
/ master(rw) trusty(rw,no_root_squash)
/projects proj*.local.domain(rw)
/usr *.local.domain(ro) @trusted(rw)
/home/joe pc001(rw,all_squash,anonuid=150,anongid=100)
/pub (ro,insecure,all_squash)

secure / insecure 옵션

secure This option requires that requests originate on an internet port less than IPPORT_RESERVED (1024). This
option is on by default. To turn it off, specify insecure.


1024 번 이하 포트까지는 well-known port 이고 특별한 목적으로 예약되어 있다.
secure는 이 포트들을 사용하고 1024 이상의 포트를 사용한 연결을 허용하지 않는다.
default 옵션은 secure 이다.

no_wdelay
This option has no effect if async is also set. The NFS server will normally delay committing a write
request to disc slightly if it suspects that another related write request may be in progress or may arrive
soon. This allows multiple write requests to be committed to disc with the one operation which can improve
performance. If an NFS server received mainly small unrelated requests, this behaviour could actually reduce
performance, so no_wdelay is available to turn it off. The default can be explicitly requested with the wde-
lay option.

이 옵션은 async 옵션과 같이 사용할 수 없다.
NFS 서버는 쓰기 요청에 대해 일반적으로 작은 크기의 데이터가 들어오면 그것을 모아두었다가
한번에 기록을 하는것이 성능상 유리할 것이다. nfs 는 실제로 디스크에 데이터를 쓸때까지 잠시
지연시간을 두기도 하는데 no_wdelay 옵션은 데이터가 오면 즉시 기록하는 방식이다.

*. 공유자원 정보 갱신 및 확인
exportfs(8) exportfs(8)

NAME
exportfs - maintain list of NFS exported file systems

SYNOPSIS
/usr/sbin/exportfs [-avi] [-o options,..] [client:/path ..]
/usr/sbin/exportfs -r [-v]
/usr/sbin/exportfs [-av] -u [client:/path ..]
/usr/sbin/exportfs [-v]
/usr/sbin/exportfs -f

/etc/exportfs 내용을 수정한 경우
nfs 서비스 재시작 하지 않고도 exportfs 명령으로 수정한 내용을
바로 적용할 수 있다.
-r Reexport all directories. It synchronizes /var/lib/nfs/xtab with /etc/exports. It
removes entries in /var/lib/nfs/xtab which are deleted from /etc/exports, and remove any
entries from the kernel export table which are no longer valid.

서버의 공유자원 정보는 showmount 또는 exportfs 명령어로 확인할 수 있다.
[root@centos100 ~]# showmount -e server
Export list for server:
/var/share 192.168.203.100/255.255.255.0

[root@centos1 ~]# exportfs
/var/share 192.168.203.100/255.255.255.0
[root@centos1 ~]# exportfs -v
/var/share 192.168.203.100/255.255.255.0(ro,wdelay,root_squash,no_subtree_check,anonuid=65534,anongid=65534)
[root@centos1 ~]#

공유자원을 해제 하고 싶을때는
exportfs -u 옵션을 사용하면 된다.
-u Unexport one or more directories.

[root@centos1 ~]# showmount -d [server] ; 클라이언트에 의해 마운트되어 있는 디렉토리만 출력해준다.
Directories on centos1:
/var/share2
-d or --directories
List only the directories mounted by some client.

'Log > Linux' 카테고리의 다른 글

apache / php / mysql 설치 및 연동  (0) 2011.11.28
fedora9 dns 서버 설정 테스트 내용.  (0) 2011.11.28
dns 설정 실습  (0) 2011.11.28
DNS - Secondary(Slave) 구성  (0) 2011.11.28
DNS - Primary DNS 설정 및 테스트  (0) 2011.11.28
Posted by logwatch

2011. 11. 28. 19:31 Log/Linux

dns 설정 실습

*. 설정하기전에 잘못될 경우를 대비하여 원본 설정파일은
백업 해 둔다.

=> cp /etc/named.conf /etc/named.conf_org

[root@vhost26 named]# cat /etc/named.conf
//
// named.conf for Red Hat caching-nameserver
//

options {
directory "/var/named";
};

zone "." IN {
type hint;
file "named.ca";
};
/*
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
*/

zone "abc.co.kr" IN {
type master;
file "abc.zone";
};

zone "10.168.192.in-addr.arpa" IN {
type master;
file "192.168.10.rev";
};

==> 복잡한 설정을 쉽게 이해하기 위해 꼭 필요한 부분만 남겨두고 나머지는 삭제하거나
주석처리하였다. 그런다음 임의의 하나의 도메인을 등록하였다.

그리고 세부설정 파일은 /etc/named.conf 파일의 options 는 /var/named 로 되어 있으나
chroot 기능 사용으로 인하여 아래의 디렉토리에 존재해야 한다.

[root@vhost26 named]# pwd
/var/named/chroot/var/named => 여기에 세부설정 파일을 만들어야 한다.
[
root@star named]# cp named.local abc.zone => 포맷이 일정하므로 복사해서 수정하면 쉽게
만들수 있다.
[root@vhost26 named]# cat abc.zone => 이 출력결과가 가리키는 것처럼 설정
$TTL 86400
@ IN SOA ns.abc.co.kr. root.ns.abc.co.kr. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.abc.co.kr.

www IN A 192.168.10.1 =>테스트를 위해 임의의 ip 지정
ns IN A 192.168.10.100 (단, 이대역의 주소는 named.conf 에
ftp.abc.co.kr. IN A 192.168.10.2 reverse 영역으로 설정되어 있어야 한다)
[root@vhost26 named]#
[root@star named]# cp abc.zone 192.168.10.rev => reverse 파일도 설정형태가 forward
파일과 유사하므로 복사해서 작업한다.

[root@vhost26 named]# cat 192.168.10.rev
$TTL 86400
@ IN SOA ns.abc.co.kr. root.ns.abc.co.kr. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.abc.co.kr.

1 IN PTR www.abc.co.kr. <= 왼쪽 숫자 1은 호스트 ip 끝자리이며 192.168.10.1 을 의미
2 IN PTR ftp.abc.co.kr.
100 IN PTR ns.abc.co.kr.
[root@vhost26 named]#

이렇게 설정한 다음 dns 서버 테스트를 위해 몇가지 작업이 더 필요하다.
먼저 dns 서버 ip 가 활성화 되어 있어야 한다.

물리적인 랜카드에 직접 ip를 할당해도 되지만 편의상 가상 랜카드로 테스트한다.

ifconfig eth0:1 192.168.10.100 up

[root@star named]# ping -c 3 192.168.10.100
PING 192.168.10.100 (192.168.10.100) 56(84) bytes of data.
64 bytes from 192.168.10.100: icmp_seq=0 ttl=64 time=0.120 ms
64 bytes from 192.168.10.100: icmp_seq=1 ttl=64 time=0.094 ms
64 bytes from 192.168.10.100: icmp_seq=2 ttl=64 time=0.451 ms

--- 192.168.10.100 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.094/0.221/0.451/0.163 ms, pipe 2
[root@star named]#

==> dns 서버 ip 는 문제가 없음을 알수 있다.

그 다음 로컬(this host)호스트에서 dns 서버를 직접 테스트하기 위해서는
/etc/resolv.conf 를 열어서 기존에 설정된 dns 주소는 주석으로 처리해두고
직접 구성한 dns 서버 주소를 적어 넣는다. 아래처럼.

[root@star named]# cat /etc/resolv.conf
;nameserver 168.126.63.1 => 여기서 ';' 이 주석을 의미하는 기호이다.
nameserver 192.168.20.101

여기까지 되었으면 dns 서버가 현재 구동중인지 확인해보고 구동중이라면
restart 하고 그렇지 않으면 start 한다.

dns 서버는 standalone 서버이므로 올라가 있지 않다면 직접 올려줘야 한다.
[root@star named]# pgrep -fl named
[root@star named]# => 현재 구동되어 있지 않은 상태이므로
[root@star named]# /etc/init.d/named start => start 인수를 줘서 구동한다.
named (을)를 시작합니다: [ 확인 ]

[root@star named]# pgrep -fl named
29362 /usr/sbin/named -u named -t /var/named/chroot => 올라왔다.
[root@star named]#

여기서 u 옵션은 named 데몬의 소유주 권한을 named 계정으로 하겠다는 의미.
-t 옵션은 보안을 위해서 chroot 기능을 사용하겠다는 의미이며 -t 에 해당되는
디렉토리는 설정파일 경로이다.

만약 -t 옵션을 생략한다면 위에 설정한 /etc/named.conf 파일에 포함된 세부설정
파일위치는 options 키워드가 가리키는 디렉토리 즉, /var/named 바로 아래에 존재
해야 한다.
-t 옵션은 /etc/init.d/named 라는 스크립트에 기본적으로 포함되어 있다.
OPTIONS="${OPTIONS} -t ${ROOTDIR}" <= 이 부분이이다.

그리고 테스트

[root@star named]# nslookup www.abc.co.kr => 이건 비대화식 질의
Server: 192.168.10.100
Address: 192.168.10.100#53

Name: www.abc.co.kr
Address: 192.168.10.1

[root@star named]# nslookup => 이건 대화식 질의
> ftp.abc.co.kr => 정방향(forward) 질의
Server: 192.168.10.100
Address: 192.168.10.100#53

Name: ftp.abc.co.kr
Address: 192.168.10.2
> 192.168.10.2 => 역방향(reverse) 질의
Server: 192.168.10.100
Address: 192.168.10.100#53

3.10.168.192.in-addr.arpa name = ftp.abc.co.kr.
>exit
[root@star named]#

- 이 테스트 결과는 dns 서버가 문제가 없음을 보여준다.

만약 질의 결과가 제대로 검색되지 못하면 dns 서버 설정에 문제가 있는것이다.
그런경우 dns 설정을 확인해서 제대로 수정한다음 dns 서버를 다시 구동시켜서
테스트 해야 한다.

'Log > Linux' 카테고리의 다른 글

fedora9 dns 서버 설정 테스트 내용.  (0) 2011.11.28
NFS 서비스  (0) 2011.11.28
DNS - Secondary(Slave) 구성  (0) 2011.11.28
DNS - Primary DNS 설정 및 테스트  (0) 2011.11.28
dns 설정파일 문법  (0) 2011.11.28
Posted by logwatch
*** slave DNS 설정

//
// named.conf for Red Hat caching-nameserver
//

options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};

//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};

zone "." IN {
type hint;
file "named.ca";
};

zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};

zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};

zone "lee.pe.kr" IN {
type slave;
file "slaves/lee.hosts";
masters { 192.168.20.101; };
};

zone "20.168.192.in-addr.arpa" IN {
type slave;
file "slaves/192.168.37.rzone";
masters { 192.168.20.101; };
};


zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};

zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};

zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};

include "/etc/rndc.key";

'Log > Linux' 카테고리의 다른 글

NFS 서비스  (0) 2011.11.28
dns 설정 실습  (0) 2011.11.28
DNS - Primary DNS 설정 및 테스트  (0) 2011.11.28
dns 설정파일 문법  (0) 2011.11.28
DNS - Domain Name Service  (0) 2011.11.28
Posted by logwatch

블로그 이미지
내가 나에게 확인 하는 블로그
logwatch

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2025.4
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함