这篇文章主要介绍Gluster集群高可用性配置和节点增删的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
一、Gluster高可用性配置
1、Gluster节点服务规划
#vi /etc/hosts
200.192.100.101 glusternode1 #节点1地址
200.192.100.102 glusternode2 #节点2地址
200.192.100.100 glustervip #gluster服务地址
在节点1,节点2上执行:
#mkdir /storage
#mount /dev/vg01/lvstorage /storage
2. 配置安装高可用性
在节点1,节点2上安装keepalived:
#yum install keepalived
#vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
vrrp_script chk_gluster {
script "/etc/keepalived/check_gluster.sh"
interval 2
global_defs {
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER #备服务器要改为BACKUP
interface eth0
virtual_router_id 101
priority 100 #备服务器优先级要降低
advert_int 1
authentication {
auth_type PASS
auth_pass Pass2020wd
}
track_script {
chk_gluster
}
virtual_ipaddress {
200.192.100.100/24
}
}
}
:wq
#vi /etc/keepalived/check_gluster.sh
#!/bin/bash
num=$(netstat -lnupt |grep glusterd | wc -l)
if [ $num -eq 0 ];then
systemctl start glusterd
gluster volume start storage force
if [ $(netstat -lnupt |grep glusterd | wc -l) -eq 0 ];then
systemctl stop keepalived
fi
fi
:wq
#给脚本权限
chmod +x /etc/keepalived/check_gluster.sh
3. 配置gluster分布式存储
在节点1上添加节点2: gluster peer probe glusternode2
在节点2上添加节点1: gluster peer probe glusternode1
查看节点状态
gluster peer status
建立复制卷:
#创建复制卷
gluster volume create storage replica 2 glusternode1:/storage glusternode2:storage
#启动卷storage
gluster volume start storage
#查看卷状态
gluster volume status
#查看卷信息
gluster volume info storage
4. 启动高可用性,通过gluster服务地址挂载卷
在节点1,2上执行
systemctl enable keepalived
systemctl start keepalived
mount -t glusterfs glustervip:/storage /home/data
二、Gluster节点故障处理
1. 假设glusternode1故障
ip -a|grep 200.192.100.100
gluster volume status #查看状态发现glusternode1已经断开连接
#先去掉glusternode1上的brick
gluster volume remove-brick iso replica 1 glusternode1:/storage force
gluster volume status
gluster peer status
gluster peer detach glusternode1 #将glusternode1节点去掉
gluster peer status
gluster volume status
gluster peer probe glusternode1 #添加节点
gluster peer status
#将节点的brick重新加入
gluster volume add-brick iso replica 2 glusternode1:/storage force
gluster volume status
以上是“Gluster集群高可用性配置和节点增删的示例分析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注天达云行业资讯频道!