블로그 이미지
오정oI

카테고리

분류 전체보기 (119)
회사 - pj # 나라원 (1)
회사 - pj # 나라원 (2)
이직준비 (10)
국비-클라우드 (1)
학점은행제 (0)
취미 (0)
주식 (0)
외국어 (0)
자격증 (14)
BigData_On (1)
BigData_Off1 (74)
클라우드 (0)
언어_Framework (1)
언어-Server (2)
언어_Client (0)
업무 (1)
IT참고서적 (1)
IT 최신 트랜드 (0)
제테크 (1)
Study Plan (2)
동영상 및 자료 (5)
여행 (1)
git (0)
Total
Today
Yesterday
반응형
SMALL

* 강사님 강의 노트 :

1월24일_10평일리2.txt

1월25일_11평일리2.txt

 

* ③ auto mount :

0124 수업 내용.txt

* nfs 실습 요점 정리 :

08.01.25_nfs_summary.txt

 

* 목차

 

* NFS(Network File System)

1> 개념

- 파일 시스템 공유와 서버 자원 공유를 위해 1980년대 중반 썬마이크로시스템즈에서 개발

- 디스크 공간 부족, 가격이 비싸므로 이를 해결하기 위해서 개발. 현재는 성능이 좋아지고 가격도 저렴해

졌으므로 파일 공유 및 파일 서버를 위한 방법으로 사용되고 있음

- 서버의 리소스(자원)을 클라이언트가 마치 자신의 리소스처럼 사용함

- 서버/클라이언트 구조로 이루어져 있으며 서버의 공유 파일 시스템을 클라이언트에서 마운트하여 사용함

- 보안은 취약함

- 다른 애의 장치(Partitioning)만 제공 (dir.같은건 갖다 못 씀)

2> 작업 순서

① nfs 패키지 설치 유무 확인

(참고로 centOS 5.x에서는 portmap 패키지를 설치했음.

centOS 6, 7은 portmap 패키지 없고 rpcbind 패키지를 설치)

 

** RPC (Remote Procedure Call : 원격 절차 호출)

1> 개념

- 별도의 원격 제어를 위한 코딩 없이 다른 주소 공간에서 함수를 실행할 수 있게하는 프로세스 간 통신 기술

- nfs service를 사용하기 위한 필수 서비스

- 클라이언트로부터 포트 요청이 있을 경우 새로운 포트를 할당해주며 mapping(변환)해주는 역할

- web server/ftp server와 같이 특정 포트로 listening 하는 것이 아니라 portmapper 프로그램을 이용하여

네트워크 포트를 할당 받게 됨 (포트가 정해지지 않음)

- portmapper 프로그램은 포트 번호 111번을 점유하고 lisening 하다가 접속 요청이 있으면 nfs server에게

포트를 바꾸어 접속 연결을 시켜줌

cf. 얘는 이전에 배웠던 서비스들 과 달리 netstat 이 안됨?

[기존 서비스와 rpc 서비스의 차이점]

2> 명령어

[서버]

nfs 서비스명이 nfs.service

rpcbind 서비스명이 rpcbind.service

 

rpcinfo

-rpc 기반의 서비스 테이블의 정보를 확인하게 위한 명령어

사용형식

rpcinfo [option]

option

-p : 등록된 rpc 정보

항목

program → 프로그램 번호

vers       → 프로그램 버전

proto     → 프로토콜

port       → 프로그램에 맵핑된 포트 

service   → 프로그램명

ex)

rpcinfo -p

→ 자신의 rpc 정보를 출력

ex)

rpcinfo -p Server-IP

→ 상대방의 rpc 정보

 

exportfs

- nfs server에서 export(보내기) 된 디렉터리 정보를 관리하는 명령어

사용형식

exportfs [option]

option

-a : /etc/exports 파일에 나열된 모든 디렉터리를 반출

-r : /etc/exports 파일을 다시 읽어들여옴

-v : 각 디렉터리가 반출 또는 반출해제될 때 디렉터리명을 출력(사전점검)

 

[클라이언트]

 

mount [option] 인자값

option

-t : 마운트할 타입 Server-IP:Server-share_dir client-mountpoint

인자값은 nfs

 

 

 

3> 환경 설정 파일 위치 및 설정 방법

/etc/exports

-nfs의 환경설정파일

 

설정방법

[share dir]

- 공유할 디렉터리명 (Server가 Client에게)

 

[access allow host/network]

- 접근을 허용할 호스트/네트워크 대역대

 

ㆍ호스트 방식

ex) x.x.x.x

ㆍ네트워크 대역(영역)

ex) x.x.x.0/subnet_mask   // class에 따라

또는

x.x.x.0/prefix

C 클래스면, 대역대 = 255.255.255.0, prefix = 24

ㆍ모든 네트워크 대역

ex) *

 

ㆍ(option)

ro → 읽기전용 파일시스템

rw → 읽고쓰기 파일시스템                                                 anonymous 

root_squash(기본) → nfs client에서 접근하는 관리자를 무시하고 nobodynfsnobody로 변환(mapping)

(default)             → nfs client에서의 root 요청을 nfs server의 nobody와 같은 익명 UID, GID로 지정하여 root 권한으로

     접근을 거부

     => 클라이언트 접근 거부(root 인정 거부)

no_root_squash  → root_squash의 반대 개념으로 nfs server와 nfs client의 root 권한으로 접근을 허용

=> 클라이언트 접근 인정(root 인정 허용)

cf. 관리자는 C, S 각각 1명씩 총 2명 필요

squash : 깔아뭉개다.

no_all_squash(기본값) → root를 제외한 nfs server와 nfs client의 사용자 계정의 UID, GID를 같은 권한으로 일치시킴

(default)                  => 클라이언트 UID, GID root 권한 인정

all_squash → no_all_squash의 반대 개념으로 모든 사용자 계정의 UID, GID를 nfsnobody로 지정함

=> 클라이언트 UID, GID root 권한 거부 => anonymous 

sync → 디스크 쓰기 실행 후 동기화 

 

[서버]

// nfs 패키지 설치

[root@junga ~]# rpm -qa | grep nfs
libnfsidmap-0.25-17.el7.x86_64
nfs-utils-1.3.0-0.48.el7.x86_64
[root@junga ~]#
[root@junga ~]# yum install nfs*
y

 

// portmap 패키지 설치

=> centOS 5.x 에는 있었는데 지금은 없음

=> centOS 6, 7.x 에서는 rpcbind 설치해야..,

[root@junga ~]# rpm -qa | grep portmap
[root@junga ~]#
[root@junga ~]# yum install portmap
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.iij.ad.jp
Package rpcbind-0.2.0-42.el7.x86_64 already installed and latest version
Nothing to do
[root@junga ~]#
[root@junga ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-42.el7.x86_64

 

// nfs, rpcbind netstat

[root@junga ~]# rpm -qa | grep portmap
[root@junga ~]#
[root@junga ~]# yum install portmap
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.iij.ad.jp
Package rpcbind-0.2.0-42.el7.x86_64 already installed and latest version
Nothing to do
[root@junga ~]#
[root@junga ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-42.el7.x86_64
[root@junga ~]#
[root@junga ~]# systemctl is-active nfs.service
unknown
[root@junga ~]#
[root@junga ~]# systemctl is-active rpcbind.service
inactive
[root@junga ~]#

 

// nfs의 환경설정 파일 및 설정 방법

[root@junga ~]# ls -l /etc/exports
-rw-r--r--. 1 root root 0  6월  7  2013 /etc/exports

[root@junga ~]#
[root@junga ~]# vi /etc/exports

=> 비어있음!

내가 설정해야..,

[root@junga ~]# vi /etc/exports
// 제목조차도 2번째 3번째 단어 공백 없게!!!


      1 #[share dir]    [access allow /host/network](option)            
      2 #/test_nfs_s1   192.168.46.90(rw,no_root_squash,sync)         // 호스트 방식
      3 #/test_nfs_s2   192.168.46.0/255.255.255.0(ro,sync)             // 네트워크 영역대
      4 #/test_nfs_s3   *(sync)                                                  // 네트워크 영역대 : all  

:wq

 

만약 호스트 2명이면,

      2 #/test_nfs_s1   192.168.46.90(rw,no_root_squash,sync)  192.168.46.91(rw,no_root_squash,sync)       

// 옆에 또 써주기~!

2018.01.25

[root@junga ~]# ls -l /etc/exports
-rw-r--r-- 1 root root 176  1월 24 15:17 /etc/exports
[root@junga ~]#
[root@junga ~]# vi /etc/exports

// 2번째 줄 주석 없애기

  1 #[share dir]    [access allow /host/network](option)            
  2 /test_nfs_s1   192.168.46.90(rw,no_root_squash,sync)         
  3 #/test_nfs_s2   192.168.46.0/255.255.255.0(ro,sync)           
  4 #/test_nfs_s3   *(sync)                                                

:wq
[root@junga ~]#
[root@junga ~]# systemctl is-active nfs.service
unknown
[root@junga ~]#
[root@junga ~]# systemctl is-active rpcbind.service
inactive
[root@junga ~]#
[root@junga ~]# systemctl restart nfs.service
[root@junga ~]#
[root@junga ~]# systemctl is-active nfs.service
active
[root@junga ~]#
[root@junga ~]# systemctl is-active rpcbind.service
active
[root@junga ~]#
[root@junga ~]#

[root@junga ~]# systemctl -l status nfs.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: active (exited) since 목 2018-01-25 12:45:42 KST; 58s ago
  Process: 2435 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 2430 ExecStartPre=/bin/sh -c /bin/kill -HUP `cat /run/gssproxy.pid` (code=exited, status=0/SUCCESS)
  Process: 2429 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
 Main PID: 2435 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

 1월 25 12:45:42 junga.kgitbank systemd[1]: Starting NFS server and services...
 1월 25 12:45:42 junga.kgitbank exportfs[2429]: exportfs: Failed to stat /test_nfs_s1: No such file or directory
 1월 25 12:45:42 junga.kgitbank systemd[1]: Started NFS server and services.

[root@junga ~]#
[root@junga ~]# systemctl -l status rpcbind.service
● rpcbind.service - RPC bind service
   Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; indirect; vendor preset: enabled)
   Active: active (running) since 목 2018-01-25 12:45:42 KST; 1min 18s ago
  Process: 2424 ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 2426 (rpcbind)
   CGroup: /system.slice/rpcbind.service
           └─2426 /sbin/rpcbind -w

 1월 25 12:45:42 junga.kgitbank systemd[1]: Starting RPC bind service...
 1월 25 12:45:42 junga.kgitbank systemd[1]: Started RPC bind service.
[root@junga ~]#
[root@junga ~]# cat /etc/exports
#[share dir] [access allow /host/network](option)
/test_nfs_s1   192.168.46.90(rw,no_root_squash,sync)
#/test_nfs_s2 192.168.46.0/255.255.255.0(ro,sync)
#/test_nfs_s3 *(sync)
[root@junga ~]#
[root@junga ~]# ls -ld /test_nfs_s1
ls: cannot access /test_nfs_s1: 그런 파일이나 디렉터리가 없습니다
[root@junga ~]#
[root@junga ~]# mkdir /test_nfs_s1
[root@junga ~]#
[root@junga ~]# ls -ld /test_nfs_s1
drwxr-xr-x 2 root root 6  1월 25 12:50 /test_nfs_s1

// 재시작 하는건 안좋은데.., 일단 테스트 해야해서..,

[root@junga ~]# systemctl restart nfs.service
[root@junga ~]#
[root@junga ~]# systemctl -l status nfs.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: active (exited) since 목 2018-01-25 12:51:52 KST; 45s ago
  Process: 2696 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
  Process: 2693 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
  Process: 2692 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
  Process: 2712 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 2707 ExecStartPre=/bin/sh -c /bin/kill -HUP `cat /run/gssproxy.pid` (code=exited, status=0/SUCCESS)
  Process: 2706 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 2712 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

 1월 25 12:51:52 junga.kgitbank systemd[1]: Starting NFS server and services...
 1월 25 12:51:52 junga.kgitbank systemd[1]: Started NFS server and services.
[root@junga ~]#

// nfs는 일반 서비스와 다르게 netstat이 안되는걸 확인 할 수 있다.
[root@junga ~]# netstat -atunp | grep nfs
[root@junga ~]#
[root@junga ~]# netstat -atunp | grep sshd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      964/sshd           
tcp6       0      0 :::22                   :::*                    LISTEN      964/sshd           
[root@junga ~]#

// 자신의 rpc 정보를 출력

[root@junga ~]# rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  40887  status
    100024    1   tcp  43715  status
    100005    1   udp  20048  mountd
    100005    1   tcp  20048  mountd
    100005    2   udp  20048  mountd
    100005    2   tcp  20048  mountd
    100005    3   udp  20048  mountd
    100005    3   tcp  20048  mountd
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    3   udp   2049  nfs_acl

    100021    1   udp  32951  nlockmgr
    100021    3   udp  32951  nlockmgr
    100021    4   udp  32951  nlockmgr
    100021    1   tcp  43544  nlockmgr
    100021    3   tcp  43544  nlockmgr
    100021    4   tcp  43544  nlockmgr

program → 프로그램 번호

vers       → 프로그램 버전

proto     → 프로토콜

port       → 프로그램에 맵핑된 포트 

service   → 프로그램명

[root@junga ~]#

// 사전 점검

[root@junga ~]# exportfs -v
/test_nfs_s1   192.168.46.90(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,no_root_squash,no_all_squash)
[root@junga ~]#
[root@junga ~]# cat /etc/exports
#[share dir] [access allow /host/network](option)
/test_nfs_s1   192.168.46.90(rw,no_root_squash,sync)
#/test_nfs_s2 192.168.46.0/255.255.255.0(ro,sync)
#/test_nfs_s3 *(sync)
[root@junga ~]#

// 데몬 재시작 대신

/etc/exports 파일 다시 읽어들여서 상태 확인

nfs service 는 restart 할 필요 없음! (맨 처음은 필요)

1번은 하는데 설정파일 적용 위해 다시 restart 할 필요 없음!

[root@junga ~]# exportfs -ra
[root@junga ~]#
[root@junga ~]# rm -rf /test_nfs_s1
[root@junga ~]#
[root@junga ~]# exportfs -ra
exportfs: Failed to stat /test_nfs_s1: No such file or directory
[root@junga ~]#
[root@junga ~]# mkdir /test_nfs_s1
[root@junga ~]#
[root@junga ~]# exportfs -ra
[root@junga ~]#
[root@junga ~]#

// 서버 역할 : 서비스 제공

-------------------------- 여기까지는 nfs server가 하는 일 --------------------------

하기 전

① /etc/exports 에서 2번째 주석 풀기

# cat /etc/exports

② ip : 우리는 자동으로 설정해둬서 바뀔 수도 있으므로 확인

# ifconfig | head -2

③ nfs가 작동중인지 확인 :

# systemctl is-active nfs.service

# systemctl -l status nfs.service

④ 적용하려면, 데몬 재 시작 대신에,

# exportfs -ra

 

cf.  scp tip.

// 전송할 ip                                    

# scp /etc/exports itbank@192.168.46.91:/home/itbank

  // /home이라고 해야지 허가권에 문제 안걸림!

 

[클라이언트]

// ① mount 

[root@junga ~]# mount -t nfs 192.168.46.90:/test_nfs_s1 /test_nfs_c1
mount.nfs: mount point /test_nfs_c1 does not exist
[root@junga ~]#
[root@junga ~]# mkdir /test_nfs_c1
[root@junga ~]#
[root@junga ~]# ls -ld /test_nfs_c1
drwxr-xr-x 2 root root 6  1월 25 13:14 /test_nfs_c1
[root@junga ~]#
[root@junga ~]# mount -t nfs 192.168.46.90:/test_nfs_s1 /test_nfs_c1
[root@junga ~]#
[root@junga ~]# df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/sda3                    17G   12G  5.5G  68% /
devtmpfs                    474M     0  474M   0% /dev
tmpfs                       489M     0  489M   0% /dev/shm
tmpfs                       489M  7.0M  482M   2% /run
tmpfs                       489M     0  489M   0% /sys/fs/cgroup
/dev/sda1                  1014M  194M  821M  20% /boot
tmpfs                        98M  4.0K   98M   1% /run/user/42
tmpfs                        98M   24K   98M   1% /run/user/0
/dev/sr0                    8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
192.168.46.90:/test_nfs_s1   17G   12G  5.5G  68% /test_nfs_c1

// mount 확인
[root@junga ~]# df -h    //client가 작업한거. Server는 못 봄!
Filesystem                  Size  Used Avail Use% Mounted on
/dev/sda3                    17G   12G  5.5G  68% /  == \C:
devtmpfs                    474M     0  474M   0% /dev
tmpfs                       489M     0  489M   0% /dev/shm
tmpfs                       489M  7.0M  482M   2% /run
tmpfs                       489M     0  489M   0% /sys/fs/cgroup
/dev/sda1                  1014M  194M  821M  20% /boot
tmpfs                        98M  4.0K   98M   1% /run/user/42
tmpfs                        98M   24K   98M   1% /run/user/0
/dev/sr0                    8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
192.168.46.90:/test_nfs_s1   17G   12G  5.5G  68% /test_nfs_c1

       ↑S. 공유dir.                                ↑C. mount pt.

  == 현재 사용 공간

=> nfs는 잘 됬지만 과정 틀림.

Client에게 최상위(/)를 제공해선 안됨!   // partitioning 할 때 남은 공간을 모두 /에게 줬기 때문에..,

[Sol]

① 별도로 다른 파티션 용량 남아있다거나

② 새로운 하드디스크 추가해서 이것을 제공

 

<실습 1>

// 하기전에

=> snapshot 마지막으로 GOTO!

실습은 클라이언트에서 작업하세요(1대입니다. 2대가 아닙니다)


nfs server

HDD (SCSI, 1GB) : 100(이걸 사용), 200, 300, 400         
nfs serivce 설정(설정할 때 호스트 방식으로 해보세요)
auto mount 설정


nfs client

nfs server가 공유한 디렉터리를 사용
nfs client의 mount point에다가 파일이나 디렉터리를 생성하여 nfs server와 공유되는지 확인

 

 

// ① partitioning

[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c264c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2050047     1024000   83  Linux
/dev/sda2         2050048    10438655     4194304   82  Linux swap / Solaris
/dev/sda3        10438656    14534655     2048000   83  Linux
/dev/sda4        14534656    41943039    13704192    5  Extended
/dev/sda5        14536704    14946303      204800   83  Linux
/dev/sda6        14948352    41943039    13497344   83  Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@localhost ~]#
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x80ac2390.

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x80ac2390

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +100M
Partition 1 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x80ac2390

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (206848-2097151, default 206848):
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-2097151, default 2097151): +200M
Partition 2 of type Linux and of size 200 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x80ac2390

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      616447      204800   83  Linux

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (616448-2097151, default 616448):
Using default value 616448
Last sector, +sectors or +size{K,M,G} (616448-2097151, default 2097151): +300M
Partition 3 of type Linux and of size 300 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x80ac2390

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      616447      204800   83  Linux
/dev/sdb3          616448     1230847      307200   83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
Selected partition 4
First sector (1230848-2097151, default 1230848):
Using default value 1230848
Last sector, +sectors or +size{K,M,G} (1230848-2097151, default 2097151):
Using default value 2097151
Partition 4 of type Linux and of size 423 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x80ac2390

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      616447      204800   83  Linux
/dev/sdb3          616448     1230847      307200   83  Linux
/dev/sdb4         1230848     2097151      433152   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#
[root@localhost ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x80ac2390

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      616447      204800   83  Linux
/dev/sdb3          616448     1230847      307200   83  Linux
/dev/sdb4         1230848     2097151      433152   83  Linux

// ② automount

// ②-1> format

[root@localhost ~]# mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=6400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=25600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]#
[root@localhost ~]# blkid /dev/sdb1
/dev/sdb1: UUID="3099f299-b60f-49ab-8847-17d12c51428d" TYPE="xfs"


[root@localhost ~]#
[root@localhost ~]# mkfs -t xfs /dev/sdb1
mkfs.xfs: /dev/sdb1 appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.
[root@localhost ~]#
[root@localhost ~]# mkfs -t xfs /dev/sdb2
meta-data=/dev/sdb2              isize=512    agcount=4, agsize=12800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=51200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]#
[root@localhost ~]# mkfs.xfs /dev/sdb3
meta-data=/dev/sdb3              isize=512    agcount=4, agsize=19200 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=76800, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]#
[root@localhost ~]# mkfs.xfs /dev/sdb4
meta-data=/dev/sdb4              isize=512    agcount=4, agsize=27072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=108288, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]#
[root@localhost ~]# blkid /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4
/dev/sdb1: UUID="3099f299-b60f-49ab-8847-17d12c51428d" TYPE="xfs"
/dev/sdb2: UUID="0ba41120-3745-4cc7-ae59-ddcf499ddfaa" TYPE="xfs"
/dev/sdb3: UUID="ddf9e8e5-e124-4cf6-bf0f-49777b22637d" TYPE="xfs"
/dev/sdb4: UUID="0b84f381-d9d6-4a7c-8037-024bdbaab9fd" TYPE="xfs"
[root@localhost ~]#

// ②-2> automount

[root@localhost ~]# vi /etc/fstab
14 /dev/sdb1       /auto/sharedir  xfs     defaults        0 0
:wq

[root@localhost ~]# mount -a
mount: mount point /auto/sharedir does not exist
[root@localhost ~]#
[root@localhost ~]# mkdir -p /auto/sharedir
[root@localhost ~]#
[root@localhost ~]# mount -a
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        13G  7.2G  5.7G  56% /
devtmpfs        474M     0  474M   0% /dev
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           488M  7.1M  481M   2% /run
tmpfs           488M     0  488M   0% /sys/fs/cgroup
/dev/sda5       197M   16M  181M   9% /home
/dev/sda3       2.0G  449M  1.6G  23% /var
/dev/sda1       997M  194M  803M  20% /boot
tmpfs            98M  4.0K   98M   1% /run/user/42
tmpfs            98M   24K   98M   1% /run/user/0
/dev/sr0        8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
/dev/sdb1        97M  5.2M   92M   6% /auto/sharedir
[root@localhost ~]#

 

// ③ nfs server

[server]

// nfs 패키지 설치

[root@junga ~]# rpm -qa | grep nfs
libnfsidmap-0.25-17.el7.x86_64
nfs-utils-1.3.0-0.48.el7.x86_64
[root@junga ~]#
[root@junga ~]# yum install nfs*
y

[root@localhost ~]# rpm -qa | grep nfs
nfsometer-1.7-1.el7.noarch
libnfsidmap-0.25-17.el7.x86_64
nfs4-acl-tools-0.3.3-15.el7.x86_64
nfstest-2.1.5-1.el7.noarch
nfs-utils-1.3.0-0.48.el7_4.x86_64

 

// portmap 패키지 설치

=> centOS 5.x 에는 있었는데 지금은 없음

=> centOS 6, 7.x 에서는 rpcbind 설치해야..,

[root@junga ~]# rpm -qa | grep portmap
[root@junga ~]#
[root@junga ~]# yum install portmap
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.iij.ad.jp
Package rpcbind-0.2.0-42.el7.x86_64 already installed and latest version
Nothing to do
[root@junga ~]#
[root@junga ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-42.el7.x86_64                    // 설치되 있음!

 

// nfs, rpcbind netstat

[root@junga ~]# rpm -qa | grep portmap
[root@junga ~]#
[root@junga ~]# yum install portmap
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.iij.ad.jp
Package rpcbind-0.2.0-42.el7.x86_64 already installed and latest version
Nothing to do
[root@junga ~]#
[root@junga ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-42.el7.x86_64
[root@junga ~]#
[root@junga ~]# systemctl is-active nfs.service
unknown
[root@junga ~]#
[root@junga ~]# systemctl is-active rpcbind.service
inactive
[root@junga ~]#

 

// nfs의 환경설정 파일 및 설정 방법

[root@junga ~]# ls -l /etc/exports
-rw-r--r--. 1 root root 0  6월  7  2013 /etc/exports

[root@junga ~]#
[root@junga ~]# vi /etc/exports

=> 비어있음!

내가 설정해야..,

[root@junga ~]# vi /etc/exports
// 제목조차도 2번째 3번째 단어 공백 없게!!!

      1 /auto/sharedir  192.168.46.85(rw,no_root_squash,sync)        // 호스트 방식
:wq

 

// nfs 데몬 시작 및 /etc/exports 점검

[root@localhost ~]# systemctl restart nfs.service
[root@localhost ~]#
[root@localhost ~]# systemctl is-active nfs.service
active
[root@localhost ~]#
[root@localhost ~]# systemctl is-active rpcbind.service
active
[root@localhost ~]#
[root@localhost ~]# systemctl -l status nfs.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: active (exited) since 목 2018-01-25 14:35:31 KST; 28s ago
  Process: 3429 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 3424 ExecStartPre=/bin/sh -c /bin/kill -HUP `cat /run/gssproxy.pid` (code=exited, status=0/SUCCESS)
  Process: 3423 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 3429 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

 1월 25 14:35:31 localhost.localdomain systemd[1]: Starting NFS server and services...
 1월 25 14:35:31 localhost.localdomain systemd[1]: Started NFS server and services.
[root@localhost ~]#
[root@localhost ~]# systemctl -l status rpcbind.service
● rpcbind.service - RPC bind service
   Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; indirect; vendor preset: enabled)
   Active: active (running) since 목 2018-01-25 14:35:31 KST; 42s ago
  Process: 3418 ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 3421 (rpcbind)
   CGroup: /system.slice/rpcbind.service
           └─3421 /sbin/rpcbind -w

 1월 25 14:35:31 localhost.localdomain systemd[1]: Starting RPC bind service...
 1월 25 14:35:31 localhost.localdomain systemd[1]: Started RPC bind service.
[root@localhost ~]#
[root@localhost ~]# ls -ld /auto/sharedir/
drwxr-xr-x 2 root root 6  1월 25 14:19 /auto/sharedir/
[root@localhost ~]#
[root@localhost ~]# exportfs -v
/auto/sharedir 192.168.46.90(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,no_root_squash,no_all_squash)
[root@localhost ~]#
[root@localhost ~]# exportfs -ra
[root@localhost ~]#
[root@localhost ~]#

하기 전

① /etc/exports 에서 2번째 주석 풀기

# cat /etc/exports

② ip : 우리는 자동으로 설정해둬서 바뀔 수도 있으므로 확인

# ifconfig | head -2

③ nfs가 작동중인지 확인 :

# systemctl is-active nfs.service

# systemctl -l status nfs.service

④ 적용하려면, 데몬 재 시작 대신에,

# exportfs -ra

// ④ nfs client

[client]

// 점검

[root@localhost ~]# cat /etc/exports
/auto/sharedir 192.168.46.90(rw,no_root_squash,sync)
[root@localhost ~]#
[root@localhost ~]# ifconfig | head -2
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.46.85  netmask 255.255.255.0  broadcast 192.168.46.255
[root@localhost ~]#
[root@localhost ~]# vi /etc/exports

ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.46.85  netmask 255.255.255.0  broadcast 192.168.46.255

Press ENTER or type command to continue
[root@localhost ~]#
[root@localhost ~]# systemctl is-active nfs.service
active
[root@localhost ~]#
[root@localhost ~]# systemctl -l status nfs.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: active (exited) since 목 2018-01-25 14:35:31 KST; 7min ago
  Process: 3429 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 3424 ExecStartPre=/bin/sh -c /bin/kill -HUP `cat /run/gssproxy.pid` (code=exited, status=0/SUCCESS)
  Process: 3423 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 3429 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

 1월 25 14:35:31 localhost.localdomain systemd[1]: Starting NFS server and services...
 1월 25 14:35:31 localhost.localdomain systemd[1]: Started NFS server and services.
[root@localhost ~]#
[root@localhost ~]# exportfs -ra

// client

[root@localhost ~]# mkdir /test_nfs_c1
[root@localhost ~]#
[root@localhost ~]# ls -ld /test_nfs_c1
drwxr-xr-x 2 root root 6  1월 25 14:39 /test_nfs_c1
[root@localhost ~]#
[root@localhost ~]# mount -t nfs 192.168.46.85:/auto_sharedir /test_nfs_c1
mount.nfs: access denied by server while mounting 192.168.46.85:/auto_sharedir
[root@localhost ~]#
[root@localhost ~]# mount -t nfs 192.168.46.85:/auto/sharedir /test_nfs_c1
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda6                      13G  7.4G  5.6G  57% /
devtmpfs                      474M     0  474M   0% /dev
tmpfs                         488M     0  488M   0% /dev/shm
tmpfs                         488M  7.1M  481M   2% /run
tmpfs                         488M     0  488M   0% /sys/fs/cgroup
/dev/sda5                     197M   16M  181M   9% /home
/dev/sda3                     2.0G  452M  1.6G  23% /var
/dev/sda1                     997M  194M  803M  20% /boot
tmpfs                          98M  4.0K   98M   1% /run/user/42
tmpfs                          98M   24K   98M   1% /run/user/0
/dev/sr0                      8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
/dev/sdb1                      97M  5.2M   92M   6% /auto/sharedir
192.168.46.85:/auto/sharedir   97M  5.3M   92M   6% /test_nfs_c1

 

// 확인

[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Jan 11 13:46:02 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=bbfd7ee6-e6db-40ef-8ed1-03b0efff5577 /                       xfs     defaults        0 0
UUID=4eaedded-01f7-4013-a328-364dfe587223 /boot                   xfs     defaults        0 0
UUID=bfcdb9c5-05c7-49ba-b530-8d4aedd39841 /home                   xfs     defaults        0 0
UUID=d2a7fb6a-fe3b-4022-93b0-8e4f6044cfb8 /var                    xfs     defaults        0 0
UUID=3e93d164-8196-471f-90a9-0f1937711e92 swap                    swap    defaults        0 0
/dev/sdb1 /auto/sharedir xfs defaults 0 0
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ls /test_nfs_c1
[root@localhost ~]#
[root@localhost ~]# touch /test_nfs_c1/test1
[root@localhost ~]#
[root@localhost ~]# ls -l /test_nfs_c1/
합계 0
-rw-r--r-- 1 root root 0  1월 25 14:44 test1
[root@localhost ~]# ls -l /test_nfs_c1/ /auto/sharedir/
/auto/sharedir/:
합계 0
-rw-r--r-- 1 root root 0  1월 25 14:44 test1

/test_nfs_c1/:
합계 0
-rw-r--r-- 1 root root 0  1월 25 14:44 test1

 

[server]

① 파티션 설정

② 포맷     /dev/sdb1

③ nfs 패키지 설치

④ /etc/exports 설정

⑤ nfs.service 재시작, exportfs -ra

⑥ mount

⑦  automount(재부팅 하면 날라가니까 해줌!) : /etc/exports 쓰기

[client]

① nfs mount (nfs service가 켜져 있어야..,)

 

=> client도 automount 하고 싶다!

① /etc/fstab이 있다?

② autofs system => 저절로 mount..,

    안 쓰면 또 unmount..,

반응형
LIST
Posted by 오정oI
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함