Restarting pcsd on the nodes in order to reload the certificates...
node02: Success
node01: Success
[iyunv@node01 ~]# pcs cluster start --all
node01: Starting Cluster...
node02: Starting Cluster...
#查看集群状态
[iyunv@node01 ~]# 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
Membership information
----------------------
Nodeid Votes Name
1 1 node01 (local)
2 1 node02
#查看状态是否正常
[iyunv@node01 ~]# crm_verify -L -V
error: unpack_resources: Resource start-up disabled since no STONITH resources have been defined
error: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option
error: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity
Errors found during check: config not valid
**发现报错了
#关闭报错信息
[iyunv@node01 ~]# pcs property set stonith-enabled=false
[iyunv@node01 ~]# vi /etc/httpd/conf/httpd.conf
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
#将apache加入集群
#只在node01操作,所有操作会自动同步到node02
[iyunv@node01 ~]# pcs resource create Web ocf:heartbeat:apache configfile=/etc/httpd/conf/httpd.conf statusurl="http://localhost/server-status" op monitor interval=1min
#设置apache的超时时间
##只在node01操作,所有操作会自动同步到node02
[iyunv@node01 ~]# pcs resource op defaults timeout=240s
#设置启动顺序
##只在node01操作,所有操作会自动同步到node02
[iyunv@node01 ~]# pcs constraint order ClusterIP then Web
Adding ClusterIP Web (kind: Mandatory) (Options: first-action=start then-action=start)
#查看集群状态
[iyunv@node01 ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: node01 (version 1.1.15-11.el7_3.5-e174ec8) - partition with quorum
Last updated: Tue Sep 12 16:06:59 2017 Last change: Tue Sep 12 16:06:49 2017 by root via cibadmin on node01
2 nodes and 2 resources configured
Online: [ node01 node02 ]
Full list of resources:
ClusterIP (ocf::heartbeat:IPaddr2): Started node01
Web (ocf::heartbeat:apache): Started node01
#我们宕掉node01,在node02上查看集群状态
[iyunv@node02 ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: node02 (version 1.1.15-11.el7_3.5-e174ec8) - partition with quorum
Last updated: Tue Sep 12 17:02:24 2017 Last change: Tue Sep 12 17:01:57 2017 by root via cibadmin on node01
2 nodes and 2 resources configured
Online: [ node02 ]
OFFLINE: [ node01 ]
Full list of resources:
ClusterIP (ocf::heartbeat:IPaddr2): Started node02
Web (ocf::heartbeat:apache): Started node02