node1 $ sudo gluster peer status
Number of Peers: 1
Hostname: node2.cluster.local
Uuid: c4ff108d-0682-43b2-bc0c-311a0417fae2
State: Peer in Cluster (Connected)
Other names:
192.168.10.11
node2 $ sudo gluster peer status
Number of Peers: 1
Hostname: node1.cluster.local
Uuid: 6375e3c2-4f25-42de-bbb6-ab6a859bf55f
State: Peer in Cluster (Connected)
Other names:
192.168.10.10
이제 2개의 복제본으로 볼륨을 생성할 수 있습니다:
$ sudo gluster volume create volume1 replica 2 node1.cluster.local:/data/glusterfs/volume1/brick0/ node2.cluster.local:/data/glusterfs/volume1/brick0/
Replica 2 volumes are prone to split-brain. Use Arbiter or Replica 3 to avoid this. See: https://docs.gluster.org/en/latest/Administrator-Guide/Split-brain-and-ways-to-deal-with-it/.
Do you still want to continue?
(y/n) y
volume create: volume1: success: please start the volume to access data
참고
위 명령이 말하듯이, 2노드 클러스터는 split brain에 대해 최선의 아이디어가 아닙니다. 하지만 우리의 테스트 플랫폼 목적에는 이러한 복제본이 충분합니다.
$ sudo gluster volume status
Status of volume: volume1
Gluster process TCP Port RDMA Port Online Pid
------------------------------------------------------------------------------
Brick node1.cluster.local:/data/glusterfs/v
olume1/brick0 49152 0 Y 1210
Brick node2.cluster.local:/data/glusterfs/v
olume1/brick0 49152 0 Y 1135
Self-heal Daemon on localhost N/A N/A Y 1227
Self-heal Daemon on node2.cluster.local N/A N/A Y 1152
Task Status of Volume volume1
------------------------------------------------------------------------------
There are no active volume tasks
$ sudo gluster volume info
Volume Name: volume1
Type: Replicate
Volume ID: f51ca783-e815-4474-b256-3444af2c40c4
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node1.cluster.local:/data/glusterfs/volume1/brick0
Brick2: node2.cluster.local:/data/glusterfs/volume1/brick0
Options Reconfigured:
cluster.granular-entry-heal: on
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off
상태는 "Started"이어야 합니다.
이제 볼륨에 대한 액세스를 약간 제한할 수 있습니다:
$ sudo gluster volume set volume1 auth.allow 192.168.10.*
추가 저장소를 구성할 필요가 없습니다. 클라이언트는 이미 기본 저장소에 포함되어 있습니다.
파일을 만들고 클러스터의 모든 노드에 있는지 확인합니다:
클라이언트에서:
sudo touch /data/test
두 서버 모두에서:
$ ll /data/glusterfs/volume1/brick0/
total 0
-rw-r--r--. 2 root root 0 Feb 3 19:21 test
잘 작동합니다! 그러나 노드 1이 실패하는 경우 어떻게 될까요? 원격 액세스를 마운트할 때 지정된 노드입니다.
노드 1을 중지해 봅시다:
$ sudo shutdown -h now
노드2의 상태를 확인합니다:
$ sudo gluster peer status
Number of Peers: 1
Hostname: node1.cluster.local
Uuid: 6375e3c2-4f25-42de-bbb6-ab6a859bf55f
State: Peer in Cluster (Disconnected)
Other names:
192.168.10.10
[antoine@node2 ~]$ sudo gluster volume status
Status of volume: volume1
Gluster process TCP Port RDMA Port Online Pid
------------------------------------------------------------------------------
Brick node2.cluster.local:/data/glusterfs/v
olume1/brick0 49152 0 Y 1135
Self-heal Daemon on localhost N/A N/A Y 1152
Task Status of Volume volume1
------------------------------------------------------------------------------
There are no active volume tasks
현재 저장소가 없지만, CentOS가 GlusterFS에 대해 가진 보관된 저장소를 사용하면 여전히 작동합니다. 설치와 유지 관리가 꽤 쉽습니다. 명령 줄 도구를 사용하는 것은 매우 간단한 과정입니다. GlusterFS를 사용하면 데이터 저장과 중복성을 위한 고가용성 클러스터를 생성하고 유지 관리하는 데 도움이 됩니다. GlusterFS와 도구 사용에 대한 자세한 정보는 공식 설명서 페이지에서 찾을 수 있습니다.