Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- FTP
- aws cloud shcool 8
- Ebs
- load balancer
- SAA-C03
- vmware
- aws saa
- EC2 인스턴스
- GNS3
- linux
- ELB
- CentOS
- DNS
- ALB
- AWS 자격증
- aws iam
- NAT
- aws SAA-c03
- aws cloud
- Firewall
- docker
- AWS
- tftp
- IAM
- SAA
- Troubleshooting
- aws cloud school
- EC2
- 네트워크
- vyos
Archives
- Today
- Total
나의 공부기록
[VMware] 07. NFS(Network File System) 본문
NFS(Network File System)
- Default Port : 2049
- RPC Port : 111
- 추가적으로 데이터를 송수신할 때, 랜덤 하게 Port 부여
- Client가 여러 개 있을 수 있기 때문
- /remout에 존재하는 것은 실제가 아니며, 원본은 /shared에 보관됨
- /shared에 접근한다는 개념으로 이해하면 좋음(공유보다는)
Mount(마운트)
- 물리적 장치를 찾아가기 위한 논리적 경로 생성(연결)
- 디스크 드라이브 = Mount Point
- 최상위 디렉토리를 통해 특정 장치에 연결
- 윈도우 = Plug&Play를 통해 장치를 연결하기만 하면, 그 장치에 접근하기 위한 논리적 경로가 자동으로 생성되어 매칭
- 리눅스 = 수동으로 마운트 해줘야
Mount 확인 방법
[root@client ~]#df -h
- df : disk free
- -h(human readable) : 인간이 읽기 편하게 보여줌
- /dev/mapper/centos-root : device(스토리지) - 최상위 디렉토리에 마운트 확인 가능
NFS 이점
- 중앙 집중식 데이터 관리 가능
- 자원을 하나로 관리해서 자원 관리가 수월
- 고가용성 지원(High Available)
- Client가 문제가 발생했을 때도, 원본 데이터에는 문제 발생 ❌ ➡️ Migration(이주) 가능
- 유연성과 확장성
- 파일 시스템을 공유함으로써 여러 클라이언트에서 쉽게 접근 가능
- 새로운 클라이언트를 추가하거나 파일 시스템 확장이 손쉬움
- 효율적인 스토리지 사용
- 클라이언트 장치에서 로컬 스토리지 공간을 절약 가능
- 데이터가 중앙 서버에만 저장 ➡️ 스토리지 자원의 중복 ⬇️
- 플랫폼 간 호환성
- NFS는 다양한 운영체제에서 지원 가능 = 이기종 시스템 간에도 파일 공유 가능
✅ 메모리
주기억장치
- 대표적인 장치 : RAM
- 휘발성이며, 가격이 비쌈
- 보조 기억장치에 비해 처리 속도가 빠름
보조기억장치
- 비휘발성이며, 가격이 저렴함
가상 메모리
- 주기억장치의 용량보다 많은 용량을 처리해야할 때, 보조기억장치의 일부 용량을 활용 ➡️ SWAP
# 가상메모리 확인하는 명령어
[root@client ~]# cat /etc/fstab
NFS 실습 환경
NFS 설정 - Server/Client
1. 초기 설정
- 방화벽 해제
[root@srv3 ~]#systemctl stop firewalld
[root@srv3 ~]#systemctl disable firewalld
- SELinux 해제
- -i : 영구적으로
- s : 대체
- g : 모두
- 구분자는 다른 특수문자(/, @,#,$ 등)으로 대체 가능
- sed 사용 이유
- 쉘 스크립트 처리와 동시에 selinux를 끄기 위해서 사용
- 이런 형태로 자주 사용됨
# 1. SELINUX 설정 확인
[root@srv3 ~]#cat /etc/selinux/config
# 2. 변경하고자 하는 내용 확인 후, 치환
[root@srv3 ~]#sed -i s/<변경전>/<변경후>/g <파일경로>
[root@srv3 ~]#sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
- 외부 통신 확인
- showmount 명령어를 사용할 때, 외부 통신이 전제 조건임
[root@srv1 ~]#ping 8.8.8.8
- 레포지토리 수정
- nfs-utils 패키지를 다운로드 하기 위해서, 레포지토리 수정 필요
cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
- nfs-utils 패키지 설치
- 우분투의 경우, Client는 nfs-common 패키지 설치
[root@srv1 ~]#yum install -y nfs-utils
[root@srv1 ~]#yum install -y nfs-common
- 재부팅
[root@srv1 ~]#reboot
[root@srv1 ~]#init 6
NFS Server 설정
1.원본 경로 생성
[root@srv3 ~]#mkdir <경로>
[root@srv3 ~]#mkdir /shared
2. 원본 경로 생성 확인
- ls -al / : /(최상위 디렉토리)의 모든 정보 확인
- grep shared : shared를 포함한 것 모두
[root@srv3 ~]#ls -al / | grep shared
[실행 결과]
drwxr-xr-x 2 root root 6 Jan 20 21:10 shared
💡리눅스 권한
더보기

drwxr-xr-x 2 root root 6 Jan 20 21:10 shared
- r : read(읽기) / w : write(쓰기) / x : execute(실행)
- 1 : 문자 🅾️ / 0 : 문자 ❌ d : 디렉토리

1) rwx = 소유자 = 111(7)
2) r-x = 소유자가 속한 그룹 = 101(5)
3) r-x = 그 외= 101(5)
1번 root : 소유자(사용자)
2번 root : 소유자가 속해있는 그룹
3. 권한 수정
# 권한 수정
[root@srv3 ~]#chmod -R <권한> <대상 경로>
[root@srv3 ~]#chmod -R 777 /shared
chmod(change mode) : 권한 변경
-R : 하위 디렉토리 포함
777 : 모든 권한 부여 -> rwx = 111 = 7
[실행 결과]
drwxrwxrwx 2 root root 6 Jan 20 21:10 share
4. nfs로 공유할 대상 설정
- /etc/exports : nsf 공유 대상 설정 파일
- showmount -e ➡️ 나 자신 / showmount -e <IP> ➡️ IP가 nfs 해주는 경로 확인
# 1. nfs 대상 설정
[root@srv3 ~]#vi /etc/exports
[/etc/exports 설정 내용]
/shared 211.183.3.*(rw)
# /shared라는 디렉토리를 NFS로 공유
# 대상 : 211.183.3.*는 읽고 쓸수 있는 권한(rw)
# 권한 : 외부에서 접근하는 사용자의 권한 부여
# 2. nfs 설정값 반영
[root@srv3 ~]#exportfs -r
-r : 다시 반영
# nfs-server 데몬 재시작 & 설정 저장
[root@srv3 ~]#systemctl restart nfs-server
[root@srv3 ~]#systemctl enable nfs-server
#공유 대상 확인 명령어
#공유 여부 확인
[root@srv3 ~]#showmount -e
[실행 결과]
Export list for srv3:
/shared 211.183.3.*
NFS Client 설정
1. 공유 상황 확인
- 외부 통신이 된다는 것이 전제 조건
[root@srv1 ~]# showmount -e <원본IP>
[root@srv1 ~]# showmount -e 211.183.3.30
Export list for 211.183.3.30:
/shared 211.183.3.*
2. mount point 생성
- mount point
- 원본 경로에 접속할 수 있는 경로
- Client의 공유 폴더
- /remote(client) ➡️ /shared(server)
[root@srv1 ~]# mkdir <mount point>
[root@srv1 ~]# mkdir /remote
3. mount 설정
- -t : type
- 만약 기존에 mount를 한 디렉토리가 존재했다면, 새로운 디렉토리에 mount를 하게 되면, 새로운 디렉토리로 변경됨
[root@srv1 ~]#mount -t nfs <nfs-server IP>:<원본경로> <mount point>
[root@srv1 ~]#mount -t nfs 211.183.3.30:/shared /remote
# 바로 끝나면 잘 실행된 것!
4. 원본 파일 생성
[ NFS Client ]
# mount point 확인
[root@srv1 ~]# ls <mount point>
[root@srv1 ~]# ls /remote
# 파일 생성
[root@srv1 ~]# touch /remote/test.txt
[root@srv1 ~]# echo 'testfile' > /remote/test.txt
[root@srv1 ~]# cat /remote/test.txt
testfile
# mount 확인
[root@srv1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 898M 0 898M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 9.4M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 17G 1.5G 16G 9% /
/dev/sda1 1014M 151M 864M 15% /boot
tmpfs 182M 0 182M 0% /run/user/0
211.183.3.30:/shared 50G 1.5G 49G 3% /remote
[ NFS Server ]
- 원본 경로에서 확인 가능
#NFS - Server에서 파일 확인
[root@srv3 ~]# cat /shared/test.txt
testfile
5. 재부팅 후에도 mount 유지 설정
- /etc/fstab - File System TABle
- 재부팅 시, mount 유지되도록 하는 설정 파일
- 내용 잘 못 기입 시, mount가 안 될 수 있음
# 재부팅 후, mount 확인
# mount가 풀린 걸 볼 수 있음
[root@srv1 ~]# df -h |grep remote
[root@srv1 ~]# vi /etc/fstab
[/etc/fstab 수정 내용]
#해당 내용 추가
211.183.3.30:/shared /remote nfs defaults 0 0
< 원본 경로> <mount point> <type> <파일 시스템 옵션> <dump 실행 여부> <파일시스템 점검 여부>
- 0 : 점검 X
6. 마운트 해제 방법
# 마운트 해제
[root@srv1 ~]#umount /remote
실습
우리 회사는 rapa.com 도메인을 갖고 있다.
➡️ dns 구성할 때, rapa.com 영역 생성
회사는 www.rapa.com으로 접속 가능한 웹 서버와 nfs.rapa.com으로 접속 가능한 nfs 서버, 이를 위한 dns.rapa.com도 갖고 있다.
➡️ 내부/외부 분리
➡️서버 3개 생성
➡️ 영문 주소 -> DNS
1. client가 /remotestg 경로를 통해 nfs 서버에 접근하여 /originstg의 파일에 접근 가능하도록 구성하시오.
➡️ client에 /remotestg 설정, nfs 서버에 /originstg 설정
2. nfs-server의 /web이라는 경로에 있는 index.html을 서버에 배포하고 싶다. www.rapa.com으로 접속했을 때, 간단한 index.html 파일이 뜨도록 구성하세요. index.html 파일의 내용은 'aws 8 파이팅!'으로 하시오.
nfs-server의 /web이라는 경로에 있는 파일인 index.html은 언제든지 변경 가능하고, 실시간으로 변경 사항이 웹 서버에 적용되어야 한다.
➡️ web 서버의 httpd 설정 수정 (/var/www/html ➡️ /remoteweb)
1. 서버 기초 설정
더보기
- 방화벽 해제
[root@web ~]# systemctl stop firewalld
[root@web ~]# systemctl disable firewalld
- SELinux 해제
[root@web ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
- 레포지토리 해제
cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
- 재부팅
[root@web ~]# init 6
2. R1 라우터 설정
더보기
- 인터페이스의 IP 설정
R1(config)#int f0/0
R1(config-if)#ip add 10.10.4.250 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int f0/1
R1(config-if)#ip add 211.183.3.250 255.255.255.0
R1(config-if)#no sh
- NAT 설정(PAT)
R1(config-if)#int f0/0
R1(config-if)#ip nat inside
R1(config-if)#int f0/1
R1(config-if)#ip nat outside
R1(config-if)#access-list 1 per 10.10.4.0 0.0.0.255
R1(config)#ip nat inside source list 1 int f0/1 overload
- default-route 설정 & 외부통신 확인(내부 서버도 확인 필요)
R1(config)#ip route 0.0.0.0 0.0.0.0 211.183.3.2
R1(config)#do ping 8.8.8.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 44/63/92 ms
3. nfs 서버
더보기
- 외부 통신 확인
[root@nfs ~]# ping 8.8.8.8
- nfs-utils 패키지 설치
[root@nfs ~]# yum install -y nfs-utils
- bind & bind-utils 패키지 설치
[root@nfs ~]# yum install -y bind bind-utils
- 원본 경로 생성
# nfs 서버 - client
[root@nfs ~]# mkdir /originstg
# nfs 서버 - web 서버
[root@nfs ~]# mkdir /web
# 위의 코드와 동일
[root@nfs ~]# mkdir /originstg /web
- 권한 수정
[root@nfs ~]# chmod -R 777 /originstg
[root@nfs ~]# chmod -R 777 /web
- nfs로 공유할 대상 설정
- 영문 주소로 접근할 경우, 접근 못하는 경우가 발생할 수 있기 때문에 *(rw)으로 설정
[root@nfs ~]# vi /etc/exports
[추가할 내용]
/originstg *(rw)
/web *(rw)
- nfs 설정 값 적용
[root@nfs ~]# exportfs -r
- nfs-server 재시작
[root@nfs ~]# systemctl restart nfs-server
[root@nfs ~]# systemctl enable nfs-server
- 공유 대상 확인
[root@nfs ~]# showmount -e
Export list for nfs:
/web *
/originstg *
4. web 서버
- SELINUX 설정해제 하지 않으면 httpd 접근 거부함
- 내부의 자원이 아니기 때문에, httpd가 접근을 허용하지 않음
- SELINUX = disabled로 설정해야 함
더보기
- httpd & nfs-utils & bind-utils 패키지 설치
[root@web ~]# yum install -y httpd nfs-utils bind-utils
- httpd 설정 파일 수정
- DocumentRoot와 <Directory ""> 수정
[root@web ~]# vi /etc/httpd/conf/httpd.conf
[수정 내용]
DocumentRoot "/remoteweb"
#
# Relax access to content within /var/www.
#
<Directory "/remoteweb">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
- mount point에 index.html 파일 생성
[root@web ~]# touch /remoteweb/index.html
[root@web ~]# echo 'aws8 파이팅!' > /remoteweb/index.html
# httpd 재시작
[root@web ~]# systemctl restart httpd
- DNS 수정
[root@web ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
DNS1 = "10.10.4.53"
- mount point 생성
[root@web ~]# mkdir /remoteweb
[root@web ~]# mount -t nfs nfs.rapa.com:/web /remoteweb
- 접속 시도
[root@web ~]# curl 10.10.4.80
aws8 파이팅!
# client 접속 확인
5. dns 서버
더보기
- bind & bind-utils 패키지 설정
[root@dns~]# yum install -y bind bind-utils
- /etc/named.conf 수정
[root@dns ~]# vi /etc/named.conf
[수정 내용]
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
- 영역(zone) 생성
- 대문자 G : 편집기 맨 밑으로 이동
[root@dns ~]# vi /etc/named.rfc1912.zones
[추가할 내용]
zone "rapa.com" IN {
type master;
file "rapa.com.db";
allow-update { none; };
};
- zone 파일 생성
[root@dns ~]# vi /var/named/rapa.com.db
[추가할 내용]
$TTL 3H
@ SOA @ root (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS @
IN A 10.10.4.53
dns IN A 10.10.4.53
www IN A 10.10.4.80
nfs IN A 10.10.4.100
- 설정 저장 및 확인
[root@dns ~]# systemctl restart named
[root@dns ~]# cat /etc/resolv.conf
# 나의 기능 확인
[root@dns ~]# nslookup rapa.com
Server: 10.10.4.53
Address: 10.10.4.53#53
Name: rapa.com
Address: 10.10.4.53
[root@dns ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
[수정할 내용]
DNS1="10.10.4.53"
6. client 서버
더보기
- bind-utils & nfs-utils 패키지 설치
[root@client ~]# yum install -y bind-utils nfs-utils
- 영문 주소로 mount 설정
# DNS 서버 변경
[root@client ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
DNS1 = "10.10.4.53"
[root@client ~]# mkdir /remotestg
[root@client ~]# mount -t nfs nfs.rapa.com:/originstg /remotestg
# mount point 연결 확인
[root@client ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 898M 0 898M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 9.5M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 17G 1.5G 16G 9% /
/dev/sda1 1014M 151M 864M 15% /boot
nfs.rapa.com:/originstg 50G 1.5G 49G 3% /remotestg
tmpfs 182M 0 182M 0% /run/user/0
'CS > Linux' 카테고리의 다른 글
[VMware]09-1. PxE Server - KickStart 파일 만드는법 (0) | 2025.01.23 |
---|---|
[VMware] 08. FTP & TFTP & PxE (0) | 2025.01.23 |
[VMware] 06. DNS(Domain Name System) (0) | 2025.01.21 |
[VMware] 04. 정적 웹 서버 - template 적용 & 실습 (0) | 2025.01.10 |
[VMware]03. Xshell & SELinux & 정적 웹 서버 & GNS3 (0) | 2025.01.08 |