日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

corosync+pacemaker+crmsh配置高可用集群。

發布時間:2025/5/22 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 corosync+pacemaker+crmsh配置高可用集群。 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

實驗環境:

admin1.tuchao.com 192.168.18.100? ansible管理節點

admin2.tuchao.com 192.168.18.101? 集群節點一 ?

admin3.tuchao.com 192.168.18.199? 集群節點二


安裝: yum?install corosync pacemaker -y

復制配置文件

  • cp corosync.conf.example corosync.conf

  • vim corosync.conf

編輯配置文件:

compatibility: whitetank?
是否兼容0.8版本的corosync
totem {
定義集群之間心跳信息傳遞層?
?version: 2 ----版本號
??????? secauth: on ---是否啟用安全認證
??????? threads: 0?? ---啟用多少個線程處理心跳信息傳遞,0為自動。
??????? interface {
??????????????? ringnumber: 0?? --報文循環次數
??????????????? bindnetaddr: 192.168.18.0? --綁定的網絡地址
??????????????? mcastaddr: 226.94.1.2?? --多播地址
??????????????? mcastport: 5405?? ---多播端口
??????????????? ttl: 1
??????? }
}

logging {
??????? fileline: off
??????? to_stderr: no? --心跳信息是否輸出到屏幕
??????? to_logfile: yes
??????? to_syslog: no? ---是否發送給/var/log/messages
??????? logfile: /var/log/cluster/corosync.log
??????? debug: off? --是否開啟調試
??????? timestamp: on?? --是否開啟當前系統時間的時間戳。
??????? logger_subsys {
??????????????? subsys: AMF?? --定義openais規范
??????????????? debug: off
??????? }
}

amf {
??????? mode: disabled
}
service {???定義pacemaker為corosync的插件。
?ver:?0
?name:?pacemaker
}
aisexec?{
?user:root
?group:root
}

生成安全認證文件,這個命令需要取1024位隨機數,我們可以另起一個終端重裝一個軟件來產生隨機數。

  • corosync-keygen

安裝資源管理器的配置接口程序:

crmsh-1.2.6-4.el6.i686.rpm

pssh-2.3.1-2.el6.i686.rpm

關閉NetworkManager,并開機禁用此服務。

/etc/init.d/NetworkManager stop

chkconfig NetworkManager off

啟動服務

  • service corosync start

?

CRM命令的使用:

  • crm status //顯示集群狀態信息

  • crm_mon

  • crm_verify -L //顯示配置文件是否有語法錯誤

  • crm 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 resource help

At this level resources may be managed.

All (or almost all) commands are implemented with the CRM tools
such as `crm_resource(8)`.

Available commands:

?status,show,list 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,move???? migrate a resource to another node --資源遷移
?unmigrate,unmove 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 --刷新Cib
?reprobe????????? probe for resources not started by the CRM? 探測沒有啟動的資源
?trace??????????? start RA tracing
?untrace????????? stop RA tracing
?help,??????????? show help (help topics for list of topics)
?end,cd,up??????? go back one level
?quit,bye,exit??? exit the program

?

  • crm node help

    Node management and status commands.

    Available commands:

    ?? ?status?????????? show nodes' status as XML --顯示節點狀態
    ?? ?show,list??????? show node
    ?? ?standby????????? put node into standby? --設置當前節點為備用節點
    ?? ?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,cd,up??????? go back one level
    ?? ?quit,bye,exit??? exit the program



  • crm configure property stonith-enabled=false?? --關閉stonith設備

  • crm ra help

classes list classes and providers --列出提供的RA類型

list? ? list RA for a class (and provider) --顯示某個RA類型所提供的資源代理

meta????show meta data for a RA --顯示一個RA的基本信息


定義一個IP資源:

crm configure

primitive webip ocf:IPaddr params ip=192.168.18.200


定義完后可以用show查看

沒錯誤的話,之后可以使用commit提交。

查看狀態:

  • crm status

  • crm resource status

停止資源:

  • crm resource stop webip

啟動資源:

  • crm resource start webip

將當前節點設為備用,這時候資源就會轉移到節點二。

  • crm node standby

我們把httpd加入到可管理資源:

  • crm configure primitive webserver lsb:httpd

定義資源組:

  • crm configure group webservice webip webserver

定義位置約束:

  • crm configure location webservice_prefer_node2 webservice 500: admin3.tuchao.com

  • crm configure

  • verify

  • commit

定義順序約束:

  • crm

  • configure

  • order webserver_after_webip mandatory: webip webserver

  • verify

  • commit

order 名稱 mandatory: webip webserver 注:這里的mandatory表示無限大的值(強制)

把優先啟動的資源寫在前面。

  • show xml

<constraints>

? ? ? <rsc_location id="webservice_prefer_node2" rsc="webservice" score="500" node="admin3.tuchao.com"/>

? ? ? <rsc_order id="webip_before_webserver" score="INFINITY" first="webip" then="webserver"/>

? ? </constraints>

定義組合約束:

  • colocation webip_with_webserver inf: webip webserver

  • show xml

<rsc_colocation id="webip_with_webserver" score="INFINITY" rsc="webip" with-rsc="webserver"/>

這里的with-rsc="webserver"是指已webserver為準,如果webip啟動成功,webserver啟動失敗,那webip也會失效的。

定義一個文件系統資源:

  • crm configure

  • primitive webstore ocf:Filesystem params device='192.168.18.160:/webdata' directory='/var/www/html' fstype='nfs' op start timeout=60 op stop timeout=60

  • verify

  • commit

將資源加入到webservice組。

  • edit

  • verify

  • commit

  • show

配置組合約束

  • crm configure

  • colocation webip_before_webstore inf: webip webstore

  • colocation webstore_webserver inf: webstore webserver

  • show

這樣配置就基本完成了,你會發現當你使用crm node standby把當前節點設置為備用后,另一個節點就會繼承資源繼續提供服務。

資源監控:

????默認情況下,集群并不會檢查資源的健康狀態,如果要實現此功能,需要專門為資源定義monitor功能,資源操作可定義的屬性有:

????id:資源操作ID,必須唯一。
????name:資源操作的動作,可用動作有minitor、start、和stop。

執行資源的監控操作使用mintor:

????interval:資源操作的時間間隔,默認為0,即不執行操作。

????timeout:確定某動作作為失敗的超時時長。

????on-fail:正在執行的動作失敗時要采取的動作。

可用值如下:

????????ignore:忽略

????????block:忽略

????????stop:停止資源

????????restart:重啟資源,也有可能會在其他節點上啟動。

????????frence:將此節點關閉

????????standby:將其所在的節點轉換為standby模式

enabled:是否啟用,true,false。



有問題歡迎與我交流QQ1183710107

總結

以上是生活随笔為你收集整理的corosync+pacemaker+crmsh配置高可用集群。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。