corosync+pacemaker 實現高可用集羣(三)

corosync
html


  OpenAIS:Open Application Interface Standard 開放的應用程序接口標準node


  corosync 屬於OpenAIS中的一類底層心跳層實現高可用集羣的工具,功能與咱們前面講到的heartbeat相同linux


corosync版本web


   1.0版本:不具有投票能力;經過corosync+cman作底層心跳層實現高可用HA,cman做爲corosync的插件存在,提供投票能力算法


   2.0版本: 具有投票能力;corosync單獨實現底層心跳層的功能shell


高可用解決方案vim

# packmaker 資源管理器
# corosync  底層心跳層

高可用解決方案實現安全


 架構圖bash

wKiom1NWWsTA91jwAABQqsuiLzg585.jpg

#node3 172.16.13.3
#node4 172.16.13.4
#clinet 172.16.250.223




資源規劃網絡

VIP   172.16.13.10
httpd


軟件程序

corosync-1.4.1-17
pacemaker-1.1.10-14
crmsh-1.2.6-4
pssh-2.3.1-2
#1.1版本的pacemaker做爲1.4.1版本corosync的插件運行
#1.2.6版本的crmsh單獨程序安裝,並不是由pacemaker安裝而安裝
#2.3.1版本的pssh 屬於crmsh安裝所依賴的軟件包
總結:corosync 作心跳信息層  pacemaker以插件的形式做爲資源管理器
      crmsh 做爲資源配置接口



配置過程

1 配置雙節點時間同步、本地主機無需DNS能夠解析主機、交換ssh密鑰實現無密鑰通訊
#以上必備步驟此處再也不累述,詳情請參照個人博客
http://jungege.blog.51cto.com/4102814/1399829


2 各個節點安裝 corosync、pacemaker、crmsh、pssh
# yum -y install corosync
# yum -y install pacemaker
# yum -y install crmsh-1.2.6-4.el6.x86_64.rpm pssh-2.3.1-2.el6.x86_64.rpm


3 node3上編輯corosync配置文件
# 提供配置文件
# cp /etc/corosync/corosync.conf.example  /etc/corosync/corosync.conf
# 編輯配置文件
# vim  /etc/corosync/corosync.conf

wKiom1NWYiez6w6iAAF1inVUNnU834.jpg

以上參數分析
  totem:圖騰,是corosync協議;存在版本號     
 # version: 2   版本號2
 # secauth: on  安全機制,防止組播等
 # threads:0    啓動的線程
 # interface       
 # ringnumber   網卡環號,防止網卡迴路;
 # bindnetaddr  綁定的網絡地址
 # mcastaddr    組播地址224.0.1.0 ~ 238.255.255.255 用戶可用組播地址(臨時組播地址,全網有效)
 # mcastport    組播端口
 logging:日誌
 # fileline:   off
 # to_stderr: no
 # to_logfile: yes
 # to_syslog:no
 # logfile: /var/log/cluster/corosync.log 該目錄可能不存在,須要建立
 # debug : off
 # timestamp : off  時間戳


#編輯配置文件添加以下內容,實現pacemaker做爲corosync的插件運行
#vim  /etc/corosync/corosync.conf


wKioL1NWavKhLr2fAAB2pVS230c916.jpg

4 提供authkeys 保證節點間通訊安全
#corosync-keygen    生成authkeys基於HAMC單項加密算法
#chmod authkey 400  設置authkeys權限爲400或者600
#scp -p authkey corosync.conf node4:/etc/corosync/ 拷貝authkeys和corosync.conf配置文件到node2節點上
  注意
#(一)corosync.conf 中的bindip綁定的網絡 與 mcust組播地址 實現各個節點在心跳信息層的心跳信息與事務信息的偵聽聯繫
#(二)authkys 保證各個節點在心跳信息層傳輸信息和事務的安全



5 各個節點啓動corosync服務
# service corosync start



6 設置集羣資源屬性
  node3上配置
# crm      進入crm shell
# crm(live)# configure  進入二級目錄 配置目錄
# crm(live)configure# property stonith-enabled=false 不使用stonith設備,咱們沒有stonith設備即無資源隔離設備
# crm(live)configure# property  no-quorum-policy=ignore  忽略法定票數策略,兩個節點高可用中,一個節點掛掉另外一個節點依然可用
# crm(live)configure# default-resource-stickiness=100 設置資源的默認粘性
# crm(live)configure# verify 檢測語法是否錯誤,沒有返回信息則無錯誤
# crm(live)configure# commit 提交任務



7 定義主資源 VIP  httpd
  node3上配置
# crm
# crm(live)# configure
# crm(live)configure# primitive webserver lsb:httpd    ----配置一個主資源名稱爲webservier  ,lsb爲資源代理類別 httpd爲資源代理 無其餘參數
# crm(live)configure# primitive webip ocf:heartbeat:IPaddr  params ip=172.16.13.10 op monitor interval=30s timeout=20s  on-fail=restart 配置一個主資源名稱爲webip,資源代理類別爲ocf:heartbeat 資源代理爲IPaddr參數params ,後續的全部參數以此爲VIP地址172.16.13.10,op表明動做 monitor設置一個監控 每30s檢測一次,超時時間爲20s,一旦故障就重啓
# crm(live)configure# verify
# crm(live)configure# commit



8 定義組資源,即將剛剛建立的兩個資源webip,webserver添加到組,實現資源綁定
 node3上配置
# crm
# crm(live)# configure
# crm(live)configure# group webservice webip webserver --組名爲webservice,組中的資源爲webip,webserver。
# crm(live)configure# verify
# crm(live)configure# commit


9 查看節點及資源狀態
# crm status

wKiom1NWdJWyRdrJAAIk04vCvo4052.jpg

10 node3 node4提供web頁面
 # node3
 # vim /var/www/html/index.html
   <h1>node3.linux.com</h1>
 # node4
 # vim /var/www/html/index.html
   <h1>node4.linux.com</h1>


   客戶端測試

    wKioL1NWdiuiUHTVAACTuGLgrMk844.jpg


   

將node4設爲備用 node3上線
# crm
# crm(live)# node
# crm(live)node# standby node4.linux.com
# crm(live)node# online node3.linux.com


   客戶端測試

   

   wKiom1NWeAfiycnAAABjL6jZeTk232.jpg



   高可用集羣設置成功


 

# 總結:經過使用corosync心跳信息工具+pacemaker資源管理器+crmsh資源配置接口實現高可用集羣,請注意各個程序包的版本;


 


  PS:水平有限,若有疑問請指出!

相關文章
相關標籤/搜索