corosync+pacemakerのcrmsh常用命令の紹介
----本文の大綱 corosync、pacemakerそれぞれ何 一般的な高可用性クラスタソリューション corosync、pacemaker をインストール pacemakerリソースマネージャ(CRM)コマンド注記 実例 一、corosync、pacemakerそれぞれは何ですか
corosyncは、高可用性クラスタアーキテクチャの最下位(Message Layer)に位置し、各ノード(node)間の心拍情報伝達を提供する役割を果たす高可用性環境における通信サービスを提供するために使用される.
Pacemakerはオープンソースの高可用性リソースマネージャ(CRM)であり、HAクラスタアーキテクチャにおけるリソース管理、リソースエージェント(RA)という階層に位置し、下位心拍情報伝達の機能を提供することはできない.相手ノードと通信するには、下位心拍伝達サービスを利用して、情報を相手に通知する必要がある.通常corosyncとの結合方法は2つあります. pacemakerはcorosyncのプラグインとして動作する. pacemakerは独立したデーモンプロセスとして実行される.
注意:
corosyncの初期バージョンは投票能力を備えていないため、クラスタ内のノードの総数は奇数であり、2より大きい必要があります.
corosync 1.0の場合、それ自体はチケット機能(votes)を備えていないが、corosync 2.0の後にvotequorumが導入された
cman(DC)+corosync(pacemakerでまたcmanを使いたいなら、cmanをcorosyncのプラグインとして使うしかない)
二、一般的な高可用性クラスタソリューション heartbeat+crm cman+rgmanager cman+pacemaker corosync+pacemaker(リソースマネージャとしてpacemaker) 三、corosync、pacemakerのインストール
そのプロファイルは/etc/corosync/の下にあり、テンプレートはcorosync.conf.exampleです.
pacemkerをcorosyncでプラグインとして使用するには、corosync.confファイルに次のように書きます.
第一歩、鍵ファイルの生成
corosync-keygenコマンドで鍵を生成する(生成された鍵のアルゴリズムは/dev/randomランダム生成)
鍵を生成すると、プロファイルディレクトリの下でauthkeyファイルが自動的に生成され、この2つのファイルが各クラスタノードにコピーされます.
ステップ2、corosyncの起動
ログ情報を表示すると、corosyncが正常に起動しているかどうかが明らかになります(各ノードで表示されます).
正常に動作している場合はcrm statusコマンドを使用して、現在のクラスタノード情報を表示できます.
現在、2つのノードがオンライン、node 2、node 3です.
四、pacemakerリソースマネージャ(CRM)コマンド注記
1、crmには2つの働き方がある
バッチ・モード
コマンドラインにコマンドを直接入力する(上記のコマンド実行時に使用するcrm status)
インタラクティブモード(crm(live)#)
crmshでインタラクティブに実行
2、crmコマンド紹介一級サブコマンド resourceサブコマンド すべてのリソース状態はここで を制御する.
configureサブコマンド すべてのリソースの定義は、このサブコマンドで完了した です.
nodeサブコマンド ノード管理およびステータスコマンド raサブコマンド リソースエージェントカテゴリは、ここで です.
注意:
これらの命令で使われている単語はすべて簡単ですが、私はよく使われている表記をします.今勉強が終わったばかりで、はっきり覚えていますが、後である日ここの命令に盲区が現れたかもしれません.△自分の記憶力を過小評価してはいけない.
五、実例プレゼンテーション
注意:高可用性の前提条件の構成 時間同期 パスワードなし登録 ホスト名解析 ここではプレゼンテーションコマンドの使用のみのため、本番環境構成 ではありません.
1、本機環境
システム:
centos 6.5 x86_64
ノード:
essun.node2.com 192.168.1.111
essun.node3.com 192.168.1.108
各ノードに必要なソフトウェアとリソース
仮想ip 192.168.1.1100
2つのノードにhttpdサービスをそれぞれインストールし、デフォルトのテストページを追加し、テストが完了した後、サービス起動の自動起動を禁止します.
nfsリソースをマウントし、nfsを提供するホストは192.168.1.1110です.
2、資源の定義 stonith-enableを無効にします(パラメータが不明な場合は、tabキーを2回押してコマンドを補完し、cdを使用します.前のコマンドに戻ることができます). 投票規則を無視 仮想ip を定義する
注記:
以上の文は4つのセグメントに分けることができます.
セグメント1:primitive:リソースで使用されるコマンドを定義する
第2段:webip:リソースに名前を付ける
第3段ocf:heartbeat;IPaddr:使用するリソースエージェントのカテゴリ、誰が提供するエージェント
(ここではcrm ra#listの後にRAの4種類のカテゴリを使用して、使用するエージェントが誰によって提供されたかを確認できます)
セクション4:params:定義されたパラメータを指定する
ip:パラメータ名ファイルシステムマウント を定義する
まずraでファイルシステムで使用されるリソースエージェントを検索します
これにより、ファイルシステムのリソースエージェントはocf:heartbeatによって提供されることがわかる.
このリソースエージェントのパラメータを表示
ここに*は必須パラメータを示しています.これで定義できます.
注記:
primitive#定義リソースコマンド
Webnfs#リソースID
ocf:heartbeat:Filesystem#リソースエージェント(RA)
params device="192.168.1.1110:/share"#共有ディレクトリ
Directory=「/var/www/html」#マウントディレクトリ
fstype="nfs" #ファイルの種類
op monitor#このwebnfsを監視する
interval=60 s#間隔時間
timeout=60 s#タイムアウト時間
op start timeout=60 s#起動タイムアウト時間
op stop timeout=60 s#停止タイムアウト時間
Webサービスリソースの定義
複数のリソースをすべて統合(バインドして実行)
別の方法で、有効なリソース情報を確認します.
上図はすべてのリソースがnode 2にあることを示しています.つまり192.168.1.1.1111というipにcurlコマンドでアクセスして、効果を見てみましょう.
Node 2ノードの障害をシミュレートし、リソースが移行するかどうかを確認します.
もう一度curl
注記:
最初のcurlはhttpdサービスがノードnode 2上で実行されなくなったことを示した.
2回目のcurlはvipを使用してマウントされたページにアクセスできるかどうかを示し、node 2ラインオフでサービスが終了していないことを示した.
3回目のcurlはnode 3 ipを用いても同様にサービスにアクセスできることを示し,サービスがnode 3上で実行されていると判断する可能性がある.
この場合、node 2再オンラインサービスがnode 2に切り替えられない場合は、node 2をオンラインにした後に切り替えることができるようにするには、位置コンストレイントを使用して重みを指定します.
次に2つ目の方法でリソースを限定し、まずグループ定義を削除し、crm configure#editでcibファイルを編集し、グループ定義のエントリを削除すればよい.
サービスはやはり帰ってこないで、私がどのようにそれを回収することを見ますa_c!
最初のステップは、グループ制限を削除し、editコマンドを使用するのが最善の方法であり、コマンドも使用できます.
この时、自分はグループの定义がなくて、このように私の“计画”を行うことができます
配列コンストレイントの定義(一緒にいる可能性)
注記:
colocation:整列拘束コマンド
Webserver-with-webnfs-webip:#制約名(ID)
inf:#(可能性、infは永久に一緒にいることを示し、数値であってもよい)
webip webnfs webserver:#リソース名
リソース起動順序の定義
注記:
order:シーケンスコンストレイントのコマンド
ip_before_webnfs_before_Webserver#コンストレイントID
mandatory:#指定レベル(ここには3つのレベルがあります:mandatory:強制、Optional:オプション、Serialize:シーケンス化)
Webip webnfs webserver#リソース名、ここで書く順番はかなり重要です
位置コンストレイントの定義
注記:
location:位置拘束コマンドいちこうそくこまんど
webip_and_webnfs_and_webserver:コンストレイント名
webip 500:essun.node 2.com:そのリソースにどのくらいの重みを指定するかそのノード
デフォルトのリソース属性の定義
注記:
この定義はクラスタ内の各リソースのデフォルトのスティッキーを表し、リソースサービスが現在のノードにない場合にのみスティッキーが有効になります.たとえば、ここでは3つのリソースwebip、webnfs、webserverを定義し、各リソースに対するスティッキーが100になると、加算すると300になります.これまで定義されていたnode 2の位置制約の値は500で、node 2がダウンタイムした後、再オンラインになります.これでnode 2に切り替わりました.
最後にステータスを見て、リソースはnode 2上で実行され、node 2が故障します.
リソースはnode 3で実行されました
もう2回curl
Node 2を再オンラインにしてリソースが戻ってくるかどうかを確認します
もう3回curl
注記:
1.100は仮想クラスタIP
1.108はessun.node 3.com
1.111はessun.node 2.com
事実が証明しているように,資源はやはり奪還された.
=============================================
PS:
英語が下手で、注釈が正確ではないかもしれません.皆さん、どうぞお許しください.c~~~~~~
corosyncは、高可用性クラスタアーキテクチャの最下位(Message Layer)に位置し、各ノード(node)間の心拍情報伝達を提供する役割を果たす高可用性環境における通信サービスを提供するために使用される.
Pacemakerはオープンソースの高可用性リソースマネージャ(CRM)であり、HAクラスタアーキテクチャにおけるリソース管理、リソースエージェント(RA)という階層に位置し、下位心拍情報伝達の機能を提供することはできない.相手ノードと通信するには、下位心拍伝達サービスを利用して、情報を相手に通知する必要がある.通常corosyncとの結合方法は2つあります.
注意:
corosyncの初期バージョンは投票能力を備えていないため、クラスタ内のノードの総数は奇数であり、2より大きい必要があります.
corosync 1.0の場合、それ自体はチケット機能(votes)を備えていないが、corosync 2.0の後にvotequorumが導入された
cman(DC)+corosync(pacemakerでまたcmanを使いたいなら、cmanをcorosyncのプラグインとして使うしかない)
二、一般的な高可用性クラスタソリューション
#yum install -y corosync
そのプロファイルは/etc/corosync/の下にあり、テンプレートはcorosync.conf.exampleです.
# Please read the corosync.conf.5 manual page
compatibility: whitetank # 08.
totem {
version: 2 #totme
secauth: off # ,
threads: 0 #
interface {
ringnumber: 0 # , ,
bindnetaddr: 192.168.1.1 # ( )
mcastaddr: 226.94.1.1 #
mcastport: 5405 #
ttl: 1 # ,
}
}
#totem ,totem , corosync ,
logging {
fileline: off
to_stderr: no # ( )
to_logfile: yes #
to_syslog: yes # syslog --> /var/log/message
logfile: /var/log/cluster/corosync.log #
debug: off # , debug, , IO.
timestamp: on #
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}
pacemkerをcorosyncでプラグインとして使用するには、corosync.confファイルに次のように書きます.
service {
ver:0
name:pacemaker
}
#corosync pacemaker
aisexec {
user :root
group:root
}
# ais , root,aisexec
第一歩、鍵ファイルの生成
corosync-keygenコマンドで鍵を生成する(生成された鍵のアルゴリズムは/dev/randomランダム生成)
鍵を生成すると、プロファイルディレクトリの下でauthkeyファイルが自動的に生成され、この2つのファイルが各クラスタノードにコピーされます.
#scp -p authkey corosync.conf 192.168.1.111:/etc/corosync/
ステップ2、corosyncの起動
[root@essun corosync]# ssh essun.node2.com 'service corosync start'
Starting Corosync Cluster Engine (corosync): [ OK ]
[root@essun corosync]# service corosync start
Starting Corosync Cluster Engine (corosync): [ OK ]
ログ情報を表示すると、corosyncが正常に起動しているかどうかが明らかになります(各ノードで表示されます).
#tail -40 /var/log/cluster/corosync.log
Apr 25 23:12:01 [2811] essun.node3.com crmd: info: update_attrd: Connecting to attrd... 5 retries remaining
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_replace: Digest matched on replace from essun.node2.com: cb225a22df77f4f0bfbf7bd73c7d4160
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_replace: Replaced 0.4.1 with 0.4.1 from essun.node2.com
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_replace operation for section 'all': OK (rc=0, origin=essun.node2.com/crmd/24, version=0.4.1)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Forwarding cib_delete operation for section //node_state[@uname='essun.node3.com']/transient_attributes to master (origin=local/crmd/9)
Apr 25 23:12:01 [2811] essun.node3.com crmd: info: do_log: FSA: Input I_NOT_DC from do_cl_join_finalize_respond() received in state S_PENDING
Apr 25 23:12:01 [2811] essun.node3.com crmd: notice: do_state_transition: State transition S_PENDING -> S_NOT_DC [ input=I_NOT_DC cause=C_HA_MESSAGE origin=do_cl_join_finalize_respond ]
Apr 25 23:12:01 [2809] essun.node3.com attrd: notice: attrd_local_callback: Sending full refresh (origin=crmd)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: write_cib_contents: Wrote version 0.3.0 of the CIB to disk (digest: 02ededba58f5938f53dd45f5bd06f577)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_apply_diff operation for section nodes: OK (rc=0, origin=essun.node2.com/crmd/26, version=0.5.1)
Apr 25 23:12:01 [2807] essun.node3.com stonith-ng: info: cib_process_diff: Diff 0.4.1 -> 0.5.1 from local not applied to 0.3.1: current "epoch" is less than required
Apr 25 23:12:01 [2807] essun.node3.com stonith-ng: notice: update_cib_cache_cb: [cib_diff_notify] Patch aborted: Application of an update diff failed, requesting a full refresh (-207)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_apply_diff operation for section status: OK (rc=0, origin=essun.node2.com/crmd/29, version=0.5.2)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_apply_diff operation for section status: OK (rc=0, origin=essun.node2.com/crmd/31, version=0.5.3)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section 'all': OK (rc=0, origin=local/crmd/4, version=0.5.3)
Apr 25 23:12:01 [2807] essun.node3.com stonith-ng: info: cib_process_diff: Diff 0.5.1 -> 0.5.2 from local not applied to 0.5.3: current "num_updates" is greater than required
Apr 25 23:12:01 [2807] essun.node3.com stonith-ng: notice: update_cib_cache_cb: [cib_diff_notify] Patch aborted: Application of an update diff failed (-206)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section 'all': OK (rc=0, origin=local/crmd/5, version=0.5.3)
Apr 25 23:12:01 [2807] essun.node3.com stonith-ng: info: cib_process_diff: Diff 0.5.2 -> 0.5.3 from local not applied to 0.5.3: current "num_updates" is greater than required
Apr 25 23:12:01 [2807] essun.node3.com stonith-ng: notice: update_cib_cache_cb: [cib_diff_notify] Patch aborted: Application of an update diff failed (-206)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section 'all': OK (rc=0, origin=local/crmd/6, version=0.5.3)
Apr 25 23:12:01 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_apply_diff operation for section cib: OK (rc=0, origin=essun.node2.com/crmd/34, version=0.5.4)
Apr 25 23:12:02 [2809] essun.node3.com attrd: notice: attrd_trigger_update: Sending flush op to all hosts for: probe_complete (true)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section //cib/status//node_state[@id='essun.node3.com']//transient_attributes//nvpair[@name='probe_complete']: No such device or address (rc=-6, origin=local/attrd/2, version=0.5.4)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section /cib: OK (rc=0, origin=local/attrd/3, version=0.5.4)
Apr 25 23:12:02 [2809] essun.node3.com attrd: notice: attrd_perform_update: Sent update 4: probe_complete=true
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_apply_diff operation for section status: OK (rc=0, origin=essun.node2.com/attrd/4, version=0.5.5)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Forwarding cib_modify operation for section status to master (origin=local/attrd/4)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section //cib/status//node_state[@id='essun.node3.com']//transient_attributes//nvpair[@name='probe_complete']: No such device or address (rc=-6, origin=local/attrd/5, version=0.5.5)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section /cib: OK (rc=0, origin=local/attrd/6, version=0.5.5)
Apr 25 23:12:02 [2809] essun.node3.com attrd: notice: attrd_perform_update: Sent update 7: probe_complete=true
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Forwarding cib_modify operation for section status to master (origin=local/attrd/7)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: retrieveCib: Reading cluster configuration from: /var/lib/pacemaker/cib/cib.dnz3rc (digest: /var/lib/pacemaker/cib/cib.dOgpug)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_apply_diff operation for section status: OK (rc=0, origin=essun.node2.com/attrd/4, version=0.5.6)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: write_cib_contents: Archived previous version as /var/lib/pacemaker/cib/cib-2.raw
Apr 25 23:12:02 [2806] essun.node3.com cib: info: write_cib_contents: Wrote version 0.5.0 of the CIB to disk (digest: 420e9390e2cb813eebbdf3bb73416dd2)
Apr 25 23:12:02 [2806] essun.node3.com cib: info: retrieveCib: Reading cluster configuration from: /var/lib/pacemaker/cib/cib.kgClFd (digest: /var/lib/pacemaker/cib/cib.gQtyTi)
Apr 25 23:12:14 [2806] essun.node3.com cib: info: crm_client_new: Connecting 0x1d8dc80 for uid=0 gid=0 pid=2828 id=2dfaa45a-28c4-4c7e-9613-603fb1217e12
Apr 25 23:12:14 [2806] essun.node3.com cib: info: cib_process_request: Completed cib_query operation for section 'all': OK (rc=0, origin=local/cibadmin/2, version=0.5.6)
Apr 25 23:12:14 [2806] essun.node3.com cib: info: crm_client_destroy: Destroying 0 events
正常に動作している場合はcrm statusコマンドを使用して、現在のクラスタノード情報を表示できます.
[root@essun corosync]# crm status
Last updated: Fri Apr 25 23:18:11 2014
Last change: Fri Apr 25 23:12:01 2014 via crmd on essun.node2.com
Stack: classic openais (with plugin)
Current DC: essun.node2.com - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
0 Resources configured
Online: [ essun.node2.com essun.node3.com ]
現在、2つのノードがオンライン、node 2、node 3です.
四、pacemakerリソースマネージャ(CRM)コマンド注記
1、crmには2つの働き方がある
バッチ・モード
コマンドラインにコマンドを直接入力する(上記のコマンド実行時に使用するcrm status)
インタラクティブモード(crm(live)#)
crmshでインタラクティブに実行
2、crmコマンド紹介
[root@essun corosync]# crm
crm(live)# help
This is crm shell, a Pacemaker command line interface.
Available commands:
cib manage shadow CIBs #cib
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 # crm(live)#
quit,bye,exit exit the program # crm(live)
crm(live)resource# help
vailable commands:
status show status of resources #
start start a resource #
stop stop a resource #
restart restart a resource #
promote promote a master-slave resource #
demote demote a master-slave resource #
manage put a resource into managed mode
unmanage put a resource into unmanaged mode
migrate migrate a resource to another node #
unmigrate unmigrate a resource to another node
param manage a parameter of a resource #
secret manage sensitive parameters #
meta manage a meta attribute #
utilization manage a utilization attribute
failcount manage failcounts #
cleanup cleanup resource status #
refresh refresh CIB from the LRM status # LRM(LRM ) CIB( ),
reprobe probe for resources not started by the CRM # CRM
trace start RA tracing # (RA)
untrace stop RA tracing # (RA)
help show help (help topics for list of topics) #
end go back one level # (crm(live)#)
quit exit the program #
crm(live)configure# help
Available commands:
node define a cluster node #
primitive define a resource #
monitor add monitor operation to a primitive # ( , )
group define a group # ( )
clone define a clone # ( , )
ms define a master-slave resource # ( , )
rsc_template define a resource template #
location a location preference # ( ( , , ))
colocation colocate resources # ( )
order order resources #
rsc_ticket resources ticket dependency
property set a cluster property #
rsc_defaults set resource defaults # ( )
fencing_topology node fencing order #
role define role access rights #
user define user access rights #
op_defaults set resource operations defaults #
schema set or display current CIB RNG schema
show display CIB objects #
edit edit CIB objects # (vim )
filter filter CIB objects # CIB
delete delete CIB objects # CIB
default-timeouts set timeouts for operations to minimums from the meta-data
rename rename a CIB object # CIB
modgroup modify group #
refresh refresh from CIB # CIB
erase erase the CIB # CIB
ptest show cluster actions if changes were committed
rsctest test resources as currently configured
cib CIB shadow management
cibstatus CIB status management and editing
template edit and import a configuration from a template
commit commit the changes to the CIB # CIB
verify verify the CIB with crm_verify #CIB
upgrade upgrade the CIB to version 1.0
save save the CIB to a file # CIB ( crm )
load import the CIB from a file # CIB
graph generate a directed graph
xml raw xml
help show help (help topics for list of topics) #
end go back one level # (crm(live)#)
quit exit the program # crm
crm(live)resource# cd ..
crm(live)# node
crm(live)node# help
Node management and status commands.
Available commands:
status show nodes status as XML # xml
show show node #
standby put node into standby # (standby FQDN)
online set node online #
maintenance put node into maintenance mode
ready put node into ready mode
fence fence node #
clearstate Clear node state #
delete delete node #
attribute manage attributes
utilization manage utilization attributes
status-attr manage status attributes
help show help (help topics for list of topics)
end go back one level
quit exit the program
crm(live)node# cd ..
crm(live)# ra
crm(live)ra# help
Available commands:
classes list classes and providers #
list list RA for a class (and provider)#
meta show meta data for a RA # ( meta ocf:heartbeat:IPaddr2)
providers show providers for a RA and a class
help show help (help topics for list of topics)
end go back one level
quit exit the program
注意:
これらの命令で使われている単語はすべて簡単ですが、私はよく使われている表記をします.今勉強が終わったばかりで、はっきり覚えていますが、後である日ここの命令に盲区が現れたかもしれません.△自分の記憶力を過小評価してはいけない.
五、実例プレゼンテーション
注意:
1、本機環境
システム:
centos 6.5 x86_64
ノード:
essun.node2.com 192.168.1.111
essun.node3.com 192.168.1.108
各ノードに必要なソフトウェアとリソース
仮想ip 192.168.1.1100
2つのノードにhttpdサービスをそれぞれインストールし、デフォルトのテストページを追加し、テストが完了した後、サービス起動の自動起動を禁止します.
nfsリソースをマウントし、nfsを提供するホストは192.168.1.1110です.
2、資源の定義
crm(live)configure# property stonith-enabled=false #( , stonith )
crm(live)configure# verify #( )
crm(live)configure# commit #( )
crm(live)configure# show #( )
node essun.node2.com
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false"
crm(live)configure# property no-quorum-policy=ignore
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# primitive webip ocf:heartbeat:IPaddr params ip=192.168.1.100
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false"
注記:
以上の文は4つのセグメントに分けることができます.
セグメント1:primitive:リソースで使用されるコマンドを定義する
第2段:webip:リソースに名前を付ける
第3段ocf:heartbeat;IPaddr:使用するリソースエージェントのカテゴリ、誰が提供するエージェント
(ここではcrm ra#listの後にRAの4種類のカテゴリを使用して、使用するエージェントが誰によって提供されたかを確認できます)
セクション4:params:定義されたパラメータを指定する
ip:パラメータ名
まずraでファイルシステムで使用されるリソースエージェントを検索します
crm(live)configure ra# classes
lsb
ocf / heartbeat pacemaker
service
stonith
crm(live)configure ra# list ocf
CTDB ClusterMon Delay Dummy Filesystem HealthCPU
HealthSMART IPaddr IPaddr2 IPsrcaddr LVM MailTo
Route SendArp Squid Stateful SysInfo SystemHealth
VirtualDomain Xinetd apache conntrackd controld dhcpd
ethmonitor exportfs mysql named nfsserver pgsql
ping pingd postfix remote rsyncd symlink
crm(live)configure ra# providers Filesystem
heartbeat
これにより、ファイルシステムのリソースエージェントはocf:heartbeatによって提供されることがわかる.
このリソースエージェントのパラメータを表示
crm(live)configure ra# meta ocf:heartbeat:Filesystem
Manages filesystem mounts (ocf:heartbeat:Filesystem)
Resource script for Filesystem. It manages a Filesystem on a
shared storage medium.
The standard monitor operation of depth 0 (also known as probe)
checks if the filesystem is mounted. If you want deeper tests,
set OCF_CHECK_LEVEL to one of the following values:
10: read first 16 blocks of the device (raw read)
This doesn't exercise the filesystem at all, but the device on
which the filesystem lives. This is noop for non-block devices
such as NFS, SMBFS, or bind mounts.
20: test if a status file can be written and read
The status file must be writable by root. This is not always the
case with an NFS mount, as NFS exports usually have the
"root_squash" option set. In such a setup, you must either use
read-only monitoring (depth=10), export with "no_root_squash" on
your NFS server, or grant world write permissions on the
directory where the status file is to be placed.
Parameters (* denotes required, [] the default):
device* (string): block device
The name of block device for the filesystem, or -U, -L options for mount, or NFS mount specificatio
n.
directory* (string): mount point
The mount point for the filesystem.
fstype* (string): filesystem type
The type of filesystem to be mounted.
........... .......
ここに*は必須パラメータを示しています.これで定義できます.
crm(live)configure# primitive webnfs ocf:heartbeat:Filesystem params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" op monitor interval=60s timeout=60s op start timeout=60s op stop timeout=60s
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false"
注記:
primitive#定義リソースコマンド
Webnfs#リソースID
ocf:heartbeat:Filesystem#リソースエージェント(RA)
params device="192.168.1.1110:/share"#共有ディレクトリ
Directory=「/var/www/html」#マウントディレクトリ
fstype="nfs" #ファイルの種類
op monitor#このwebnfsを監視する
interval=60 s#間隔時間
timeout=60 s#タイムアウト時間
op start timeout=60 s#起動タイムアウト時間
op stop timeout=60 s#停止タイムアウト時間
Webサービスリソースの定義
crm(live)configure# primitive webserver lsb:httpd
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
primitive webserver lsb:httpd
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false"
複数のリソースをすべて統合(バインドして実行)
crm(live)configure# group webservice webip webnfs webserver
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
primitive webserver lsb:httpd
group webservice webip webnfs webserver
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false"
別の方法で、有効なリソース情報を確認します.
crm(live)configure# cd ..
crm(live)# status
Last updated: Sat Apr 26 01:51:45 2014
Last change: Sat Apr 26 01:49:54 2014 via cibadmin on essun.node3.com
Stack: classic openais (with plugin)
Current DC: essun.node2.com - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
3 Resources configured
Online: [ essun.node2.com essun.node3.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started essun.node2.com
webnfs (ocf::heartbeat:Filesystem): Started essun.node2.com
webserver (lsb:httpd): Started essun.node2.com
上図はすべてのリソースがnode 2にあることを示しています.つまり192.168.1.1.1111というipにcurlコマンドでアクセスして、効果を見てみましょう.
[root@bogon share]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:63:4A:25
inet addr:192.168.1.110 Bcast:255.255.255.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe63:4a25/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2747 errors:0 dropped:0 overruns:0 frame:0
TX packets:1161 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:212090 (207.1 KiB) TX bytes:99626 (97.2 KiB)
[root@bogon share]# curl http://192.168.1.111
NFS
Node 2ノードの障害をシミュレートし、リソースが移行するかどうかを確認します.
crm(live)node# standby essun.node2.com
crm(live)# status
Last updated: Sat Apr 26 02:05:24 2014
Last change: Sat Apr 26 02:04:17 2014 via crm_attribute on essun.node3.com
Stack: classic openais (with plugin)
Current DC: essun.node2.com - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
3 Resources configured
Node essun.node2.com: standby
Online: [ essun.node3.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started essun.node3.com
webnfs (ocf::heartbeat:Filesystem): Started essun.node3.com
webserver (lsb:httpd): Started essun.node3.com
もう一度curl
[root@bogon share]# curl http://192.168.1.111
curl: (7) couldn't connect to host
[root@bogon share]# curl http://192.168.1.100
NFS
[root@bogon share]# curl http://192.168.1.108
NFS
注記:
最初のcurlはhttpdサービスがノードnode 2上で実行されなくなったことを示した.
2回目のcurlはvipを使用してマウントされたページにアクセスできるかどうかを示し、node 2ラインオフでサービスが終了していないことを示した.
3回目のcurlはnode 3 ipを用いても同様にサービスにアクセスできることを示し,サービスがnode 3上で実行されていると判断する可能性がある.
この場合、node 2再オンラインサービスがnode 2に切り替えられない場合は、node 2をオンラインにした後に切り替えることができるようにするには、位置コンストレイントを使用して重みを指定します.
次に2つ目の方法でリソースを限定し、まずグループ定義を削除し、crm configure#editでcibファイルを編集し、グループ定義のエントリを削除すればよい.
crm(live)node# online essun.node2.com
crm(live)# status
Last updated: Sat Apr 26 02:20:13 2014
Last change: Sat Apr 26 02:19:29 2014 via crm_attribute on essun.node2.com
Stack: classic openais (with plugin)
Current DC: essun.node2.com - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
3 Resources configured
Online: [ essun.node2.com essun.node3.com ]
Resource Group: webservice
webip (ocf::heartbeat:IPaddr): Started essun.node3.com
webnfs (ocf::heartbeat:Filesystem): Started essun.node3.com
webserver (lsb:httpd): Started essun.node3.com
サービスはやはり帰ってこないで、私がどのようにそれを回収することを見ますa_c!
最初のステップは、グループ制限を削除し、editコマンドを使用するのが最善の方法であり、コマンドも使用できます.
crm(live)resource# stop webservice #
crm(live)configure# delete webservice #
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com \
attributes standby="off"
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
primitive webserver lsb:httpd
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1398450597"
この时、自分はグループの定义がなくて、このように私の“计画”を行うことができます
配列コンストレイントの定義(一緒にいる可能性)
crm(live)configure# colocation webserver-with-webnfs-webip inf: webip webnfs webserver
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com \
attributes standby="off"
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
primitive webserver lsb:httpd
colocation webserver-with-webnfs-webip inf: webip webnfs webserver
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1398450597"
注記:
colocation:整列拘束コマンド
Webserver-with-webnfs-webip:#制約名(ID)
inf:#(可能性、infは永久に一緒にいることを示し、数値であってもよい)
webip webnfs webserver:#リソース名
リソース起動順序の定義
crm(live)configure# order ip_before_webnfs_before_webserver mandatory: webip webnfs webserver
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com \
attributes standby="off"
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
primitive webserver lsb:httpd
colocation webserver-with-webnfs-webip inf: webip webnfs webserver
order ip_before_webnfs_before_webserver inf: webip webnfs webserver
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1398450597"
注記:
order:シーケンスコンストレイントのコマンド
ip_before_webnfs_before_Webserver#コンストレイントID
mandatory:#指定レベル(ここには3つのレベルがあります:mandatory:強制、Optional:オプション、Serialize:シーケンス化)
Webip webnfs webserver#リソース名、ここで書く順番はかなり重要です
位置コンストレイントの定義
crm(live)configure# location webip_and_webnfs_and_webserver webip 500: essun.node2.com
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com \
attributes standby="off"
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
primitive webserver lsb:httpd
location webip_and_webnfs_and_webserver webip 500: essun.node2.com
colocation webserver-with-webnfs-webip inf: webip webnfs webserver
order ip_before_webnfs_before_webserver inf: webip webnfs webserver
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1398450597"
注記:
location:位置拘束コマンドいちこうそくこまんど
webip_and_webnfs_and_webserver:コンストレイント名
webip 500:essun.node 2.com:そのリソースにどのくらいの重みを指定するかそのノード
デフォルトのリソース属性の定義
crm(live)configure# rsc_defaults resource-stickiness=100
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node essun.node2.com \
attributes standby="off"
node essun.node3.com
primitive webip ocf:heartbeat:IPaddr \
params ip="192.168.1.100"
primitive webnfs ocf:heartbeat:Filesystem \
params device="192.168.1.110:/share" directory="/var/www/html" fstype="nfs" \
op monitor interval="60s" timeout="60s" \
op start timeout="60s" interval="0" \
op stop timeout="60s" interval="0"
primitive webserver lsb:httpd
location webip_and_webnfs_and_webserver webip 500: essun.node2.com
colocation webserver-with-webnfs-webip inf: webip webnfs webserver
order ip_before_webnfs_before_webserver inf: webip webnfs webserver
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6_5.3-368c726" \
cluster-infrastructure="classic openais (with plugin)" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore" \
last-lrm-refresh="1398450597"
rsc_defaults $id="rsc-options" \
resource-stickiness="100"
注記:
この定義はクラスタ内の各リソースのデフォルトのスティッキーを表し、リソースサービスが現在のノードにない場合にのみスティッキーが有効になります.たとえば、ここでは3つのリソースwebip、webnfs、webserverを定義し、各リソースに対するスティッキーが100になると、加算すると300になります.これまで定義されていたnode 2の位置制約の値は500で、node 2がダウンタイムした後、再オンラインになります.これでnode 2に切り替わりました.
最後にステータスを見て、リソースはnode 2上で実行され、node 2が故障します.
crm(live)# status
Last updated: Sat Apr 26 03:14:30 2014
Last change: Sat Apr 26 03:14:19 2014 via cibadmin on essun.node3.com
Stack: classic openais (with plugin)
Current DC: essun.node2.com - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
3 Resources configured
Online: [ essun.node2.com essun.node3.com ]
webip (ocf::heartbeat:IPaddr): Started essun.node2.com
webnfs (ocf::heartbeat:Filesystem): Started essun.node2.com
webserver (lsb:httpd): Started essun.node2.com
crm(live)# node
crm(live)node# standby essun.node2.com
リソースはnode 3で実行されました
crm(live)# status
Last updated: Sat Apr 26 03:18:17 2014
Last change: Sat Apr 26 03:15:20 2014 via crm_attribute on essun.node3.com
Stack: classic openais (with plugin)
Current DC: essun.node2.com - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
3 Resources configured
Node essun.node2.com: standby
Online: [ essun.node3.com ]
webip (ocf::heartbeat:IPaddr): Started essun.node3.com
webnfs (ocf::heartbeat:Filesystem): Started essun.node3.com
webserver (lsb:httpd): Started essun.node3.com
もう2回curl
[root@bogon share]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:63:4A:25
inet addr:192.168.1.110 Bcast:255.255.255.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe63:4a25/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2747 errors:0 dropped:0 overruns:0 frame:0
TX packets:1161 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:212090 (207.1 KiB) TX bytes:99626 (97.2 KiB)
[root@bogon share]# curl http://192.168.1.100
NFS
[root@bogon share]# curl http://192.168.1.108
NFS
[root@bogon share]#
Node 2を再オンラインにしてリソースが戻ってくるかどうかを確認します
crm(live)node# online essun.node2.com
crm(live)node# cd ..
crm(live)# status
Last updated: Sat Apr 26 03:21:46 2014
Last change: Sat Apr 26 03:21:36 2014 via crm_attribute on essun.node3.com
Stack: classic openais (with plugin)
Current DC: essun.node2.com - partition with quorum
Version: 1.1.10-14.el6_5.3-368c726
2 Nodes configured, 2 expected votes
3 Resources configured
Online: [ essun.node2.com essun.node3.com ]
webip (ocf::heartbeat:IPaddr): Started essun.node2.com
webnfs (ocf::heartbeat:Filesystem): Started essun.node2.com
webserver (lsb:httpd): Started essun.node2.com
もう3回curl
[root@bogon share]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:63:4A:25
inet addr:192.168.1.110 Bcast:255.255.255.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe63:4a25/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2747 errors:0 dropped:0 overruns:0 frame:0
TX packets:1161 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:212090 (207.1 KiB) TX bytes:99626 (97.2 KiB)
[root@bogon share]# curl http://192.168.1.100
NFS
[root@bogon share]# curl http://192.168.1.108
curl: (7) couldn't connect to host
[root@bogon share]# curl http://192.168.1.111
NFS
[root@bogon share]#
注記:
1.100は仮想クラスタIP
1.108はessun.node 3.com
1.111はessun.node 2.com
事実が証明しているように,資源はやはり奪還された.
=============================================
PS:
英語が下手で、注釈が正確ではないかもしれません.皆さん、どうぞお許しください.c~~~~~~