0.实验前的环境检查与配置
[student@workstation ~]$ lab georeplication setup
1.开启共享
gluster volume set all cluster.enable-shared-storage enable开启共享存储功能。gluster volume list all查看存储卷情况。
[root@servera ~]# gluster volume set all cluster.enable-shared-storage enable
volume set: success
[root@servera ~]# gluster volume list all
gluster_shared_storage
mastervol
2.配置密钥
ssh-keygen -f ~/.ssh/id_rsa -N ''生成私钥。ssh-copy-id -i ~/.ssh/id_rsa.pub geoaccount@servere生成公钥并传递给servere的geoaccount账户。
[root@servera ~]# ssh-keygen -f ~/.ssh/id_rsa -N ''
Generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
78:49:00:2b:c7:bb:27:c8:ee:fc:d1:22:3b:66:98:d4 root@servera.lab.example.com
The key's randomart image is:
+--[ RSA 2048]----+
| ... |
| . . . |
| . + . |
| o . o . |
| . . . S |
| o E o . |
|.o+ = o |
|oo+o = |
| +=o. |
+-----------------+
[root@servera ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub geoaccount@servere
The authenticity of host 'servere (172.25.250.14)' can't be established.
ECDSA key fingerprint is f3:3a:20:c9:5a:cc:cc:f0:44:f7:00:90:03:18:b1:8d.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
geoaccount@servere's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'geoaccount@servere'"
and check to make sure that only the key(s) you wanted were added.
3.配置权限
mkdir -m 0711 /var/mountbroker-root设置掩码。semanage fcontext -a -e /home /var/mountbroker-root设置安全上下文。 restorecon -Rv /var/mountbroker-root递归安全上下文。
[root@servere ~]# mkdir -m 0711 /var/mountbroker-root
[root@servere ~]# semanage fcontext -a -e /home /var/mountbroker-root
[root@servere ~]# restorecon -Rv /var/mountbroker-root
restorecon reset /var/mountbroker-root context unconfined_u:object_r:var_t:s0->unconfined_u:object_r:home_root_t:s0
4.配置存储选项功能
gluster system:: execute mountbroker opt mountbroker-root /var/mountbroker-root将mountbroker-root指定目录/var/mountbroker-root。gluster system:: execute mountbroker user geoaccount slavevol设置用户geoaccount。gluster system:: execute mountbroker opt geo-replication-log-group geogroup设置组。gluster system:: execute mountbroker opt rpc-auth-allow-insecure on开启特定规则定义功能。systemctl restart glusterd重启服务。
[root@servere ~]# gluster system:: execute mountbroker opt mountbroker-root /var/mountbroker-root
Command executed successfully.
[root@servere ~]# gluster system:: execute mountbroker user geoaccount slavevol
Command executed successfully.
[root@servere ~]# gluster system:: execute mountbroker opt geo-replication-log-group geogroup
Command executed successfully.
[root@servere ~]# gluster system:: execute mountbroker opt rpc-auth-allow-insecure on
Command executed successfully.
[root@servere ~]# systemctl restart glusterd
5.配置关联
gluster system:: execute gsec_create创建在节点之间使用的密钥对。gluster volume geo-replication mastervol geoaccount@servere::slavevol create push-pem推送密钥。/usr/libexec/glusterfs/set_geo_rep_pem_keys.sh geoaccount mastervol slavevol移动密钥到指定位置。gluster volume geo-replication mastervol geoaccount@servere::slavevol config use_meta_volume true确认主从节点之间的连接。gluster volume geo-replication mastervol geoaccount@servere::slavevol start启动主从节点之间的服务。
[root@servera ~]# gluster system:: execute gsec_create
Common secret pub file present at /var/lib/glusterd/geo-replication/common_secret.pem.pub
[root@servera ~]# gluster volume geo-replication mastervol geoaccount@servere::slavevol create push-pem
Creating geo-replication session between mastervol & geoaccount@servere::slavevol has been successful
[root@servere ~]# /usr/libexec/glusterfs/set_geo_rep_pem_keys.sh geoaccount mastervol slavevol
Successfully copied file.
Command executed successfully.
You have mail in /var/spool/mail/root
[root@servera ~]# gluster volume geo-replication mastervol geoaccount@servere::slavevol config use_meta_volume true
geo-replication config updated successfully
[root@servera ~]# gluster volume geo-replication mastervol geoaccount@servere::slavevol start
Starting geo-replication session between mastervol & geoaccount@servere::slavevol has been successful
6.状态确认
gluster volume geo-replication status确认主从节点的状态信息。ls /bricks/brick-e1/brick | tail -5查看文件同步信息。
[root@servera ~]# gluster volume geo-replication status
MASTER NODE MASTER VOL MASTER BRICK SLAVE USER SLAVE SLAVE NODE STATUS CRAWL STATUS LAST_SYNCED
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
servera.lab.example.com mastervol /bricks/brick-a1/brick geoaccount ssh://geoaccount@servere::slavevol servere Active Hybrid Crawl N/A
serverb.lab.example.com mastervol /bricks/brick-b1/brick geoaccount ssh://geoaccount@servere::slavevol servere Passive N/A N/A
[root@servere ~]# ls /bricks/brick-e1/brick | tail -5
file95
file96
file97
file98
file99
7.任务测评
lab georeplication grade进行测评。主要是测评主节点的副本信息状态和灾复系统的用户信息。
[student@workstation ~]$ lab georeplication grade
Grading the student's work:
· Checking replication status for mastervol................... PASS
· Checking user for geo-replication........................... PASS
Overall lab grade.............................................. PASS