注:本文主要的讲解的是crmsh 4.crmsh 简单说明 注:以下上pacemaker 1.1.8的更新说明,最重要的我用红色标记出来,从pacemaker 1.1.8开始,crm sh 发展成一个独立项目,pacemaker中不再提供,说明我们安装好pacemaker后,是不会有crm这个命令行模式的资源管理器的。 [root@node1 ~]# cd /usr/share/doc/pacemaker-1.1.8/ [root@node1 pacemaker-1.1.8]# ll 总用量 132 -rw-r--r-- 1 root root 1102 2月 22 13:05 AUTHORS -rw-r--r-- 1 root root 109311 2月 22 13:05 ChangeLog -rw-r--r-- 1 root root 18046 2月 22 13:05 COPYING [root@node1 pacemaker-1.1.8]# vim ChangeLog * Thu Sep 20 2012 Andrew Beekhof Pacemaker-1.1.8-1 - Update source tarball to revision: 1a5341f - Statistics: Changesets: 1019 Diff: 2107 files changed, 117258 insertions(+), 73606 deletions(-) - All APIs have been cleaned up and reduced to essentials - Pacemaker now includes a replacement lrmd that supports systemd and upstart agents - Config and state files (cib.xml, PE inputs and core files) have moved to new locations - The crm shell has become a separate project and no longer included with Pacemaker (crm shell 已成为一个独立的项目,pacemaker中一再提供) - All daemons/tools now have a unified set of error codes based on errno.h (see crm_error) [root@node1 ~]# crm crmadmin crm_diff crm_failcount crm_mon crm_report crm_shadow crm_standby crm_verify crm_attribute crm_error crm_master crm_node crm_resource crm_simulate crm_ticket
注:大家可以看到,安装好pacemaker后,就没有crm shell命令行工具,我们得单独安装。下面我们就来说说怎么安装crm sh 5.安装crmsh资源管理工具 (1).crmsh官方网站 https://savannah.nongnu.org/forum/forum.php?forum_id=7672 (2).crmsh下载地址 http://download.openSUSE.org/repositories/network:/ha-clustering:/Stable/ (3).安装crmsh [root@node1 ~]# rpm -ivh crmsh-1.2.6-0.rc2.2.1.x86_64.rpm warning: crmsh-1.2.6-0.rc2.2.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 7b709911: NOKEY error: Failed dependencies: pssh is needed by crmsh-1.2.6-0.rc2.2.1.x86_64 python-dateutil is needed by crmsh-1.2.6-0.rc2.2.1.x86_64 python-lxml is needed by crmsh-1.2.6-0.rc2.2.1.x86_64
注:大家可以看到年缺少依赖包,我们先用yum安装依赖包 [root@node1 ~]# yum install -y python-dateutil python-lxml [root@node1 ~]# rpm -ivh crmsh-1.2.6-0.rc2.2.1.x86_64.rpm --nodeps warning: crmsh-1.2.6-0.rc2.2.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 7b709911: NOKEY Preparing... ########################################### [100%] 1:crmsh ########################################### [100%] [root@node1 ~]# crm #安装好后出现一个crm命令,说明安装完成 crm crm_attribute crm_error crm_master crm_node crm_resource crm_simulate crm_ticket crmadmin crm_diff crm_failcount crm_mon crm_report crm_shadow crm_standby crm_verify [root@node1 ~]# crm #输入crm命令,进入资源配置模式 Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) crm(live)# help #查看一下帮助 This is crm shell, a Pacemaker command line interface. Available commands: cib manage shadow CIBs resource resources management configure CRM cluster configuration node nodes management options user preferences history CRM cluster history site Geo-cluster support ra resource agents information center status show cluster status help,? show help (help topics for list of topics) end,cd,up go back one level quit,bye,exit exit the program crm(live)#
注:到此准备工作全部完成,下面我们来具体配置一下高可用的Web集群,在配置之前我们还得简的说明一下,crm sh 如何使用! 6.crmsh使用说明 注:简单说明一下,其实遇到一个新命令最好的方法就是man一下!简单的先熟悉一下这个命令,然后再慢慢尝试。 [root@node1 ~]# crm #输入crm命令,进入crm sh 模式 Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) crm(live)# help #输入help查看一下,会出下很多子命令 This is crm shell, a Pacemaker command line interface. Available commands: cib manage shadow CIBs resource resources management configure CRM cluster configuration node nodes management options user preferences history CRM cluster history site Geo-cluster support ra resource agents information center status show cluster status help,? show help (help topics for list of topics) end,cd,up go back one level quit,bye,exit exit the program crm(live)# configure #输入configure就会进入,configure模式下, crm(live)configure# #敲两下tab键就会显示configure下全部命令 ? default-timeouts group node rename simulate bye delete help op_defaults role template cd edit history order rsc_defaults up cib end load primitive rsc_template upgrade cibstatus erase location property rsc_ticket user clone exit master ptest rsctest verify collocation fencing_topology modgroup quit save xml colocation filter monitor ra schema commit graph ms refresh show crm(live)configure# help node #输入help加你想了解的任意命令,就会显示该命令的使用帮助与案例 The node command describes a cluster node. Nodes in the CIB are commonly created automatically by the CRM. Hence, you should not need to deal with nodes unless you also want to define node attributes. Note that it is also possible to manage node attributes at the `node` level. Usage: ............... node [:] [attributes = [=...]] [utilization = [=...]] type :: normal | member | ping ............... Example: ............... node node1 node big_node attributes memory=64 ............... 注:好了,简单说明就到这,其实就是一句话,不会的命令help一下。下面我们开始配置,高可用的Web集群。
7.crmsh 配置高可用的Web集群 (1).查看一下默认配置 [root@node1 ~]# crm Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) crm(live)# configure crm(live)configure# show node node1.test.com node node2.test.com property $id="cib-bootstrap-options" \ dc-version="1.1.8-7.el6-394e906" \ cluster-infrastructure="classic openais (with plugin)" \ expected-quorum-votes="2" \
(2).检测一下配置文件是否有错 crm(live)# configure crm(live)configure# verify crm_verify[5202]: 2011/06/14_19:10:38 ERROR: unpack_resources: Resource start-up disabled since no STONITH resources have been defined crm_verify[5202]: 2011/06/14_19:10:38 ERROR: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option crm_verify[5202]: 2011/06/14_19:10:38 ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity 注:说我们的STONITH resources没有定义,因我们这里没有STONITH设备,所以我们先关闭这个属性 crm(live)configure# property stonith-enabled=false crm(live)configure# show node node1.test.com node node2.test.com property $id="cib-bootstrap-options" \ dc-version="1.1.8-7.el6-394e906" \ cluster-infrastructure="classic openais (with plugin)" \ expected-quorum-votes="2" \ stonith-enabled="false" crm(live)configure# verify #现在已经不报错
(3).查看当前集群系统所支持的类型 crm(live)# ra crm(live)ra# classes lsb ocf / heartbeat pacemaker RedHat service stonith
(5).查看某个资源代理的配置方法 crm(live)ra# info ocf:heartbeat:IPaddr Manages virtual IPv4 addresses (portable version) (ocf:heartbeat:IPaddr) This script manages IP alias IP addresses It can add an IP alias, or remove one. Parameters (* denotes required, [] the default): ip* (string): IPv4 address The IPv4 address to be configured in dotted quad notation, for example "192.168.1.1". nic (string, [eth0]): Network interface The base network interface on which the IP address will be brought online. If left empty, the script will try and determine this from the routing table. Do NOT specify an alias interface in the form eth0:1 or anything here; rather, specify the base interface only. Prerequisite: There must be at least one static IP address, which is not managed by the cluster, assigned to the network interface. If you can not assign any static IP address on the interface, :
(6).接下来要创建的web集群创建一个IP地址资源(IP资源是主资源,我们查看一下怎么定义一个主资源) crm(live)# configure crm(live)configure# primitive usage: primitive {[:[:]]|@} [params = [=...]] [meta = [=...]] [utilization = [=...]] [operations id_spec [op op_type [=...] ...]] crm(live)configure# primitive vip ocf:heartbeat:IPaddr params ip=192.168.18.200 nic=eth0 cidr_netmask=24 #增加一个VIP资源 crm(live)configure# show #查看已增加好的VIP,我用红色标记了一下 node node1.test.com node node2.test.com primitive vip ocf:heartbeat:IPaddr \ params ip="192.168.18.200" nic="eth0" cidr_netmask="24" property $id="cib-bootstrap-options" \ dc-version="1.1.8-7.el6-394e906" \ cluster-infrastructure="classic openais (with plugin)" \ expected-quorum-votes="2" \ stonith-enabled="false" crm(live)configure# verify #检查一下配置文件有没有错误 crm(live)configure# commit #提交配置的资源,在命令行配置资源时,只要不用commit提交配置好资源,就不会生效,一但用commit命令提交,就会写入到cib.xml的配置文件中 crm(live)# status #查看一下配置好的资源状态,有一个资源vip,运行在node1上 Last updated: Thu Aug 15 14:24:45 2013 Last change: Thu Aug 15 14:21:21 2013 via cibadmin on node1.test.com Stack: classic openais (with plugin) Current DC: node1.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 1 Resources configured. Online: [ node1.test.com node2.test.com ] vip (ocf::heartbeat:IPaddr): Started node1.test.com
测试,停止node1节点上的corosync,可以看到node1已经离线 [root@node2 ~]# ssh node1 "service corosync stop" Signaling Corosync Cluster Engine (corosync) to terminate: [确定] Waiting for corosync services to unload:..[确定] [root@node2 ~]# crm status Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) Last updated: Thu Aug 15 14:29:04 2013 Last change: Thu Aug 15 14:21:21 2013 via cibadmin on node1.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition WITHOUT quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 1 Resources configured. Online: [ node2.test.com ] OFFLINE: [ node1.test.com ]
片刻之后,集群就会在目前仍在运行中的节点node2上启动此资源了,如下所示: [root@node2 ~]# crm status Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) Last updated: Thu Aug 15 14:38:23 2013 Last change: Thu Aug 15 14:37:08 2013 via cibadmin on node2.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition WITHOUT quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 1 Resources configured. Online: [ node2.test.com ] OFFLINE: [ node1.test.com ] vip (ocf::heartbeat:IPaddr): Started node2.test.com
好了,验正完成后,我们正常启动node1.test.com [root@node2 ~]# ssh node1 "service corosync start" Starting Corosync Cluster Engine (corosync): [确定] [root@node2 ~]# crm status Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) Last updated: Thu Aug 15 14:39:45 2013 Last change: Thu Aug 15 14:37:08 2013 via cibadmin on node2.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 1 Resources configured. Online: [ node1.test.com node2.test.com ] vip (ocf::heartbeat:IPaddr): Started node2.test.com [root@node2 ~]#
首先可以使用如下命令查看lsb类型的httpd资源的语法格式: crm(live)# ra crm(live)ra# info lsb:httpd start and stop Apache HTTP Server (lsb:httpd) The Apache HTTP Server is an efficient and extensible \ server implementing the current HTTP standards. Operations' defaults (advisory minimum): start timeout=15 stop timeout=15 status timeout=15 restart timeout=15 force-reload timeout=15 monitor timeout=15 interval=15
来查看一下资源状态 [root@node1 ~]# crm status Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) Last updated: Thu Aug 15 14:55:04 2013 Last change: Thu Aug 15 14:54:14 2013 via cibadmin on node1.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 2 Resources configured. Online: [ node1.test.com node2.test.com ] vip (ocf::heartbeat:IPaddr): Started node2.test.com httpd (lsb:httpd): Started node1.test.com
再次查看一下资源状态 [root@node1 ~]# crm status Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) Last updated: Thu Aug 15 15:33:09 2013 Last change: Thu Aug 15 15:32:28 2013 via cibadmin on node1.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 2 Resources configured. Online: [ node1.test.com node2.test.com ] Resource Group: webservice vip (ocf::heartbeat:IPaddr): Started node2.test.com httpd (lsb:httpd): Started node2.test.com
大家可以看到,所有资源全部运行在node2上,下面我们来测试一下
下面我们模拟故障,测试一下 crm(live)# node crm(live)node# ? cd end help online show status-attr attribute clearstate exit list quit standby up bye delete fence maintenance ready status utilization crm(live)node# standby [root@node1 ~]# crm status Cannot change active directory to /var/lib/pacemaker/cores/root: No such file or directory (2) Last updated: Thu Aug 15 15:39:05 2013 Last change: Thu Aug 15 15:38:57 2013 via crm_attribute on node2.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 2 Resources configured. Node node2.test.com: standby Online: [ node1.test.com ] Resource Group: webservice vip (ocf::heartbeat:IPaddr): Started node1.test.com httpd (lsb:httpd): Started node1.test.com [root@node1 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:91:45:90 inet addr:192.168.18.201 Bcast:192.168.18.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe91:4590/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:408780 errors:0 dropped:0 overruns:0 frame:0 TX packets:323137 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:60432533 (57.6 MiB) TX bytes:57541647 (54.8 MiB) eth0:0 Link encap:Ethernet HWaddr 00:0C:29:91:45:90 inet addr:192.168.18.200 Bcast:192.168.18.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:6525 errors:0 dropped:0 overruns:0 frame:0 TX packets:6525 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:882555 (861.8 KiB) TX bytes:882555 (861.8 KiB) [root@node1 ~]# netstat -ntulp | grep :80 tcp 0 0 :::80 :::* LISTEN 16603/httpd
因此,对于前述的vip和httpd可能会运行于不同节点的问题,可以通过以下命令来解决: crm(live)configure# colocation httpd-with-ip INFUNTY: httpd vip crm(live)configure# show node node1.test.com node node2.test.com \ attributes standby="off" primitive httpd lsb:httpd primitive vip ocf:heartbeat:IPaddr \ params ip="192.168.18.200" nic="eth0" cidr_netmask="24" colocation httpd-with-ip INFUNTY: httpd vip property $id="cib-bootstrap-options" \ dc-version="1.1.8-7.el6-394e906" \ cluster-infrastructure="classic openais (with plugin)" \ expected-quorum-votes="2" \ stonith-enabled="false" \ no-quorum-policy="ignore" \ last-lrm-refresh="1376553277" rsc_defaults $id="rsc-options" \ resource-stickiness="100" crm(live)configure# show xml [root@node2 ~]# crm_mon Last updated: Thu Aug 15 16:12:18 2013 Last change: Thu Aug 15 16:12:05 2013 via cibadmin on node1.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 2 Resources configured. Online: [ node1.test.com node2.test.com ] vip (ocf::heartbeat:IPaddr): Started node1.test.com httpd (lsb:httpd): Started node1.test.com
大家可以看到,所有资源全部运行在node1上,下面我们来测试访问一下
模拟一下故障,再进行测试 crm(live)# node crm(live)node# standby crm(live)node# show node1.test.com: normal standby: on node2.test.com: normal standby: off [root@node2 ~]# crm_mon Last updated: Thu Aug 15 16:14:33 2013 Last change: Thu Aug 15 16:14:23 2013 via crm_attribute on node1.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 2 Resources configured. Node node1.test.com: standby Online: [ node2.test.com ] vip (ocf::heartbeat:IPaddr): Started node2.test.com httpd (lsb:httpd): Started node2.test.com
[root@node2 ~]# crm_mon Last updated: Thu Aug 15 17:03:20 2013 Last change: Thu Aug 15 17:02:44 2013 via cibadmin on node1.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 3 Resources configured. Online: [ node1.test.com node2.test.com ] Resource Group: webservice vip (ocf::heartbeat:IPaddr): Started node1.test.com nfs (ocf::heartbeat:Filesystem): Started node1.test.com httpd (lsb:httpd): Started node1.test.com
(5).最后我们模拟一下资源故障 crm(live)# node crm(live)node# standby crm(live)node# show node1.test.com: normal standby: on node2.test.com: normal [root@node2 ~]# crm_mon Last updated: Thu Aug 15 17:05:52 2013 Last change: Thu Aug 15 17:05:42 2013 via crm_attribute on node1.test.com Stack: classic openais (with plugin) Current DC: node2.test.com - partition with quorum Version: 1.1.8-7.el6-394e906 2 Nodes configured, 2 expected votes 3 Resources configured. Node node1.test.com: standby Online: [ node2.test.com ] Resource Group: webservice vip (ocf::heartbeat:IPaddr): Started node2.test.com nfs (ocf::heartbeat:Filesystem): Started node2.test.com httpd (lsb:httpd): Started node2.test.com
1、java.lang.IllegalStateException: Class invariant violation
at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:199)at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
at o
hadoop jps出现process information unavailable提示解决办法
jps时出现如下信息:
3019 -- process information unavailable3053 -- process information unavailable2985 -- process information unavailable2917 --
<?php
class Image{
private $path;
function __construct($path='./'){
$this->path=rtrim($path,'/').'/';
}
//水印函数,参数:背景图,水印图,位置,前缀,TMD透明度
public function water($b,$l,$pos