從頭開始搭建集羣(二)

 從頭開始搭建集羣(二)

檢驗集羣的安裝

目錄

3.1. 檢驗Corosync的安裝  ..............................................................   27

3.2. 檢查Pacemaker的安裝  .............................................................   27

3.1.?檢驗Corosync的安裝 在第一個節點啓動Corosync:

[root@pcmk-1 ~]# /etc/init.d/corosync start

Starting Corosync Cluster Engine (corosync): [ OK ]

查看集羣是否正確啓動並且已經可以與其他節點建立集羣關係

[root@pcmk-1 ~]# grep -e "corosync.*network interface" -e "Corosync Cluster Engine" -e "Successfully read main

 configuration file" /var/log/messages

Aug 27 09:05:34 pcmk-1 corosync[1540]: [MAIN ?] Corosync Cluster Engine ('1.1.0'): started and ready to provide

 service.

Aug 27 09:05:34 pcmk-1 corosync[1540]: [MAIN ?] Successfully read main configuration file '/etc/corosync/

corosync.conf'.

[root@pcmk-1 ~]# grep TOTEM /var/log/messages

Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transport (UDP/IP).

Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/

SHA1HMAC (mode 0).

Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] The network interface [192.168.122.101] is now up.

Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] A processor joined or left the membership and a new membership

 was formed.

第一個節點正常以後,我們可以安全地啓動第二個節點。

[root@pcmk-1 ~]# ssh pcmk-2 -- /etc/init.d/corosync start

Starting Corosync Cluster Engine (corosync): [ OK ]

[root@pcmk-1 ~]#

檢查集羣關係有沒有正確建立:

[root@pcmk-1 ~]# grep TOTEM /var/log/messages

Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transport (UDP/IP).

Aug 27 09:05:34 pcmk-1 corosync[1540]: [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/

SHA1HMAC (mode 0).

Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] The network interface [192.168.122.101] is now up.

Aug 27 09:05:35 pcmk-1 corosync[1540]: [TOTEM ] A processor joined or left the membership and a new membership

 was formed.

Aug 27 09:12:11 pcmk-1 corosync[1540]: [TOTEM ] A processor joined or left the membership and a new membership

 was formed.

3.2.?檢查Pacemaker的安裝 現在我們已經確認Corosync正常,我們可以開始檢查其他部分是否正常.第?3?章?檢驗集羣的安裝

28

[root@pcmk-1 ~]# grep pcmk_startup /var/log/messages

Aug 27 09:05:35 pcmk-1 corosync[1540]: ? [pcmk ?] info: pcmk_startup: CRM: Initialized

Aug 27 09:05:35 pcmk-1 corosync[1540]: ? [pcmk ?] Logging: Initialized pcmk_startup

Aug 27 09:05:35 pcmk-1 corosync[1540]: ? [pcmk ?] info: pcmk_startup: Maximum core file size is:

 18446744073709551615

Aug 27 09:05:35 pcmk-1 corosync[1540]: ? [pcmk ?] info: pcmk_startup: Service: 9

Aug 27 09:05:35 pcmk-1 corosync[1540]: ? [pcmk ?] info: pcmk_startup: Local hostname: pcmk-1

Now try starting Pacemaker and check the necessary processes have been started

[root@pcmk-1 ~]# /etc/init.d/pacemaker start

Starting Pacemaker Cluster Manager: [ OK ]

[root@pcmk-1 ~]# grep -e pacemakerd.*get_config_opt -e pacemakerd.*start_child -e "Starting Pacemaker" /var/

log/messages

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'pacemaker' for option: name

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found '1' for option: ver

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Defaulting to 'no' for option: use_logd

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Defaulting to 'no' for option: use_mgmtd

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'on' for option: debug

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'yes' for option: to_logfile

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found '/var/log/corosync.log' for option:

 logfile

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'yes' for option: to_syslog

Feb  8 13:31:24 pcmk-1 pacemakerd: [13155]: info: get_config_opt: Found 'daemon' for option: syslog_facility

Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: main: Starting Pacemaker 1.1.5 (Build: 31f088949239+): 

 docbook-manpages publican ncurses trace-logging cman cs-quorum heartbeat corosync snmp libesmtp

Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14022 for process stonith-ng

Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14023 for process cib

Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14024 for process lrmd

Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14025 for process attrd

Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14026 for process pengine

Feb  8 16:50:38 pcmk-1 pacemakerd: [13990]: info: start_child: Forked child 14027 for process crmd

[root@pcmk-1 ~]# ps axf

? PID TTY ? ? ?STAT ? TIME COMMAND

? ? 2 ? ? ? ? ?S< ? ? 0:00 [kthreadd]

? ? 3 ? ? ? ? ?S< ? ? 0:00 ?\_ [migration/0]

... lots of processes ...

?13990 ? ? ?S  ? ? ?0:01 pacemakerd

?14022 ? ? ?Sa ? ? ?0:00 ?\_ /usr/lib64/heartbeat/stonithd

?14023 ? ? ?Sa ? ? ?0:00 ?\_ /usr/lib64/heartbeat/cib

?14024 ? ? ?Sa ? ? ?0:00 ?\_ /usr/lib64/heartbeat/lrmd

?14025 ? ? ?Sa ? ? ?0:00 ?\_ /usr/lib64/heartbeat/attrd

?14026 ? ? ?Sa ? ? ?0:00 ?\_ /usr/lib64/heartbeat/pengine

?14027 ? ? ?Sa ? ? ?0:00 ?\_ /usr/lib64/heartbeat/crmd

Next, check for any ERRORs during startup - there shouldn’t be any.

[root@pcmk-1 ~]# grep ERROR: /var/log/messages | grep -v unpack_resources

[root@pcmk-1 ~]#

Repeat on the other node and display the cluster's status.

[root@pcmk-1 ~]# ssh pcmk-2 -- /etc/init.d/pacemaker start檢查Pacemaker的安裝

29

Starting Pacemaker Cluster Manager: [ OK ]

[root@pcmk-1 ~]# crm_mon

============

Last updated: Thu Aug 27 16:54:55 2009

Stack: openais

Current DC: pcmk-1 - partition with quorum

Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f

2 Nodes configured, 2 expected votes

0 Resources configured.

============

Online: [ pcmk-1 pcmk-2 ]30第?4

31

使用Pacemaker工具 在萬惡的舊社會,配置Pacemaker需要管理員具備讀寫XML的能力。 根據UNIX精神,也有許多不同的查

詢和配置集羣的命令。

自從Pacemaker 1.0,這一切都改變了,我們有了一個集成的腳本化的集羣控制shell,它把麻煩的XML配

置隱藏了起來。它甚至允許你一次做出許多修改並自動提交(並檢測是否合法)。

讓我們花點時間熟悉一下它能做什麼。

[root@pcmk-1 ~]# crm --help

usage:

? ? crm [-D display_type]

? ? crm [-D display_type] args

? ? crm [-D display_type] [-f file]

? ? Use crm without arguments for an interactive session.

? ? Supply one or more arguments for a "single-shot" use.

? ? Specify with -f a file which contains a script. Use '-' for

? ? standard input or use pipe/redirection.

? ? crm displays cli format configurations using a color scheme

? ? and/or in uppercase. Pick one of "color" or "uppercase", or

? ? use "-D color,uppercase" if you want colorful uppercase.

? ? Get plain output by "-D plain". The default may be set in

? ? user preferences (options).

Examples:

? ? # crm -f stopapp2.cli

? ? # crm < stopapp2.cli

? ? # crm resource stop global_www

? ? # crm status

監控集羣狀態的主要命令是 crm_mon(跟crm status是一樣的效果)。它可以運行在很多模式下並且有許

多輸出選項。如果要查看Pacemaker相應的工具,可以通過--help或者man pages來查看。這些輸出都是

靠命令來生成的,所以它總是會在各個節點和工具之間同步。

此外,Pacemaker的版本和支持的stack(本文中是corosync)可以通過 --version選項看到

[root@pcmk-1 ~]# crm_mon --version

Pacemaker 1.1.5

Written by Andrew Beekhof

[root@pcmk-1 ~]# crm_mon --help

crm_mon - Provides a summary of cluster's current state.

Outputs varying levels of detail in a number of different formats.

Usage: crm_mon mode [options]

Options:

?-?, --help ? ? ? ? ? ? ? ? This text

?-$, --version ? ? ? ? ? ?  Version information

?-V, --verbose ? ? ? ? ? ?  Increase debug output

Modes:

?-h, --as-html=value? ? ? ? Write cluster status to the named file

?-w, --web-cgi ? ? ? ? ? ?  Web mode with output suitable for cgi

?-s, --simple-status ? ? ?  Display the cluster status once as a simple one line output (suitable for nagios)

?-S, --snmp-traps=value? ?  Send SNMP traps to this station

?-T, --mail-to=value? ? ? ? Send Mail alerts to this user. ?See also --mail-from, --mail-host, --mail-prefix第?4?章?使用Pacemaker工具

32

Display Options:

?-n, --group-by-node  ? ? ? Group resources by node

?-r, --inactive ? ? ? ? ? ? Display inactive resources

?-f, --failcounts ? ? ? ? ? Display resource fail counts

?-o, --operations ? ? ? ? ? Display resource operation history

?-t, --timing-details ? ? ? Display resource operation history with timing details

Additional Options:

?-i, --interval=value? ? ? ? ? ?Update frequency in seconds

?-1, --one-shot ? ? ? ? ? ? ? ? Display the cluster status once on the console and exit

?-N, --disable-ncurses ? ? ? ? ?Disable the use of ncurses

?-d, --daemonize ? ? ? ? ? ? ? ?Run in the background as a daemon

?-p, --pid-file=value? ? ? ? ? ?(Advanced) Daemon pid file location

?-F, --mail-from=value? ? ? ? ? Mail alerts should come from the named user

?-H, --mail-host=value? ? ? ? ? Mail alerts should be sent via the named host

?-P, --mail-prefix=value? ? ? ? Subjects for mail alerts should start with this string

?-E, --external-agent=value? ? ?A program to run when resource operations take place.

?-e, --external-recipient=value?A recipient for your program (assuming you want the program to send something

 to someone).

Examples:

Display the cluster′s status on the console with updates as they occur:

? ? ? ? # crm_mon

Display the cluster′s status on the console just once then exit:

? ? ? ? # crm_mon -1

Display your cluster′s status, group resources by node, and include inactive resources in the list:

? ? ? ? # crm_mon --group-by-node --inactive

Start crm_mon as a background daemon and have it write the cluster′s status to an HTML file:

? ? ? ? # crm_mon --daemonize --as-html /path/to/docroot/filename.html

Start crm_mon as a background daemon and have it send email alerts:

? ? ? ? # crm_mon --daemonize --mail-to [email protected] --mail-host mail.example.com

Start crm_mon as a background daemon and have it send SNMP alerts:

? ? ? ? # crm_mon --daemonize --snmp-traps snmptrapd.example.com

Report bugs to [email protected]

注意

如果SNMP或者email選項沒有出現在選項中,說明pacemaker編譯的時候沒有打開對他們的支持,你

需要聯繫提供這個發行版本的人,或者自己編譯。第?5

33

創建一個主/備集羣

目錄

5.1. 瀏覽現有配置  ....................................................................   33

5.2. 添加一個資源  ....................................................................   34

5.3. 做一次失效備援  ..................................................................   36

5.3.1. 法定人數和雙節點集羣  .....................................................   36

5.3.2. 防止資源在節點恢復後移動  ..................................................  37

5.1.?瀏覽現有配置 當Pacemaker啓動的時候,它會自動記錄節點的數量和詳細信息,以及基層軟件(本文中是corosync)和

Pacemaker的版本。

這是初始配置文件的模樣:

[root@pcmk-2 ~]# crm configure show

node pcmk-1

node pcmk-2

property $id="cib-bootstrap-options" \

? ? ? ? dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \

? ? ? ? cluster-infrastructure="openais" \

? ? ? ? expected-quorum-votes="2"

如果有誰想看看XML格式的,你可以添加xml選項來看到原始的配置文件

[root@pcmk-2 ~]# crm configure show xml

<?xml version="1.0" ?>

<cib admin_epoch="0" crm_feature_set="3.0.1" dc-uuid="pcmk-1" epoch="13" have-quorum="1" num_updates="7"

 validate-with="pacemaker-1.0">

? <configuration>

? ? <crm_config>

? ? ? <cluster_property_set id="cib-bootstrap-options">

? ? ? ? <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.5-

bdd89e69ba545404d02445be1f3d72e6a203ba2f"/>

? ? ? ? <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure"

 value="openais"/>

? ? ? ? <nvpair id="cib-bootstrap-options-expected-quorum-votes" name="expected-quorum-votes" value="2"/>

? ? ? </cluster_property_set>

? ? </crm_config>

? ? <rsc_defaults/>

? ? <op_defaults/>

? ? <nodes>

? ? ? <node id="pcmk-1" type="normal" uname="pcmk-1"/>

? ? ? <node id="pcmk-2" type="normal" uname="pcmk-2"/>

? ? </nodes>

? ? <resources/>

? ? <constraints/>

? </configuration>

</cib>

這是本文檔最後一次顯示XML。(作者怨念很深啊)

在我們做出任何改變之前,我們最好檢查下配置文件。第?5?章?創建一個主/備集羣

34

[root@pcmk-1 ~]# crm_verify -L

crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: Resource start-up disabled since no STONITH

 resources have been defined

crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: Either configure some or disable STONITH with

 the stonith-enabled option

crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to

 ensure data integrity

Errors found during check: config not valid

? -V may provide more details

[root@pcmk-1 ~]#

就像你看到的,這個工具發現了一些錯誤。

爲了確保您數據的安全性 1

 ,請使用配備STONITH 2

的Pacemaker。但是當沒有配置STONITH的時候也會

報這個錯誤(因爲當集羣中某個節點需要被隔離的時候,集羣就無法工作了)。

目前,我們禁用這個特性,然後在 配置STONISH 章節來配置它。這裏要指出,使用STONITH是非常有必

要的。關閉這個特性就是告訴集羣:假裝故障的節點已經安全的關機了。一些供應商甚至不允許這個特

性被關閉。

我們將 stonith-enabled設置爲 false 來關閉STONITH

crm configure property stonith-enabled=false

crm_verify -L

設置完這個選項以後,校驗配置文件就正常了。

警告

The use of stonith-enabled=false is completely inappropriate for a production cluster.

We use it here to defer the discussion of its configuration which can differ widely

from one installation to the next. See 第?9?章 配置 STONITH for information on why

STONITH is important and details on how to configure it.

5.2.?添加一個資源 首先要做的是配置一個IP地址,不管集羣服務在哪運行,我們要一個固定的地址來提供服務。在這裏我

選擇192.168.122.101作爲浮動IP,給它取一個好記的名字 ClusterIP 並且告訴集羣 每30秒檢查它一

重要

選擇的IP地址不能被節點所佔用

crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 \ 

? ? ? ? params ip=192.168.122.101 cidr_netmask=32 \ 

? ? ? ? op monitor interval=30s

1

 如果數據是損壞的,那保證它的可用性是沒有意義的 2

 一個常見的隔離手段。用關掉壞節點電源的辦法來保證數據完整添加一個資源

35

另外一個重要的信息是 ocf:heartbeat:IPaddr2。這告訴Pacemaker三件事情,第一個部分,ocf,指明

了這個資源採用的標準(類型)以及在哪能找到它。第二個部分標明這個資源腳本的在OCF中的名字空間

,在這個例子中是heartbeat。最後一個部分指明瞭資源腳本的名稱。

可以運行下面的命令來獲得可用的資源類

[root@pcmk-1 ~]# crm ra classes

heartbeat

lsb

ocf / heartbeat pacemaker

stonith

找到OCF中Pacemaker和Heartbeat提供的資源腳本,運行下面的命令

[root@pcmk-1 ~]# crm ra list ocf pacemaker

ClusterMon ? ? Dummy ? ? ? ? ?Stateful ? ? ? SysInfo ? ? ? ?SystemHealth ? controld

ping ? ? ? ? ? pingd ? ? ? ? ?

[root@pcmk-1 ~]# crm ra list ocf heartbeat

AoEtarget ? ? ? ? ? ? ?AudibleAlarm ? ? ? ? ? ClusterMon ? ? ? ? ? ? Delay

Dummy ? ? ? ? ? ? ? ? ?EvmsSCC ? ? ? ? ? ? ? ?Evmsd ? ? ? ? ? ? ? ? ?Filesystem

ICP ? ? ? ? ? ? ? ? ? ?IPaddr ? ? ? ? ? ? ? ? IPaddr2 ? ? ? ? ? ? ? ?IPsrcaddr

LVM ? ? ? ? ? ? ? ? ? ?LinuxSCSI ? ? ? ? ? ? ?MailTo ? ? ? ? ? ? ? ? ManageRAID

ManageVE ? ? ? ? ? ? ? Pure-FTPd ? ? ? ? ? ? ?Raid1 ? ? ? ? ? ? ? ? ?Route

SAPDatabase ? ? ? ? ? ?SAPInstance ? ? ? ? ? ?SendArp ? ? ? ? ? ? ? ?ServeRAID

SphinxSearchDaemon ? ? Squid ? ? ? ? ? ? ? ? ?Stateful ? ? ? ? ? ? ? SysInfo

VIPArip ? ? ? ? ? ? ? ?VirtualDomain ? ? ? ? ?WAS ? ? ? ? ? ? ? ? ? ?WAS6

WinPopup ? ? ? ? ? ? ? Xen ? ? ? ? ? ? ? ? ? ?Xinetd ? ? ? ? ? ? ? ? anything

apache ? ? ? ? ? ? ? ? db2 ? ? ? ? ? ? ? ? ? ?drbd ? ? ? ? ? ? ? ? ? eDir88

iSCSILogicalUnit ? ? ? iSCSITarget ? ? ? ? ? ?ids ? ? ? ? ? ? ? ? ? ?iscsi

ldirectord ? ? ? ? ? ? mysql ? ? ? ? ? ? ? ? ?mysql-proxy ? ? ? ? ? ?nfsserver

oracle ? ? ? ? ? ? ? ? oralsnr ? ? ? ? ? ? ? ?pgsql ? ? ? ? ? ? ? ? ?pingd

portblock ? ? ? ? ? ? ?rsyncd ? ? ? ? ? ? ? ? scsi2reservation ? ? ? sfex

tomcat ? ? ? ? ? ? ? ? vmware ? ? ? ? ? ? ? ? 

[root@pcmk-1 ~]#

現在檢查下IP 資源是不是已經添加了,並且看看是否處在可用狀態。

[root@pcmk-1 ~]# crm configure show

node pcmk-1

node pcmk-2

primitive ClusterIP ocf:heartbeat:IPaddr2 \

 params ip="192.168.122.101" cidr_netmask="32" \

 op monitor interval="30s"

property $id="cib-bootstrap-options" \

? ? ? ? dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \

? ? ? ? cluster-infrastructure="openais" \

? ? ? ? expected-quorum-votes="2" \

? ? ? ? stonith-enabled="false" \

[root@pcmk-1 ~]# crm_mon

============

Last updated: Fri Aug 28 15:23:48 2009

Stack: openais

Current DC: pcmk-1 - partition with quorum

Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f

2 Nodes configured, 2 expected votes

1 Resources configured.

============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP (ocf::heartbeat:IPaddr): Started pcmk-1第?5?章?創建一個主/備集羣

36

5.3.?做一次失效備援 作爲一個高可用的集羣,我們在繼續本文檔之前,我們要需要測試失效備援 。

首先,找到IP資源現在在哪個節點上運行。

[root@pcmk-1 ~]# crm resource status ClusterIP

resource ClusterIP is running on: pcmk-1

[root@pcmk-1 ~]#

Shut down Pacemaker and Corosync on that machine.

[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/pacemaker stop

Signaling Pacemaker Cluster Manager to terminate: [ OK ]

Waiting for cluster services to unload:. [ OK ]

[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/corosync stop

Stopping Corosync Cluster Engine (corosync): [ OK ]

Waiting for services to unload: [ OK ]

[root@pcmk-1 ~]#

當Corosync停止運行以後,我們到另外一個節點用crm_mon來檢查集羣狀態.

[root@pcmk-2 ~]# crm_mon

============

Last updated: Fri Aug 28 15:27:35 2009

Stack: openais

Current DC: pcmk-2 - partition WITHOUT quorum

Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f

2 Nodes configured, 2 expected votes

1 Resources configured.

============

Online: [ pcmk-2 ]

OFFLINE: [ pcmk-1 ]

關於集羣狀態,我們有三個地方需要注意,首先,如我們所料pcmk-1已經下線了,然而我們發現

ClusterIP不在任何地方運行!

5.3.1.?法定人數和雙節點集羣

這是因爲集羣已經達不到“法定人數”了,就像我們看到的“partition WITHOUT quorum” (用綠色強

調的)。爲了避免數據遭到破壞,當Pacemaker發現集羣達不到法定人數時,就會停止所有的資源。

當有半數以上的節點在線時,這個集羣就認爲自己擁有法定人數了,是“合法”的,換而言之就是下面

的公式:

total_nodes < 2 * active_nodes

因此在雙節點的集羣中,只有當兩者都在線時纔是合法的。 這個規則會讓 雙節點的集羣 毫無意義,

但是我們可以控制Pacemaker發現集羣達不到法定人數時候的行爲。簡單來說,我們告訴集羣忽略它 。

[root@pcmk-1 ~]# crm configure property no-quorum-policy=ignore

[root@pcmk-1 ~]# crm configure show 

node pcmk-1

node pcmk-2

primitive ClusterIP ocf:heartbeat:IPaddr2 \防止資源在節點恢復後移動

37

? ? ? ? params ip="192.168.122.101" cidr_netmask="32" \

? ? ? ? op monitor interval="30s"

property $id="cib-bootstrap-options" \

? ? ? ? dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \

? ? ? ? cluster-infrastructure="openais" \

? ? ? ? expected-quorum-votes="2" \

? ? ? ? stonith-enabled="false" \

? ? ? ? no-quorum-policy="ignore"

過了一會,集羣會在剩下的那個節點上啓動這個IP。請注意集羣現在依然沒有達到法定人數。

[root@pcmk-2 ~]# crm_mon

============

Last updated: Fri Aug 28 15:30:18 2009

Stack: openais

Current DC: pcmk-2 - partition WITHOUT quorum

Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f

2 Nodes configured, 2 expected votes

1 Resources configured.

============

Online: [ pcmk-2 ]

OFFLINE: [ pcmk-1 ]

ClusterIP (ocf::heartbeat:IPaddr): Started pcmk-2

現在模擬節點恢復,我們啓動 pcmk-1 上面的Corosync服務,然後檢查集羣狀態。

[root@pcmk-1 ~]# /etc/init.d/corosync start

Starting Corosync Cluster Engine (corosync): [ OK ]      

[root@pcmk-1 ~]# /etc/init.d/pacemaker start

Starting Pacemaker Cluster Manager: [ OK ]

[root@pcmk-1 ~]# crm_mon

============

Last updated: Fri Aug 28 15:32:13 2009

Stack: openais

Current DC: pcmk-2 - partition with quorum

Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f

2 Nodes configured, 2 expected votes

1 Resources configured.

============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP? ? ? ? (ocf::heartbeat:IPaddr): ? ? ? ?Started pcmk-1

現在我們可以看到讓某些人驚奇的事情,IP資源回到原來那個節點(pcmk-1)上去了。

5.3.2.?防止資源在節點恢復後移動

一些環境中會要求儘量避免資源在節點之間移動。移動資源通常意味着一段時間內無法提供服務,某些

複雜的服務,比如Oracle數據庫,這個時間可能會很長。

爲了達到這個效果,Pacemaker 有一個叫做 資源黏性值 的概念,它能夠控制一個服務(資源)有多想呆

在它正在運行的節點上。你可以把它認爲是無法提供服務的“代價”3

”。 Pacemaker爲了達到最優分佈

各個資源的目的,默認設置這個值爲0。我們可以爲每個資源定義不同的黏性值,但一般來說,更改默

認黏性值就夠了。

3

 這裏要注意的是Pacemaker定義的代價跟人們所想的不一樣。如果管理員沒有明確的指定參數(創建穩定環境所必須的),那麼資

源個節點在Pacemaker處理列表中的順序會隱式地創建參數第?5?章?創建一個主/備集羣

38

[root@pcmk-2 ~]# crm configure rsc_defaults resource-stickiness=100

[root@pcmk-2 ~]# crm configure show

node pcmk-1

node pcmk-2

primitive ClusterIP ocf:heartbeat:IPaddr2 \

? ? ? ? params ip="192.168.122.101" cidr_netmask="32" \

? ? ? ? op monitor interval="30s"

property $id="cib-bootstrap-options" \

? ? ? ? dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \

? ? ? ? cluster-infrastructure="openais" \

? ? ? ? expected-quorum-votes="2" \

? ? ? ? stonith-enabled="false" \

? ? ? ? no-quorum-policy="ignore"

rsc_defaults $id="rsc-options" \

 resource-stickiness="100"

現在我們重新嘗試失效援備測試,我們可以看到,正如我們所料,當pcmk-1不在線的時候ClusterIP還

是移動到了pcmk-2

[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/pacemaker stop

Signaling Pacemaker Cluster Manager to terminate:          [  OK  ]

Waiting for cluster services to unload:.                   [  OK  ]

[root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/corosync stop

Stopping Corosync Cluster Engine (corosync): ? ? ? ? ? ? ? [ ?OK ?]

Waiting for services to unload: ? ? ? ? ? ? ? ? ? ? ? ? ? ?[ ?OK ?]

[root@pcmk-1 ~]# ssh pcmk-2 -- crm_mon -1

============

Last updated: Fri Aug 28 15:39:38 2009

Stack: openais

Current DC: pcmk-2 - partition WITHOUT quorum

Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f

2 Nodes configured, 2 expected votes

1 Resources configured.

============

Online: [ pcmk-2 ]

OFFLINE: [ pcmk-1 ]

ClusterIP? ? ? ? (ocf::heartbeat:IPaddr):? ? ? ? Started pcmk-2

但是當我們把pcmk-1恢復在線後,ClusterIP現在還是跑在pcmk-2上面。

[root@pcmk-1 ~]# /etc/init.d/corosync start

Starting Corosync Cluster Engine (corosync): [ OK ]

[root@pcmk-1 ~]# /etc/init.d/pacemaker start

Starting Pacemaker Cluster Manager: [ OK ]

[root@pcmk-1 ~]# crm_mon

============

Last updated: Fri Aug 28 15:41:23 2009

Stack: openais

Current DC: pcmk-2 - partition with quorum

Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f

2 Nodes configured, 2 expected votes

1 Resources configured.

============

Online: [ pcmk-1 pcmk-2 ]

ClusterIP? ? ? ? (ocf::heartbeat:IPaddr): ? ? ? ?Started pcmk-2

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章