스토리지 설정 · 8 min read · Nov 29, 2025
CentOS 7에서 GlusterFS로 고가용성 스토리지 설정 - 두 스토리지 서버 간 미러링
이 튜토리얼에서는 GlusterFS를 사용하는 두 개의 스토리지 서버(CentOS 7.2)로 고가용성 스토리지를 설정하는 방법을 보여줍니다. 각 스토리지 서버는 다른 스토리지 서버의 미러가 되며, 파일은 두 스토리지 서버 간에 자동으로 복제됩니다. 클라이언트 시스템(CentOS 7.2)도 로컬 파일 시스템처럼 스토리지에 접근할 수 있습니다. GlusterFS는 여러 페타바이트로 확장할 수 있는 클러스터 파일 시스템입니다. 이는 Infiniband RDMA 또는 TCP/IP 상의 다양한 스토리지 브릭을 하나의 대규모 병렬 네트워크 파일 시스템으로 집계합니다. 스토리지 브릭은 SATA-II RAID 및 Infiniband HBA가 장착된 x86_64 서버와 같은 일반 하드웨어로 구성될 수 있습니다.
1 사전 참고
이 튜토리얼에서는 세 개의 시스템, 두 개의 서버 및 하나의 클라이언트를 사용합니다:
- server1.example.com: IP 주소 192.168.0.100 (서버)
- server2.example.com: IP 주소 192.168.0.101 (서버)
- client1.example.com: IP 주소 192.168.0.102 (클라이언트)
세 시스템 모두 서로의 호스트 이름을 확인할 수 있어야 합니다. DNS를 통해 이를 수행할 수 없는 경우, /etc/hosts 파일을 편집하여 모든 세 시스템에서 다음과 같이 보이도록 해야 합니다:
nano /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.0.100 server1.example.com server1
192.168.0.101 server2.example.com server2
192.168.0.102 client1.example.com client1
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6(다음 설정에서 호스트 이름 대신 IP 주소를 사용할 수도 있습니다. IP 주소를 사용하려는 경우, 호스트 이름이 확인될 수 있는지 여부에 대해 걱정할 필요가 없습니다.)
2 추가 리포지토리 활성화
server1.example.com/server2.example.com/client1.example.com:
먼저, 소프트웨어 패키지에 대한 GPG 키를 가져옵니다:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*그런 다음 CentOS 시스템에서 EPEL 7 리포지토리를 활성화합니다:
yum -y install epel-releaseyum -y install yum-priorities/etc/yum.repos.d/epel.repo 파일을 편집합니다…
nano /etc/yum.repos.d/epel.repo… 그리고 [epel] 섹션에 priority=10을 추가합니다:
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
priority=10
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[...]그런 다음 시스템의 기존 패키지를 업데이트합니다:
yum -y update3 GlusterFS 서버 설정
server1.example.com/server2.example.com:
GlusterFS는 CentOS 스토리지 특별 관심 그룹의 리포지토리에서 사용할 수 있습니다. 다음 명령으로 리포지토리를 설치합니다:
yum -y install centos-release-gluster그런 다음 GlusterFS 서버를 다음과 같이 설치합니다:
yum -y install glusterfs-serverGluster 데몬의 시스템 시작 링크를 생성하고 시작합니다:
systemctl enable glusterd.service
systemctl start glusterd.service명령
glusterfsd --version이제 방금 설치한 GlusterFS 버전(이 경우 3.7.12)이 표시되어야 합니다:
[root@server1 ~]# glusterfsd --version
glusterfs 3.7.12 built on Jun 24 2016 14:11:19
Repository revision: git://git.gluster.com/glusterfs.git
Copyright (c) 2006-2013 Red Hat, Inc.
GlusterFS는 전혀 보증이 없습니다.
GNU 약소 일반 공중 라이선스 버전 3 또는 이후 버전(LGPLv3 또는 이후) 또는 GNU 일반 공중 라이선스 버전 2(GPLv2) 중 하나에 따라 귀하에게 라이선스가 부여됩니다.
모든 경우에 자유 소프트웨어 재단에서 발표한 라이선스입니다.방화벽을 사용하는 경우, TCP 포트 111, 24007, 24008, 24009-(모든 볼륨에 걸쳐 있는 브릭 수) 가 server1.example.com 및 server2.example.com에서 열려 있는지 확인하십시오.
다음으로, server2.example.com을 신뢰할 수 있는 스토리지 풀에 추가해야 합니다(모든 GlusterFS 구성 명령을 server1.example.com에서 실행하고 있지만, server2.example.com에서도 실행할 수 있습니다. 구성은 GlusterFS 노드 간에 복제되므로 올바른 호스트 이름이나 IP 주소를 사용해야 합니다):
server1.example.com:
server1.example.com에서 다음을 실행합니다:
gluster peer probe server2.example.com[root@server1 ~]# gluster peer probe server2.example.com
peer probe: success.신뢰할 수 있는 스토리지 풀의 상태는 이제 다음과 비슷해야 합니다:
gluster peer status[root@server1 ~]# gluster peer statusNumber of Peers: 1Hostname: server2.example.com
Uuid: 582e10da-aa1b-40b8-908c-213f16f57fe5
State: Peer in Cluster (Connected)다음으로, /data 디렉토리에서 두 개의 복제본을 가진 testvol이라는 공유를 생성합니다(이 경우 복제본의 수는 미러링을 설정하려고 하므로 서버 수와 같습니다):
gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data force[root@server1 ~]# gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data force
volume create: testvol: success: please start the volume to access data
[root@server1 ~]#볼륨을 시작합니다:
gluster volume start testvol결과는 다음과 같아야 합니다:
[root@server1 ~]# gluster volume start testvol
volume start: testvol: success
[root@server1 ~]#위 명령이 성공하지 않았다고 알려줄 수 있습니다:
[root@server1 ~]# gluster volume start testvol
Starting volume testvol has been unsuccessful
[root@server1 ~]#이 경우, 두 서버에서…
server1.example.com/server2.example.com:
netstat -tap | grep glusterfsd를 확인해야 합니다.
다음과 같은 출력이 나타나면…
[root@server1 ~]# netstat -tap | grep glusterfsd
tcp 0 0 0.0.0.0:49152 0.0.0.0:* LISTEN 22880/glusterfsd
tcp 0 0 server1.example.c:49152 server2.example.c:49148 ESTABLISHED 22880/glusterfsd
tcp 0 0 server1.example.c:49152 server1.example.c:49148 ESTABLISHED 22880/glusterfsd
tcp 0 0 server1.example.c:49150 server1.example.c:24007 ESTABLISHED 22880/glusterfsd
tcp 0 0 server1.example.c:49152 server2.example.c:49142 ESTABLISHED 22880/glusterfsd
tcp 0 0 server1.example.c:49152 server1.example.c:49149 ESTABLISHED 22880/glusterfsd
[root@server1 ~]#… 모든 것이 정상입니다. 그러나 출력이 없으면…
[root@server2 ~]# netstat -tap | grep glusterfsd
[root@server2 ~]#… 해당 서버(server2.example.com)에서 GlusterFS 데몬을 재시작해야 합니다:
server2.example.com:
systemctl restart glusterd.service그런 다음…
netstat -tap | grep glusterfsd를 다시 확인해야 합니다. 이제 다음과 같아야 합니다:
[root@server2 ~]# netstat -tap | grep glusterfsd
tcp 0 0 0.0.0.0:49152 0.0.0.0:* LISTEN 10971/glusterfsd
tcp 0 0 server2.example.c:49152 server1.example.c:49140 ESTABLISHED 10971/glusterfsd
tcp 0 0 server2.example.c:49152 server2.example.c:49149 ESTABLISHED 10971/glusterfsd
tcp 0 0 server2.example.c:49152 server2.example.c:49143 ESTABLISHED 10971/glusterfsd
tcp 0 0 server2.example.c:49152 server1.example.c:49142 ESTABLISHED 10971/glusterfsd
tcp 0 0 server2.example.c:49150 server2.example.c:24007 ESTABLISHED 10971/glusterfsd
[root@server2 ~]#이제 server1.example.com으로 돌아갑니다:
server1.example.com:
볼륨의 상태를 확인할 수 있는 명령은 다음과 같습니다:
gluster volume info[root@server1 ~]# gluster volume info
Volume Name: testvol
Type: Replicate
Volume ID: e1f825ca-c9d9-4eeb-b6c5-d62c4aa02376
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data
Brick2: server2.example.com:/data
Options Reconfigured:
performance.readdir-ahead: on
[root@server1 ~]#기본적으로 모든 클라이언트가 볼륨에 연결할 수 있습니다. client1.example.com(= 192.168.1.102)만 접근을 허용하려면 다음을 실행합니다:
gluster volume set testvol auth.allow 192.168.1.102IP 주소에 와일드카드를 사용할 수 있으며(예: 192.168.*) 여러 IP 주소를 쉼표로 구분하여 지정할 수 있습니다(예: 192.168.1.102,192.168.1.103).
이제 볼륨 정보는 업데이트된 상태를 보여야 합니다:
gluster volume info[root@server1 ~]# gluster volume infoVolume Name: testvol
Type: Replicate
Volume ID: e1f825ca-c9d9-4eeb-b6c5-d62c4aa02376
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data
Brick2: server2.example.com:/data
Options Reconfigured:
auth.allow: 192.168.1.102
performance.readdir-ahead: on
[root@server1 ~]#4 GlusterFS 클라이언트 설정
client1.example.com:
클라이언트에서 GlusterFS 클라이언트를 다음과 같이 설치할 수 있습니다:
yum -y install glusterfs-client그런 다음 다음 디렉토리를 생성합니다:
mkdir /mnt/glusterfs그게 전부입니다! 이제 다음 명령으로 GlusterFS 파일 시스템을 /mnt/glusterfs에 마운트할 수 있습니다:
mount.glusterfs server1.example.com:/testvol /mnt/glusterfs(위 명령에서 server1.example.com 대신 server2.example.com을 사용할 수도 있습니다!)
이제 다음의 출력에서 새로운 공유를 볼 수 있어야 합니다…
mount[root@client1 ~]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=930336k,nr_inodes=232584,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mapper/centos-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=188060k,mode=700)
server1.example.com:/testvol on /mnt/glusterfs type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
[root@client1 ~]#… 및…
df -h[root@client1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 28G 1.3G 27G 5% /
devtmpfs 909M 0 909M 0% /dev
tmpfs 919M 0 919M 0% /dev/shm
tmpfs 919M 8.6M 910M 1% /run
tmpfs 919M 0 919M 0% /sys/fs/cgroup
/dev/sda1 497M 192M 306M 39% /boot
tmpfs 184M 0 184M 0% /run/user/0
server1.example.com:/testvol 28G 12G 17G 41% /mnt/glusterfs
[root@client1 ~]#클라이언트에서 GlusterFS 공유를 수동으로 마운트하는 대신, /etc/rc.local 파일에 마운트 명령을 추가합니다. /etc/fstab에 추가하지 않는 이유는 rc.local이 항상 네트워크가 활성화된 후에 실행되기 때문입니다. 이는 네트워크 파일 시스템에 필요합니다.
/etc/rc.local을 열고 다음 줄을 추가합니다:
nano /etc/rc.local[...]
/usr/sbin/mount.glusterfs server1.example.com:/testvol /mnt/glusterfs(다시 말하지만, server1.example.com 대신 server2.example.com을 사용할 수 있습니다!)
수정된 /etc/rc.local이 작동하는지 테스트하려면 클라이언트를 재부팅합니다:
reboot재부팅 후, 다음의 출력에서 공유를 찾아야 합니다…
df -h… 및…
mount5 테스트
이제 GlusterFS 공유에 테스트 파일을 생성해 보겠습니다:
client1.example.com:
touch /mnt/glusterfs/test1
touch /mnt/glusterfs/test2이제 server1.example.com 및 server2.example.com의 /data 디렉토리를 확인해 보겠습니다. test1 및 test2 파일이 각 노드에 존재해야 합니다:
server1.example.com/server2.example.com:
ls -l /data[root@server1 ~]# ls -l /data
total 0
-rw-r--r--. 2 root root 0 Jul 1 2016 test1
-rw-r--r--. 2 root root 0 Jul 1 2016 test2
[root@server1 ~]이제 server1.example.com을 종료하고 client1.example.com에서 GlusterFS 공유에 파일을 추가/삭제합니다.
server1.example.com:
shutdown -h nowclient1.example.com:
touch /mnt/glusterfs/test3
touch /mnt/glusterfs/test4
rm -f /mnt/glusterfs/test2명령이 실행되는 데 시간이 걸릴 수 있습니다. GlusterFS가 server1에 더 이상 접근할 수 없을 때 server2로 전환하기 때문입니다. 우리는 서버1이 오프라인일 때도 데이터 저장소 공유에서 작업할 수 있는 시스템의 내결함성을 볼 수 있습니다. 변경 사항은 server2.example.com의 /data 디렉토리에서 확인할 수 있어야 합니다:
server2.example.com:
ls -l /data[root@server2 ~]# ls -l /data
total 8
-rw-r--r--. 2 root root 0 Jul 1 15:17 test1
-rw-r--r--. 2 root root 0 Jul 1 15:19 test3
-rw-r--r--. 2 root root 0 Jul 1 15:19 test4이제 server1.example.com을 다시 부팅하고 /data 디렉토리를 확인해 보겠습니다:
server1.example.com:
ls -l /data[root@server1 ~]# ls -l /data
total 8
-rw-r--r--. 2 root root 0 Jul 1 15:17 test1
-rw-r--r--. 2 root root 0 Jul 1 15:19 test2
[root@server1 ~]#보시다시피, server1.example.com은 변경 사항을 자동으로 동기화했습니다. 변경 사항이 아직 동기화되지 않은 경우, 클라이언트에서 GlusterFS 공유에 대한 읽기 명령을 호출하면 쉽게 해결할 수 있습니다. 예를 들어:
client1.example.com:
ls -l /mnt/glusterfs/[root@client1 ~]# ls -l /data
total 8
-rw-r--r--. 2 root root 0 Jul 1 15:17 test1
-rw-r--r--. 2 root root 0 Jul 1 15:19 test3
-rw-r--r--. 2 root root 0 Jul 1 15:19 test4
[root@server1 ~]#이제 server1.example.com의 /data 디렉토리를 다시 확인하면 변경 사항이 해당 노드에 복제된 것을 볼 수 있습니다:
server1.example.com:
ls -l /data[root@server1 ~]# ls -l /data
total 8
-rw-r--r--. 2 root root 0 Jul 1 15:17 test1
-rw-r--r--. 2 root root 0 Jul 1 15:19 test3
-rw-r--r--. 2 root root 0 Jul 1 15:19 test4
[root@server1 ~]#6 링크
- GlusterFS: http://www.gluster.org/
- GlusterFS 3.2 문서: http://download.gluster.com/pub/gluster/glusterfs/3.2/Documentation/AG/html/index.html
- CentOS: http://www.centos.org/
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.