프린트 하기

OS 환경 : Oracle Linux 8.4 (64bit)

 

방법 : Oracle Linux 8 nfs 서버 구축 가이드

본문에서는 oracle linux 8 버전에서 nfs 를 구축하는 방법을 설명함
nfs란?
nfs(Network File System)는 네트워크 상에서 파일을 공유하기 위한 프로토콜로, 여러 대의 컴퓨터가 네트워크를 통해 같은 파일 시스템을 공유할 수 있게 해줌
nfs는 주로 리눅스 및 유닉스 계열 운영 체제에서 사용되며, 서버와 클라이언트 사이에 파일을 원격으로 읽거나 쓸 수 있도록 하는 시스템임
오라클을 사용하는 환경이라면 오라클 백업도 nfs에 저장할 수 있음

 

 

테스트
0. 서버 정보
1. nfs 서버 설정
2. 클라이언트 서버 설정

 

 

테스트
0. 서버 정보
nfs 서버 : 192.168.137.50
클라이언트 서버 : 192.168.137.19

 

 

1. nfs 서버 설정
nfs-utils 패키지 설치

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# dnf install -y nfs-utils
Oracle Linux 8 BaseOS Latest (x86_64)                                                                                                 31 MB/s |  81 MB     00:02
Oracle Linux 8 Application Stream (x86_64)                                                                                            26 MB/s |  64 MB     00:02
Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)                                                            28 MB/s | 102 MB     00:03
Last metadata expiration check: 0:00:12 ago on Wed 23 Oct 2024 01:43:50 AM KST.
Package nfs-utils-1:2.3.3-41.el8.x86_64 is already installed.
Dependencies resolved.
=====================================================================================================================================================================
 Package                             Architecture                     Version                                      Repository                                   Size
=====================================================================================================================================================================
Upgrading:
 nfs-utils                           x86_64                           1:2.3.3-59.0.1.el8                           ol8_baseos_latest                           514 k
 
Transaction Summary
=====================================================================================================================================================================
Upgrade  1 Package
 
Total download size: 514 k
Downloading Packages:
nfs-utils-2.3.3-59.0.1.el8.x86_64.rpm                                                                                                1.1 MB/s | 514 kB     00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                1.1 MB/s | 514 kB     00:00
warning: /var/cache/dnf/ol8_baseos_latest-e4c6155830ad002c/packages/nfs-utils-2.3.3-59.0.1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY
Oracle Linux 8 BaseOS Latest (x86_64)                                                                                                3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0xAD986DA3:
 Userid     : "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
 Fingerprint: 76FD 3DB1 3AB6 7410 B89D B10E 8256 2EA9 AD98 6DA3
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                             1/1
  Running scriptlet: nfs-utils-1:2.3.3-59.0.1.el8.x86_64                                                                                                         1/1
  Running scriptlet: nfs-utils-1:2.3.3-59.0.1.el8.x86_64                                                                                                         1/2
  Upgrading        : nfs-utils-1:2.3.3-59.0.1.el8.x86_64                                                                                                         1/2
  Running scriptlet: nfs-utils-1:2.3.3-59.0.1.el8.x86_64                                                                                                         1/2
  Running scriptlet: nfs-utils-1:2.3.3-41.el8.x86_64                                                                                                             2/2
  Cleanup          : nfs-utils-1:2.3.3-41.el8.x86_64                                                                                                             2/2
  Running scriptlet: nfs-utils-1:2.3.3-41.el8.x86_64                                                                                                             2/2
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-5.4.17-2102.201.3.el8uek.x86_64.conf:6: hwcap directive ignored
 
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-5.4.17-2102.201.3.el8uek.x86_64.conf:6: hwcap directive ignored
 
  Verifying        : nfs-utils-1:2.3.3-59.0.1.el8.x86_64                                                                                                         1/2
  Verifying        : nfs-utils-1:2.3.3-41.el8.x86_64                                                                                                             2/2
 
Upgraded:
  nfs-utils-1:2.3.3-59.0.1.el8.x86_64
 
Complete!

 

 

nfs 공유할 폴더 생성 및 샘플 파일 삽입

1
2
3
# mkdir -p /nfsshare
# chmod 777 /nfsshare/
# cp /etc/redhat-release /nfsshare/

 

 

/etc/exports 파일에 공유할 디렉토리명 입력

1
2
# vi /etc/exports
/nfsshare 192.168.137.19(rw,no_root_squash,sync)

 

 

nfs 서비스 재기동 후 활성화

1
2
3
# systemctl restart nfs-server
# systemctl enable nfs-server
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.

 

 

아래 명령어 입력시 어떤 디렉토리를 공유하는지 확인 가능함

1
2
# exportfs -v
/nfsshare       192.168.137.19(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

현재 /nfsshare 폴더가 192.168.137.19 서버에 공유되고 있음

 

 

2. 클라이언트 서버 설정
nfs-utils 패키지 설치

1
# dnf install -y nfs-utils

 

 

rpc 서비스 시작 확인

1
2
3
4
5
6
7
8
9
10
11
12
# systemctl status rpcbind
● rpcbind.service - RPC Bind
   Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2024-10-15 18:47:27 KST; 4 weeks 1 days ago
     Docs: man:rpcbind(8)
 Main PID: 918 (rpcbind)
    Tasks: 1 (limit: 50432)
   Memory: 1.3M
   CGroup: /system.slice/rpcbind.service
           └─918 /usr/bin/rpcbind -w -f
 
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

 

 

stop 상태라면 기동

1
2
# systemctl start rpcbind
# systemctl enable rpcbind

 

 

nfs 서버 공유 상태 확인

1
2
3
# showmount -e 192.168.137.50
Export list for 192.168.137.50:
/nfsshare 192.168.137.19

현재 192.168.137.50 서버에서 192.168.137.19 서버에 대해 /nfsshare 라는 폴더를 공유중임

 

 

nfs 마운트용 디렉토리 생성

1
# mkdir -p /shareddir

 

 

nfs 디렉토리 마운트

1
# mount -t nfs 192.168.137.50:/nfsshare /shareddir

 

 

마운트 확인

1
2
3
4
5
6
7
8
9
10
11
12
13
# df -h
df: /run/user/0/gvfs: Transport endpoint is not connected
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                  3.9G     0  3.9G   0% /dev
tmpfs                     3.9G     0  3.9G   0% /dev/shm
tmpfs                     3.9G  402M  3.5G  11% /run
tmpfs                     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/ol-root        46G   40G  6.7G  86% /
/dev/sda1                 471M  235M  237M  50% /boot
/dev/sdb1                  60G   37G   24G  62% /oradata1
tmpfs                     794M   44K  794M   1% /run/user/0
tmpfs                     794M     0  794M   0% /run/user/54321
192.168.137.50:/nfsshare   52G   13G   40G  24% /shareddir  <<

정상적으로 마운트됨

 

 

파일 읽고 써지는지 확인

1
2
3
4
5
6
7
8
9
10
11
12
# cd /shareddir
# touch 1 2 3
# ls
1  2  3  redhat-release
# ls > 1
# cat 1
1
2
3
redhat-release
# cat redhat-release
Red Hat Enterprise Linux release 8.4 (Ootpa)

정상적으로 읽고 써짐

 

 

fstab에도 마운트 내용 추가
(재기동 이후에도 mount 되어있게 하려면 fstab에 등록 필요)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# cat /etc/fstab
 
#
/etc/fstab
# Created by anaconda on Sun Jan  5 00:07:22 2020
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/ol-root     /                       xfs     defaults        0 0
UUID=dba63100-3189-40ad-bdb0-eabc1716d21a /boot                   xfs     defaults        0 0
/dev/mapper/ol-swap     swap                    swap    defaults        0 0
/dev/sdb1               /oradata1               xfs     defaults        0 0
192.168.137.50:/nfsshare /shareddir             nfs     defaults        0 0  <<<---- 추가

 

 

참조 : 

https://mcc96.tistory.com/41
https://pinetreeday.tistory.com/179