웹사이트 검색

CentOS 7의 GlusterFS를 사용한 고가용성 스토리지 - 두 스토리지 서버에서 미러링


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 센트OS 7.2
  • 센트OS 5.4

이 페이지에서

  1. 1 서문
  2. 2 추가 저장소 활성화\n
  3. 3 GlusterFS 서버 설정
  4. 4 GlusterFS 클라이언트 설정
  5. 5 테스트
  6. 6개의 링크

이 튜토리얼은 GlusterFS를 사용하는 두 개의 스토리지 서버(CentOS 7.2)로 고가용성 스토리지를 설정하는 방법을 보여줍니다. 각 스토리지 서버는 다른 스토리지 서버의 미러가 되며 파일은 두 스토리지 서버 간에 자동으로 복제됩니다. 클라이언트 시스템(CentOS 7.2도 마찬가지)은 마치 로컬 파일 시스템인 것처럼 스토리지에 액세스할 수 있습니다. GlusterFS는 여러 페타바이트로 확장할 수 있는 클러스터 파일 시스템입니다. Infiniband RDMA 또는 TCP/IP 상호 연결을 통해 다양한 스토리지 브릭을 하나의 대규모 병렬 네트워크 파일 시스템으로 통합합니다. 스토리지 브릭은 SATA-II RAID 및 Infiniband HBA가 있는 x86_64 서버와 같은 모든 상용 하드웨어로 만들 수 있습니다.

1 서문

이 튜토리얼에서는 3개의 시스템, 2개의 서버 및 클라이언트를 사용합니다.

  • 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/hosts
127.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-release
yum -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 update

3 GlusterFS 서버 설정

GlusterFS는 CentOS 스토리지 특별 관심 그룹의 저장소에서 사용할 수 있습니다. 다음 명령으로 저장소를 설치하십시오.

yum -y install centos-release-gluster

그런 다음 다음과 같이 GlusterFS 서버를 설치합니다.

yum -y install glusterfs-server

Gluster 데몬에 대한 시스템 시작 링크를 만들고 시작합니다.

systemctl enable glusterd.service
systemctl start glusterd.service

명령

glusterfsd --version

이제 방금 설치한 GlusterFS 버전(이 경우 3.7.12)이 표시되어야 합니다.

[ ~]# 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. <http://www.redhat.com/>
GlusterFS comes with ABSOLUTELY NO WARRANTY.
It is licensed to you under your choice of the GNU Lesser
General Public License, version 3 or any later version (LGPLv3
or later), or the GNU General Public License, version 2 (GPLv2),
in all cases as published by the Free Software Foundation.

방화벽을 사용하는 경우 TCP 포트 111, 24007, 24008, 24009-(24009 + 모든 볼륨의 브릭 수)가 server1.example.com 및 server2.example.com에서 열려 있는지 확인하십시오.

다음으로 신뢰할 수 있는 저장소 풀에 server2.example.com을 추가해야 합니다. GlusterFS 노드 사이 - 올바른 호스트 이름 또는 IP 주소를 사용하는지 확인하십시오):

server1.example.com에서 다음을 실행합니다.

gluster peer probe server2.example.com
[ ~]# gluster peer probe server2.example.com
peer probe: success.

신뢰할 수 있는 스토리지 풀의 상태는 이제 다음과 유사해야 합니다.

gluster peer status
[ ~]# gluster peer status
Number of Peers: 1
Hostname: server2.example.com
Uuid: 582e10da-aa1b-40b8-908c-213f16f57fe5
State: Peer in Cluster (Connected)

다음으로 server1.example.com 및 server2.example.com에 2개의 복제본이 있는 testvol이라는 공유를 생성합니다(이 경우 미러링을 설정하기 때문에 복제본의 수는 서버의 수와 같습니다). /data 디렉토리(존재하지 않는 경우 생성됨):

gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data force
[ ~]#

볼륨 시작:

gluster volume start testvol

결과는 다음과 같아야 합니다.

[ ~]#

위의 명령은 작업이 성공하지 못했음을 알려줄 수 있습니다.

[ ~]#

이 경우 출력을 확인해야 합니다...

netstat -tap | grep glusterfsd

두 서버 모두에서.

이렇게 출력이 된다면...

[ ~]#

... 모든 것이 정상이지만 출력이 없으면 ...

[ ~]#

... 해당 서버(이 경우 server2.example.com)에서 GlusterFS 데몬을 다시 시작합니다.

systemctl restart glusterd.service

그런 다음 출력을 확인하십시오 ...

netstat -tap | grep glusterfsd

... 해당 서버에서 다시 - 이제 다음과 같이 표시됩니다.

[ ~]#

이제 server1.example.com으로 돌아갑니다.

명령으로 볼륨의 상태를 확인할 수 있습니다.

gluster volume info

[[email ~]# 글러스터 볼륨 정보

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
[ ~]#

기본적으로 모든 클라이언트는 볼륨에 연결할 수 있습니다. client1.example.com(= 192.168.1.102)에만 액세스 권한을 부여하려면 다음을 실행하십시오.

gluster volume set testvol auth.allow 192.168.1.102

IP 주소(예: 192.168.*)에 와일드카드를 사용할 수 있으며 쉼표로 구분된 여러 IP 주소(예: 192.168.1.102,192.168.1.103)를 지정할 수 있습니다.

이제 볼륨 정보에 업데이트된 상태가 표시됩니다.

gluster volume info
[ ~]# 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:
auth.allow: 192.168.1.102
performance.readdir-ahead: on
[ ~]#

4 GlusterFS 클라이언트 설정

클라이언트에서 다음과 같이 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
[ ~]#

... 그리고...

df -h
[ ~]#

GlusterFS 공유를 클라이언트에 수동으로 마운트하는 대신 마운트 명령을 /etc/rc.local 파일에 추가합니다. 네트워크 파일 시스템에 필요한 네트워크가 가동된 후에 rc.local이 항상 실행되므로 /etc/fstab에 추가하지 않겠습니다.

/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

... 그리고...

mount

5 테스트

이제 GlusterFS 공유에 몇 가지 테스트 파일을 생성해 보겠습니다.

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
[ ~]

이제 server1.example.com을 종료하고 client1.example.com의 GlusterFS 공유에서 일부 파일을 추가/삭제합니다.

shutdown -h now
touch /mnt/glusterfs/test3
touch /mnt/glusterfs/test4
rm -f /mnt/glusterfs/test2

Glusterfs가 더 이상 server1에 도달할 수 없으면 server2로 전환하므로 명령을 실행하는 데 약간의 시간이 걸릴 수 있습니다. 여기서 우리는 server1이 오프라인일 때 데이터 저장소 공유에서 계속 작업할 수 있으므로 시스템의 내결함성을 볼 수 있습니다. 변경 사항은 server2.example.com의 /data 디렉토리에서 볼 수 있어야 합니다.

ls -l /data
[ ~]# 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 디렉토리를 살펴보겠습니다.

ls -l /data
[ ~]#

보시다시피 server1.example.com은 변경 사항을 자동으로 동기화했습니다. 변경 사항이 아직 동기화되지 않은 경우 수정하기 쉽습니다. client1.example.com의 GlusterFS 공유에서 읽기 명령을 호출하기만 하면 됩니다. 예를 들면 다음과 같습니다.

ls -l /mnt/glusterfs/
[ ~]#

이제 server1.example.com의 /data 디렉토리를 다시 살펴보고 변경 사항이 해당 노드에 복제되었는지 확인해야 합니다.

ls -l /data
[ ~]#

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/