部署红帽pcs高可用集群详解

在日常工作过程中 , 我们总是要求服务器永久在线能给我们提供服务 , 可是服务器总是要维护的 , 那应该怎么样才能做到永久在线呢 , 此时就需要服务器的高可用技术 , 而红帽系提供了packmarker的技术来实现 , 我们具体来看看如何部署一个高可用的Linux集群吧 。
软件安装在每个节点上部署以下软件
for ip in {nodea,nodeb,nodec,noded};do ssh root@"$ip" "yum install pcs fence-agents-all fence-agents-rht -y";done
部署红帽pcs高可用集群详解文章插图
启用并启动服务for ip in {nodea,nodeb,nodec,noded};do ssh root@"$ip" "systemctl enable pcsd;systemctl start pcsd";done
部署红帽pcs高可用集群详解文章插图
规范化用户名和密码Pcsd服务使用hacluster这个用户用来集群通信和配置 , 所以建议在所有节点上使用相同的密码
for ip in {nodea,nodeb,nodec,noded};do ssh root@"$ip" "echo redhat | passwd --stdin hacluster";done
部署红帽pcs高可用集群详解文章插图
开通防火墙规则for ip in {nodea,nodeb,nodec,noded};do ssh root@"$ip" "firewall-cmd --permanent --add-service=high-availability;firewall-cmd --reload";done
部署红帽pcs高可用集群详解文章插图
授权各个节点登陆到节点A上
pcs cluster auth nodea.cluster0.example.com nodeb.cluster0.example.com nodec.cluster0.example.com noded.cluster0.example.com -u hacluster -p redhat
部署红帽pcs高可用集群详解文章插图
部署集群pcs cluster setup --start --name bbs nodea.cluster0.example.com nodeb.cluster0.example.com nodec.cluster0.example.com noded.cluster0.example.com
部署红帽pcs高可用集群详解文章插图
配置fence 设备pcs stonith create fence_nodea fence_rht port="nodea.cluster0.example.com" pcmk_host_list="nodea.cluster0.example.com" ipaddr="classroom.example.com"
pcs stonith create fence_nodeb fence_rht port="nodeb.cluster0.example.com" pcmk_host_list="nodeb.cluster0.example.com" ipaddr="classroom.example.com"
pcs stonith create fence_nodec fence_rht port="nodec.cluster0.example.com" pcmk_host_list="nodec.cluster0.example.com" ipaddr="classroom.example.com"
pcs stonith create fence_noded fence_rht port="noded.cluster0.example.com" pcmk_host_list="noded.cluster0.example.com" ipaddr="classroom.example.com"
部署红帽pcs高可用集群详解文章插图
pcs stonith show
部署红帽pcs高可用集群详解文章插图
启用集群默认情况下 , 集群节点重启后不会自动加入集群 , 我们可以用pcs cluster enable --all来设置自动启动服务
pcs cluster enable --all
部署红帽pcs高可用集群详解文章插图
查看集群状态pcs cluster status
部署红帽pcs高可用集群详解文章插图


推荐阅读