[iyunv@node1 ~]# service corosync start
Starting Corosync Cluster Engine (corosync): [ OK ]
查看corosync引擎是否正常启动
[iyunv@node1 ~]# grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/cluster/corosync.log
Apr 20 23:48:45 corosync [MAIN ] Corosync Cluster Engine ('1.4.1'): started and ready to provide service.
Apr 20 23:48:45 corosync [MAIN ] Successfully read main configuration file '/etc/corosync/corosync.conf'.
Apr 20 23:48:45 corosync [MAIN ] Corosync Cluster Engine exiting with status 8 at main.c:1797.
Apr 21 00:01:53 corosync [MAIN ] Corosync Cluster Engine ('1.4.1'): started and ready to provide service.
Apr 21 00:01:53 corosync [MAIN ] Successfully read main configuration file '/etc/corosync/corosync.conf'.
查看初始化成员节点通知是否正常
[iyunv@node1 ~]# grep "TOTEM" /var/log/cluster/corosync.log
Apr 21 00:01:53 corosync [TOTEM ] Initializing transport (UDP/IP Multicast).
Apr 21 00:01:53 corosync [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/SHA1HMAC (mode 0).
Apr 21 00:01:53 corosync [TOTEM ] The network interface [192.168.1.200] is now up.
Apr 21 00:01:53 corosync [TOTEM ] A processor joined or left the membership and a new membership was formed.
查看启动过程中是否有错误产生,下面表示在以后pacemaker在以后将不再作为corosync的插件提供 ,建议使用cman作为集群的基础架构,可以安全忽略
[iyunv@node1 ~]# grep "ERROR" /var/log/cluster/corosync.log
Apr 21 00:01:53 corosync [pcmk ] ERROR: process_ais_conf: You have configured a cluster using the Pacemaker plugin for Corosync. The plugin is not supported in this environment and will be removed very soon.
Apr 21 00:01:53 corosync [pcmk ] ERROR: process_ais_conf: Please see Chapter 8 of 'Clusters from Scratch' (http://www.clusterlabs.org/doc) for details on using Pacemaker with CMAN
Apr 21 00:02:17 [2461] node1.wangfeng7399.com pengine: notice: process_pe_message: Configuration ERRORs found during PE processing. Please run "crm_verify -L" to identify issues
如果上面命令执行均没有问题,接着可以执行如下命令启动node2上的corosync
[iyunv@node1 ~]# pcs status
Cluster name:
WARNING: no stonith devices and stonith-enabled is not false
Last updated: Mon Apr 21 00:12:53 2014
Last change: Mon Apr 21 00:10:41 2014 via crmd on node1.wangfeng7399.com
Stack: classic openais (with plugin)
Current DC: node1.wangfeng7399.com - partition with quorum
Version: 1.1.10-14.el6_5.2-368c726
2 Nodes configured, 2 expected votes
0 Resources configured
Online: [ node1.wangfeng7399.com node2.wangfeng7399.com ]
Full list of resources:
我们已经看到我们的两个节点
4、配置集群的工作属性,禁用stonith(生产环境中应该提供stonith)
corosync默认启用了stonith,而当前集群并没有相应的stonith设备,因此此默认配置目前尚不可用,这可以通过如下命令验正:
[iyunv@node1 ~]# 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
我们里可以通过如下命令先禁用stonith:
[iyunv@node1 ~]# pcs property set stonith-enabled=false
使用如下命令查看当前的配置信息:
[iyunv@node1 corosync]# pcs status
Cluster name:
Last updated: Mon Apr 21 00:50:03 2014
Last change: Mon Apr 21 00:49:53 2014 via cibadmin on node1.wangfeng7399.com
Stack: classic openais (with plugin)
Current DC: node2.wangfeng7399.com - partition with quorum
Version: 1.1.10-14.el6_5.2-368c726
2 Nodes configured, 2 expected votes
2 Resources configured
Online: [ node1.wangfeng7399.com node2.wangfeng7399.com ]
Full list of resources:
WebIP (ocf::heartbeat:IPaddr2): Started node2.wangfeng7399.com
webserver (lsb:httpd): Started node2.wangfeng7399.com
7.1.2 顺序约束
通过pcs命令定义顺序约束的语法如下所示:
order [action] then [action] [options]
因此,要确保WebServer在某节点启动之前得先启动WebIP可以使用如下命令实现:
[iyunv@node1 corosync]# pcs constraint order WebIP then webserver
Adding WebIP webserver (kind: Mandatory) (Options: first-action=start then-action=start)
查看定义的结果:
[iyunv@node1 corosync]# pcs constraint order
Ordering Constraints:
start WebIP then start webserver
7.1.3 位置约束
由于HA集群本身并不强制每个节点的性能相同或相近,所以,某些时候我们可能希望在正常时服务总能在某个性能较强的节点上运行,这可以通过位置约束来实现。通过pcs命令定义位置约束的语法略复杂些,如下所述。
倾向运行于某节点:
location prefers ...
倾向离开某节点:
location avoids ...
通过约束分数来定义其倾向运行的节点:
location add
例如:如果期望WebServer倾向运行于node1.wangfeng7399.com的分数为1000,则可以使用类似如下命令实现:
[iyunv@node1 corosync]# pcs constraint location add webservce_on_node1 webserver node1.wangfeng7399.com 1000
可以看到我们的资源运行状态
[iyunv@node1 corosync]# pcs status
Cluster name:
Last updated: Mon Apr 21 00:59:44 2014
Last change: Mon Apr 21 00:59:24 2014 via cibadmin on node1.wangfeng7399.com
Stack: classic openais (with plugin)
Current DC: node2.wangfeng7399.com - partition with quorum
Version: 1.1.10-14.el6_5.2-368c726
2 Nodes configured, 2 expected votes
2 Resources configured
Online: [ node1.wangfeng7399.com node2.wangfeng7399.com ]
Full list of resources:
WebIP (ocf::heartbeat:IPaddr2): Started node1.wangfeng7399.com
webserver (lsb:httpd): Started node1.wangfeng7399.com
最终的配置结果如下所示: