NFS 네트워크 공유 서비스 배포

32061 단어
10.3 NFS 서버 배포 환경 준비
10.3.1 NFS 서비스 배포 서버 준비
서버 시스템
역할
IP
Centos6.7 x86_64
NFS 서버 쪽(NFS-server)
192.168.1.14
Centos6.7 x86_64
NFS 클라이언트(Web-lamp01)
192.168.1.15
Centos6.7 x86_64
NFS 클라이언트(Web-lnmp02)
192.168.1.16
 
 
 
 
10.3.2 NFS 서비스 배포 아키텍처
 
10.3.3 NFS 서버 측 운영 체제 및 커널 버전
1 [root@NFS-server ~]# cat /etc/redhat-release 
2 CentOS release 6.7 (Final)
3 [root@NFS-server ~]# username -r
4 [root@NFS-server ~]# uname -r
5 2.6.32-573.el6.x86_64
6 [root@NFS-server ~]# uname -m
7 x86_64

10.4 NFS 서비스 설치 전 준비
10.4.1 nfs-utils 및 rpcbind 패키지 설치 여부 조회
 
1 [root@NFS-server ~]# rpm -qa nfs-utils rpcbind   ## 
2 [root@NFS-server ~]#

지식 확장:
NFS 소프트웨어 설치를 위한 3가지 방법:
검사: rpm-qa nfs-utils rpcbind← 최적
1) 방법1:yum-y install nfs-utils rpcbind
2) 방법2: 시스템 CD에 rpm 패키지를 설치하여 명령: rpm-ivh nfs-utils-1.2.3-36.e16.x86_64.rpm
3) 방법 3: LANG=en
yum grouplist|grep -i nfs
yum groupinstall "NFS file server"-y
 
10.4.2 사용 방법1 설치에 필요한 소프트웨어 패키지
 
10.4.3 설치 패키지 설치 여부 확인
1 [root@NFS-server ~]# rpm -qa nfs-utils rpcbind
2 rpcbind-0.2.0-11.el6_7.x86_64
3 nfs-utils-1.2.3-64.el6.x86_64

10.4.4 다음 서비스 시작
 1 [root@NFS-server ~]# /etc/init.d/rpcbind status  <== rpcbind 
 2 rpcbind is stopped
 3 [root@NFS-server ~]# rpcinfo -p localhost  <==rpcbind  rpcinfo 
 4 rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused
 5 [root@NFS-server ~]# /etc/init.d/rpcbind start  <== rpcbind 
 6 Starting rpcbind:                                          [  OK  ]
 7 [root@NFS-server ~]# /etc/init.d/rpcbind status
 8 rpcbind (pid  2083) is running...
 9 ​[root@NFS-server ~]# /etc/init.d/nfs status  <== nfs 
10 rpc.svcgssd is stopped
11 rpc.mountd is stopped
12 nfsd is stopped
13 rpc.rquotad is stopped
14 [root@NFS-server ~]# /etc/init.d/nfs start  <== nfs 
15 Starting NFS services:                                     [  OK  ]
16 Starting NFS quotas:                                       [  OK  ]
17 Starting NFS mountd:                                       [  OK  ]
18 Starting NFS daemon:                                       [  OK  ]
19 Starting RPC idmapd:                                       [  OK  ]

10.4.5 전원 켜기 시작 설정
1 [root@NFS-server ~]# chkconfig --level 35  nfs on  <== nfs 
2 [root@NFS-server ~]# chkconfig --list nfs
3 nfs             0:off   1:off   2:off   3:on    4:off   5:on    6:off
4 [root@NFS-server ~]# chkconfig --level 35 rpcbind on
5 [root@NFS-server ~]# chkconfig --list rpcbind     <==<== rpcbind 
6 rpcbind         0:off   1:off   2:on    3:on    4:on    5:on    6:off

10.5 NFS 서버 구성
10.5.1 NFS 서버 구성 파일 경로
NFS 서비스 프로필 경로는/etc/exports이며 기본값은 비어 있습니다.
1 [root@NFS-server ~]# ll /etc/exports
2 -rw-r--r--. 1 root root 0 Jan 12  2010 /etc/exports
3 [root@NFS-server ~]# cat /etc/exports
4 [root@NFS-server ~]# 

10.5.2 NFS 서버 구성 파일 편집
1 [root@NFS-server ~]# vim /etc/exports
2 /data 192.168.1.0/24(rw,sync,all_squash)  <== , all_squash nobody, , 。
1 [root@NFS-server ~]# vim /etc/exports
2 /data 192.168.1.0/24(rw,sync,all_squash)  <== 
3 ​[root@NFS-server ~]# mkdir -p /data  <== /data
4 [root@NFS-server ~]# ls -ld /data
5 drwxr-xr-x. 3 root root 4096 Nov 26 15:19 /data  <== root
6 [root@NFS-server ~]# chown -R nfsnobody.nfsnobody /data  <== /data nfsnobody
7 [root@NFS-server ~]# ls -ld /data                      
8 drwxr-xr-x. 3 nfsnobody nfsnobody 4096 Nov 26 15:19 /data

10.5.3 NFS 서비스 다시 로드(우아한 재부팅)
1 [root@NFS-server ~]# /etc/init.d/nfs reload ===exportfs -r
2 [root@NFS-server ~]# cat /var/lib/nfs/etab                
3 /data   192.168.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,root_squash,all_squash)
4 [root@NFS-server ~]# showmount -e 192.168.1.14 <== 
5 Export list for 192.168.1.14:
6 /data 192.168.1.0/24 <--- /data 

10.5.4 마운트 검사 또는 테스트
1 [root@NFS-server test]# mount -t nfs 192.168.1.14:/data /mnt  ## /data /mnt 
2 [root@NFS-server test]# df -h
3 Filesystem          Size  Used Avail Use% Mounted on
4 /dev/sda3           7.1G  1.5G  5.3G  22% /
5 tmpfs               279M     0  279M   0% /dev/shm
6 /dev/sda1           190M   36M  145M  20% /boot
7 192.168.1.14:/data  7.1G  1.5G  5.3G  22% /mnt

참고:
대형 기업의 업무 장면은 운영 규범에 따라 서비스의 시작을/etc/rc에 통일적으로 쓴다.local 파일에서chkconfig 관리를 사용하지 않습니다./etc/rc.로컬 파일은 본 컴퓨터의 중요한 파일로서 모든 서비스의 시작은/etc/rc에 넣어야 합니다.local.이러한 규범의 장점은 일단 운영자가 이직하거나 업무가 이동할 때/etc/rc를 통과한다는 것이다.local는 서버 관련 서비스를 쉽게 볼 수 있어 운영 관리가 편리하다.시작 명령을/etc/rc에 넣습니다.local 파일에 서비스 시작 설명을 추가해야 합니다.
 
 1 [root@NFS-server test]# vim /etc/rc.local 
 2 #!/bin/sh
 3 #
 4 # This script will be executed *after* all the other init scripts.
 5 # You can put your own initialization stuff in here if you don't
 6 # want to do the full Sys V style init stuff.
 7 
 8 touch /var/lock/subsys/local
 9 #start up nfs services by zhurui at 20160226
10 /etc/init.d/rpcbind start <== rpcbind 
11 /etc/init.d/nfs start  <== nfs 

Web-lamp01 클라이언트 배포:
 1 1. 
 2 [root@Web-lamp01 ~]# yum -y install nfs-utils rpcbind   
 3 Loaded plugins: fastestmirror, security
 4 Setting up Install Process
 5 Loading mirror speeds from cached hostfile
 6  * base: mirrors.sina.cn
 7  * extras: mirrors.opencas.cn
 8  * updates: centos.ustc.edu.cn
 9 base                                             | 3.7 kB     00:00     
10 extras                                           | 3.4 kB     00:00     
11 extras/primary_db                                |  34 kB     00:00     
12 updates                                          | 3.4 kB     00:00 
13 2. rpcbind
14 [root@Web-lamp01 ~]# /etc/init.d/rpcbind start
15 Starting rpcbind:                                          [  OK  ]
16 [root@Web-lamp01 ~]# 
17 3. 
18 [root@Web-lamp01 ~]# chkconfig --level 35 rpcbind on
19 [root@Web-lamp01 ~]# chkconfig --list rpcbind
20 rpcbind         0:off   1:off   2:on    3:on    4:on    5:on    6:off
21 [root@Web-lamp01 ~]# 
22 4. 
23 [root@Web-lamp01 ~]# showmount -e 192.168.1.14
24 Export list for 192.168.1.14:
25 /data 192.168.1.0/24
26 5. 
27 [root@Web-lamp01 ~]# mount -t nfs 192.168.1.14:/data /mnt
28 [root@Web-lamp01 ~]# df -h
29 Filesystem          Size  Used Avail Use% Mounted on
30 /dev/sda3           7.1G  1.5G  5.3G  22% /
31 tmpfs               279M     0  279M   0% /dev/shm
32 /dev/sda1           190M   36M  145M  20% /boot
33 192.168.1.14:/data  7.1G  1.5G  5.3G  22% /mnt
34 6. , 
35 36 [root@NFS-server test]# cd /data/
37 [root@NFS-server data]# ll
38 total 8
39 -rw-r--r--. 1 nfsnobody nfsnobody    0 Nov 28 12:20 fs.sf
40 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 26 15:19 test
41 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 28 12:20 zhurui
42 [root@NFS-server data]# mkdir zhurui1
43 [root@NFS-server data]# ll
44 total 12
45 -rw-r--r--. 1 nfsnobody nfsnobody    0 Nov 28 12:20 fs.sf
46 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 26 15:19 test
47 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 28 12:20 zhurui
48 drwxr-xr-x. 2 root      root      4096 Nov 28 12:21 zhurui1
49 50 [root@Web-lamp01 ~]# cd /mnt/
51 [root@Web-lamp01 mnt]# ll
52 total 4
53 drwxr-xr-x. 2 nobody nobody 4096 Nov 26 15:19 test
54 [root@Web-lamp01 mnt]# touch fs.sf
55 [root@Web-lamp01 mnt]# ll
56 total 4
57 -rw-r--r--. 1 nobody nobody    0 Nov 28 12:20 fs.sf
58 drwxr-xr-x. 2 nobody nobody 4096 Nov 26 15:19 test
59 [root@Web-lamp01 mnt]# mkdir zhurui
60 [root@Web-lamp01 mnt]# ls -ld zhurui/
61 drwxr-xr-x. 2 nobody nobody 4096 Nov 28 12:20 zhurui/
62 [root@Web-lamp01 mnt]# ll
63 total 12
64 -rw-r--r--. 1 nobody nobody    0 Nov 28 12:20 fs.sf
65 drwxr-xr-x. 2 nobody nobody 4096 Nov 26 15:19 test
66 drwxr-xr-x. 2 nobody nobody 4096 Nov 28 12:20 zhurui
67 drwxr-xr-x. 2 nobody nobody 4096 Nov 28 12:21 zhurui1
68 7. 
69 ​[root@Web-lamp01 mnt]# vim /etc/rc.local 
70#start  up rpcbind services by zhurui 20160226
71 
72 /etc/init.d/rpcbind start
73 
74 /bin/mount -t nfs 192.168.1.14:/data /mnt

Web-lnmp02 클라이언트 배치는 Web-lamp01 배치 절차와 동일합니다. 여기에는 더 이상 설명이 없습니다.
14  1 1. 
15  2 [root@Web-lnmp02 ~]# yum -y install nfs-utils rpcbind   
16  3 Loaded plugins: fastestmirror, security
17  4 Setting up Install Process
18  5 Loading mirror speeds from cached hostfile
19  6  * base: mirrors.sina.cn
20  7  * extras: mirrors.opencas.cn
21  8  * updates: centos.ustc.edu.cn
22  9 base                                             | 3.7 kB     00:00     
23 10 extras                                           | 3.4 kB     00:00     
24 11 extras/primary_db                                |  34 kB     00:00     
25 12 updates                                          | 3.4 kB     00:00 
26 13 2. rpcbind
27 14 [root@Web-lnmp02 ~]# /etc/init.d/rpcbind start
28 15 Starting rpcbind:                                          [  OK  ]
29 16 [root@Web-lnmp02 ~]# 
30 17 3. 
31 18 [root@Web-lnmp02 ~]# chkconfig --level 35 rpcbind on
32 19 [root@Web-lnmp02 ~]# chkconfig --list rpcbind
33 20 rpcbind         0:off   1:off   2:on    3:on    4:on    5:on    6:off
34 21 [root@Web-lnmp02 ~]# 
35 22 4. 
36 23 [root@Web-lnmp02 ~]# showmount -e 192.168.1.14
37 24 Export list for 192.168.1.14:
38 25 /data 192.168.1.0/24
39 26 5. 
40 27 [root@Web-lnmp02 ~]# mount -t nfs 192.168.1.14:/data /mnt
41 28 [root@Web-lnmp02 ~]# df -h
42 29 Filesystem          Size  Used Avail Use% Mounted on
43 30 /dev/sda3           7.1G  1.5G  5.3G  22% /
44 31 tmpfs               279M     0  279M   0% /dev/shm
45 32 /dev/sda1           190M   36M  145M  20% /boot
46 33 192.168.1.14:/data  7.1G  1.5G  5.3G  22% /mnt
47 34 6. , 
48 3549 36 [root@NFS-server test]# cd /data/
50 37 [root@NFS-server data]# ll
51 38 total 8
52 39 -rw-r--r--. 1 nfsnobody nfsnobody    0 Nov 28 12:20 fs.sf
53 40 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 26 15:19 test
54 41 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 28 12:20 zhurui
55 42 [root@NFS-server data]# mkdir zhurui1
56 43 [root@NFS-server data]# ll
57 44 total 12
58 45 -rw-r--r--. 1 nfsnobody nfsnobody    0 Nov 28 12:20 fs.sf
59 46 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 26 15:19 test
60 47 drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Nov 28 12:20 zhurui
61 48 drwxr-xr-x. 2 root      root      4096 Nov 28 12:21 zhurui1
62 4963 50 [root@Web-lnmp02 ~]# cd /mnt/
64 51 [root@Web-lnmp02 mnt]# ll
65 52 total 4
66 53 drwxr-xr-x. 2 nobody nobody 4096 Nov 26 15:19 test
67 54 [root@Web-lnmp02 mnt]# touch fs.sf
68 55 [root@Web-lnmp02 mnt]# ll
69 56 total 4
70 57 -rw-r--r--. 1 nobody nobody    0 Nov 28 12:20 fs.sf
71 58 drwxr-xr-x. 2 nobody nobody 4096 Nov 26 15:19 test
72 59 [root@Web-lnmp02 mnt]# mkdir zhurui
73 60 [root@Web-lnmp02 mnt]# ls -ld zhurui/
74 61 drwxr-xr-x. 2 nobody nobody 4096 Nov 28 12:20 zhurui/
75 62 [root@Web-lnmp02 mnt]# ll
76 63 total 12
77 64 -rw-r--r--. 1 nobody nobody    0 Nov 28 12:20 fs.sf
78 65 drwxr-xr-x. 2 nobody nobody 4096 Nov 26 15:19 test
79 66 drwxr-xr-x. 2 nobody nobody 4096 Nov 28 12:20 zhurui
80 67 drwxr-xr-x. 2 nobody nobody 4096 Nov 28 12:21 zhurui1
81 68 7. 
82 69 ​[root@Web-lnmp02 mnt]# vim /etc/rc.local 
83 70 ​#start  up rpcbind services by zhurui 20160226
84 71 
85 72 /etc/init.d/rpcbind start
86 73 
87 74 /bin/mount -t nfs 192.168.1.14:/data /mnt

10.6 mount 마운트 성능 최적화 매개 변수 옵션
(1) 디렉터리 업데이트 및 파일 타임 스탬프 마운트 금지
1 mount -t nfs -o noatime,nodiratime 192.168.1.14:/data

(2) 안전하고 최적화된 마운트 방식
1 mount -t nfs -o nosuid,noexec,nodev,noatime,nodiratime,intr,rsize=131072,wsize=131072 192.168.1.14:/data /mnt

(3) 기본 마운트 방식
1 mount -t nfs 192.168.1.14:/data /mnt

10.7 NFS 코어 최적화
해당 커널 최적화 명령:
1 cat >>/etc/sysctl.conf<<EOF
2 net.core.wmem_default = 8388608
3 net.core.rmem_default = 8388608
4 net.core.rmem_max = 16777216
5 net.core.wmem_max = 16777216
6 EOF
 sysctl -p 

좋은 웹페이지 즐겨찾기