标签:pacemaker
实验环境:server3:172.25.29.3
server4:172.25.29.4
server6:172.25.29.6
[root@server3 ~]#yum install -y pacemaker
[root@server3 ~]#cd /etc/corosync/
[root@server3 corosync]#cp corosync.conf.example corosync.conf
[root@server3 corosync]#vim corosync.conf
9 ringnumber: 0
10 bindnetaddr: 172.25.29.0
11 mcastaddr: 226.94.1.1
12 mcastport: 540529
13 ttl: 1
31 amf {
32 mode: disabled
33 }
34
35 service {
36 name: pacemaker
37 ver:0
38 }
[root@server3 corosync]#scp corosync.conf 172.25.29.4:/etc/corosync/
[root@server3 corosync]#/etc/init.d/corosync start (打开集群)
[root@server3 corosync]#crm_verify -LV
下载crmsh-1.2.6-0.rc2.2.1.x86_64.rpm pssh-2.3.1-2.1.x86_64.rpm
[root@server3~]#yum install -y crmsh-1.2.6-0.rc2.2.1.x86_64.rpm pssh-2.3.1-2.1.x86_64.rpm
[root@server3 corosync]#crm_verify -LV
[root@server3 corosync]#crm
crm(live)# node
crm(live)node# show
server3.example.com: normal
server4.example.com: normal
crm(live)node# cd
crm(live)# configure
crm(live)configure# show
node server3.example.com
node server4.example.com
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
crm(live)configure# property stonith-enabled=false
crm(live)configure#commit
crm(live)configure# primitive vip ocf:heartbeat:IPaddr2 params ip="172.25.29.100" cidr_netmask="32" op monitor interval="10s"
crm(live)configure# primitive mysite ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=1min
crm(live)configure#commit
crm(live)configure#edit (可以进去查看)
crm(live)configure#show
node server3.example.com
node server4.example.com
primitive mysite ocf:heartbeat:apache \
params configfile="/etc/httpd/conf/httpd.conf" \
op monitor interval="1min"
primitive vip ocf:heartbeat:IPaddr2 \
params ip="172.25.29.100" cidr_netmask="32" \
op monitor interval="10s"
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false"
[root@server3 ~]#cd /etc/httpd/conf
[root@server3 conf]#vim httpd.conf
921 <Location /server-status>
922 SetHandler server-status
923 Order deny,allow
924 Deny from all
925 Allow from 127.0.0.1
926 </Location>
@@@@@@
[root@server4 ~]#yum install -y pacemaker
[root@server4 ~]#cd /etc/corosync/
[root@server4 corosync]#ls
[root@server4 corosync]#/etc/init.d/corosync start
[root@server4 ~]#cd /etc/httpd/conf
[root@server4 conf]#vim httpd.conf
921 <Location /server-status>
922 SetHandler server-status
923 Order deny,allow
924 Deny from all
925 Allow from 127.0.0.1
926 </Location>
[root@server4 corosync]#crm_mon
vip (ocf::heartbeat:IPaddr2): Started serevr3.example.com
mysite (ocf::heartbeat:apache): Started server4.example.com
(当vip和mysite 没有在一台电脑上工作时)
@@@@@@@@@@@@@@@@@
[root@server3 corosync]#crm
crm(live)# configure
crm(live)configure# colocation apache-with-vip inf: mysite vip
crm(live)configure# commit
[root@server4 corosync]#crm_mon
vip (ocf::heartbeat:IPaddr2): Started serevr3.example.com
mysite (ocf::heartbeat:apache): Started server3.example.com
@@@@@@@@@@@@@@@@@@@
[root@server3 corosync]#/etc/init.d/corosync start
[root@server3 corosync]#crm
crm(live)# configure
crm(live)configure# property no-quorum-policy=ignore
crm(live)configure# property stonith-enabled=true
crm(live)configure# commit
crm(live)configure# bye
[root@server3 corosync]#/etc/init.d/corosync stop (服务转到server4上面)
[root@server3 corosync]#/etc/init.d/corosync start
[root@server3 corosync]#crm
crm(live)# configure
crm(live)configure# show
node server3.example.com
node server4.example.com
primitive mysite ocf:heartbeat:apache \
params configfile="/etc/httpd/conf/httpd.conf" \
op monitor interval="1min"
primitive vip ocf:heartbeat:IPaddr2 \
params ip="172.25.29.100" cidr_netmask="32" \
op monitor interval="1mins"
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="true
last-lrm-refresh="1474513359" \
no-quorum-policy="ignore"
[root@server3 corosync]# yum provides */fence_xvm
[root@server3 corosync]# stonith_admin -I
fence_xvm
fence_virt
fence_pcmk
fence_legacy
4 devices found
[root@server3 corosync]#crm
crm(live)# configure
crm(live)configure# cd
crm(live)# resource
crm(live)resource# show
vip (ocf::heartbeat:IPaddr2): Started
mysite (ocf::heartbeat:apache): Started
vmfence (stonith:fence_xvm): Stopped (vmfence 关闭)
crm(live)resource# start vmfence
crm(live)resource# cleanup vmfence
Cleaning up vmfence on server3.example.com
Cleaning up vmfence on server4.example.com
Waiting for 1 replies from the CRMd. OK
crm(live)resource# show (查看是否打开)
crm(live)resource# bye
[root@server3~]#stonith_admin -a fence_xvm -M
[root@server3 corosync]#crm
crm(live)# configure
crm(live)configure# primitive vmfence stonith:fence_xvm params pcmk_host_map=server3.example.com:vm3;server4.example.com:vm4 op monitor interval=1min
crm(live)configure#commit
[root@server4 corosync]#/etc/init.d/corosync start
[root@server4 corosync]#crm_mon
vip (ocf::heartbeat:IPaddr2): Started serevr4.example.com
mysite (ocf::heartbeat:apache): Started server4.example.com
vmfence (stonith:fence_xvm): Started server3.example.com
[root@server4 corosync]#/etc/init.d/httpd stop
[root@server4 corosync]#crm_mon (当关掉http时服务并没有发生掉转)
vip (ocf::heartbeat:IPaddr2): Started serevr4.example.com
mysite (ocf::heartbeat:apache): Started server4.example.com
vmfence (stonith:fence_xvm): Started server3.example.com
[root@server4 corosync]#ip addr del 172.25.29.100/32 dev eth0
(删掉虚拟IP让集群帮助调换服务)
[root@server4 corosync]#ip addr show (查看)
[root@server4 corosync]#crm_mon (此时服务发生改变)
vip (ocf::heartbeat:IPaddr2): Started serevr3.example.com
mysite (ocf::heartbeat:apache): Started server3.example.com
vmfence (stonith:fence_xvm): Started server4.example.com
[root@server3 corosync]#/etc/init.d/network stop
(用虚拟机查看验证服务跳转的效果)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
############集群共享储存################
[root@server6 ~]# yum install scsi-target-utils -y
[root@server6 ~]#chkconfig tgtd on
[root@server6 ~]#service tgtd start
[root@server6 ~]#dd if=/dev/zero of=/dev/vda bs=1024 count=1
[root@server6 ~]#/etc/init.d/tgtd start
[root@serevr6 ~]# vim /etc/tgt/targets.conf
38 <target iqn.2016-09.com.example:server.disk>
39 backing-store /dev/vda
40 initiator-address 172.25.29.3
41 initiator-address 172.25.29.4
42 </target>
[root@server6 ~]#tgt-admin -s (查看共享分区的地址)
@@@@@@@@@@@@@@@@@@@@
[root@server3 ~]#yum install iscsi-initiator-utils -y
[root@server3 ~]#chkconfig iscsi on
[root@server3 ~]#service iscsi start
[root@server3 ~]#/etc/init.d/iscsi start
[root@server3 ~]#fdisk -l (查看共享磁盘)(/dev/sdb)
[root@server3 ~]#fdisk -cu /dev/sdb (分出一个4G sdb1的分区)
[root@server3 ~]#mkfs.ext4 /dev/sda1
@@@@@@@@@@@@@@@@@(此时两个节点共享一个分区)
[root@server4 ~]#yum install iscsi-initiator-utils -y
[root@server4 ~]#chkconfig iscsi on
[root@server4 ~]#service iscsi start
[root@server4 ~]#/etc/init.d/iscsi start
[root@server4 ~]#fdisk -l (查看共享磁盘)
[root@server4 ~]#cat /proc/partitions (查看验证是否共享)
[root@server4 ~]#mount /dev/sda1 /mnt/
[root@server4 ~]#cd /mnt/
[root@server4 mnt]#vim index.html (添加测试页验证)
server3+serevr4
[root@server4 mnt]#cd
[root@server4 ~]#umount /mnt
@@@@@@@@@@@@@
[root@server3 corosync]#crm
crm(live)# configure
crm(live)configure# primitive webdata ocf:heartbeat:Filesystem params device=/dev/sdb1 directory=/var/www/html fstype=ext4 op monitor interval=1min
crm(live)configure#commit
crm(live)configure# show
(查看是否添加到文件里面)
[root@server4 corosync]#crm_mon
vip (ocf::heartbeat:IPaddr2): Started serevr3.example.com
mysite (ocf::heartbeat:apache): Started server3.example.com
vmfence (stonith:fence_xvm): Started server4.example.com
webdata (ocf::heartbeat:Filesystem): Started server4.example.com
[root@server3 corosync]#crm (当共享分区和vip,mysite 不同步时)
crm(live)# configure
crm(live)configure# group webgroup vip webdata mysite
crm(live)configure#commit
[root@server4 corosync]#crm_mon
vmfence (stonith:fence_xvm): Started server4.example.com
Resource Group: webgroup
vip (ocf::heartbeat:IPaddr2): Started serevr3.example.com
mysite (ocf::heartbeat:apache): Started server3.example.com
webdata (ocf::heartbeat:Filesystem): Started server3.example.com
[root@server4 ~]#mount /dev/sda1 /var/www/html
访问172.25.29.100:找到储存中共享的文件
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
标签:pacemaker
原文地址:http://12083916.blog.51cto.com/12073916/1859525