pacemaker搭建集群
#以node01為例修改主機名
#node02需要同樣的配置
[[email protected] ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.5 node01
10.10.10.6 node02
#關閉防火墻以及SElinux
#node02需要同樣配置
[[email protected] ~]# systemctl stop firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[[email protected] ~]# setenforce 0
[[email protected] ~]# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config
#配置pacemaker的EPEL源
#node02需要同樣配置
[[email protected] ~]# cat /etc/yum.repos.d/pacemaker.repo
[pacemaker]
name=pacemaker
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=0
#下載pacemaker安裝包
#node02需要同樣配置
[[email protected] ~]# yum install pacemaker pcs resource-agents -y
#配置節點之間認證
#node02需要同樣配置
[[email protected] ~]# ssh-keygen -t rsa -P ‘‘
[[email protected] ~]# ssh-copy-id node02
#修改pacemaker的用戶密碼(pacemaker使用的用戶是hacluster,軟件安裝完後用戶以添加)
#node02需要同樣配置
[[email protected] ~]# passwd hacluster
#啟動pcs服務
#node02需要同樣配置
[[email protected] ~]# systemctl restart pcsd
#設置節點認證
#只在node01操作,所有操作會自動同步到node02
[[email protected] ~]# pcs cluster auth node01 node02
Username: hacluster
Password:
node02: Authorized
node01: Authorized
#創建一個名為mycluster的集群,並將node01和node02加入到集群節點上
#只在node01操作,所有操作會自動同步到node02
[[email protected] ~]# pcs cluster setup --force --name mycluster node01 node02
Destroying cluster on nodes: node01, node02...
node01: Stopping Cluster (pacemaker)...
node02: Stopping Cluster (pacemaker)...
node01: Successfully destroyed cluster
node02: Successfully destroyed cluster
Sending cluster config files to the nodes...
node01: Succeeded
node02: Succeeded
Synchronizing pcsd certificates on nodes node01, node02...
node02: Success
node01: Success
Restarting pcsd on the nodes in order to reload the certificates...
node02: Success
node01: Success
#啟動集群
[[email protected] ~]# pcs cluster start --all
node01: Starting Cluster...
node02: Starting Cluster...
#查看集群狀態
[[email protected] ~]# pcs status
Cluster name: mycluster
WARNING: no stonith devices and stonith-enabled is not false
Stack: corosync
Current DC: node02 (version 1.1.15-11.el7_3.5-e174ec8) - partition with quorum
Last updated: Mon Sep 11 22:54:14 2017 Last change: Mon Sep 11 22:53:39 2017 by hacluster via crmd on node02
2 nodes and 0 resources configured
Online: [ node01 node02 ]
No resources
Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/disabled
本文出自 “openstack+kvm+linux” 博客,請務必保留此出處http://wangzhice.blog.51cto.com/12875919/1964517
pacemaker搭建集群