heartbeat 編譯安裝配置

来源:http://www.cnblogs.com/jym1/archive/2017/12/20/8073164.html
-Advertisement-
Play Games

一、heartbeat介紹 heartbeat是HA高可用集群的一個重要組件,heartbeat實現了資源轉移和心跳信息傳遞。它的常用組合方式為heartbeat v1,heartbeat v2+crm,heartbeat v3 + pacemaker,目前版本為v3版本。 二、編譯前準備 hear ...


一、heartbeat介紹

    heartbeat是HA高可用集群的一個重要組件,heartbeat實現了資源轉移和心跳信息傳遞。它的常用組合方式為heartbeat v1,heartbeat v2+crm,heartbeat v3 + pacemaker,目前版本為v3版本。

 

二、編譯前準備

    heartbeat官方站點http://hg.linux-ha.org/

  Cluster Glue官方站點https://github.com/ClusterLabs/cluster-glue

  Resource Agents官方站點 https://github.com/ClusterLabs/resource-agents

 

 node1:192.168.0.15

 node2:192.168.0.16

 配置集群前提:

    (1)各節點時間一致,便於心跳信息傳遞,使用ntp實現

     (2)節點間需要通過主機名互相通信,必須解析主機至IP地址

        (a)建議名稱解析功能使用hosts文件來實現

        (b)通信中使用的名字與節點名字必須保持一致 “uname -n” 或hostname展示出的名字保持一致

    (3)考慮仲裁設備是否會用到

    (4)建立各節點之間的root用戶能夠給予密鑰認證

    (5)定義為集群中的資源,不能開機啟動

 

#使用ntpdate命令同步時間,並建立周期性任務
#可使用任意節點伺服器作為ntp時間伺服器,如各節點可上公網,可直接指定公網ntp伺服器
  
1、安裝ntp
[root@node2 ~]# yum install -y ntp
[root@node2 ~]# vim /etc/ntp.conf           #修改配置文件允許本網段客戶端獲取地址
將下麵的語句
restrict default kod nomodify notrap nopeer noquery
修改為
restrict default nomodify 
restrict 192.168.0.0 mask 255.255.255.0 nomodify
  
[root@node2 ~]# service ntpd start
Starting ntpd:                                             [  OK  ]
  
查看同步過程
[root@node2 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*202.118.1.81    202.118.1.47     2 u   30   64    1   92.249    8.602   0.714
 202.112.31.197  .INIT.          16 u    -   64    0    0.000    0.000   0.000
  
2、客戶端創建周期任務,每3秒同步時間
[root@node1 ~]# crontab -e
*/3 * * * * /usr/sbin/ntpdate 192.168.0.16 &> /dev/null
[root@node1 ~]# service crond start
  
  
#手動同步成功,因ntp一般為自動,手動前kill掉所有ntp進程即可
[root@node1 ~]# ntpdate 192.168.0.16
14 Nov 20:26:09 ntpdate[3786]: adjust time server 192.168.0.16 offset -0.004440 sec
  
3、時間同步
[root@node2 ~]# date; ssh 192.168.0.15 'date'
Mon Nov 14 20:36:17 CST 2016
root@192.168.0.15's password: 
Mon Nov 14 20:36:20 CST 2016
 
[root@node2 ~]# vim /etc/hosts
192.168.0.15   node1
192.168.0.16   node2
 
1、生成密鑰對
[root@node1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
a8:ad:2c:23:83:60:ff:36:73:9d:09:24:37:ae:da:c9 root@centfils
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|     . =         |
|      * S        |
|..   o o         |
|+ . . o o o      |
|+ ooo*.. +       |
| o +*E+          |
+-----------------+
  
2、把公鑰傳輸至遠程伺服器對應用戶的家目錄
[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.0.16
The authenticity of host '192.168.0.16 (192.168.0.16)' can't be established.
RSA key fingerprint is e5:84:6c:f7:c0:60:3d:0b:39:b6:1e:12:0d:48:8b:07.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.16' (RSA) to the list of known hosts.
root@192.168.0.16's password: 
Now try logging into the machine, with "ssh '[email protected]'", and check in:
  
  .ssh/authorized_keys
  
to make sure we haven't added extra keys that you weren't expecting.
  
3、測試
[root@node2 ~]# date; ssh root@192.168.0.15 'date'
Mon Nov 14 21:02:30 CST 2016
Mon Nov 14 21:02:30 CST 2016
準備工作

 

三、編譯安裝  

 1、安裝依賴包(node1和node2同步安裝)

 

[root@node2 ~]# yum -y install autoconf automake gcc-c++ asciidoc libxslt-devel libtool libtool-ltdl-devel libxml2 libxml2-devel bzip2-devel glib2-devel mercurial *openssl* net-snmp OpenIPMI flex bison e2fsprogs-devel

 

   2、源碼編譯安裝

下載地址http://linux-ha.org/wiki/Download
#下載heartbeat
[root@node2 ~]# wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2
#下載cluster glue
[root@node2 ~]# wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2
#下載cluster resource agents    註意:需要FQ
[root@node1 ~]# wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz

  3、創建用戶與組

[root@node1 ~]# groupadd haclient
[root@node1 ~]# useradd -g haclient hacluster -M -s /sbin/nologin

 4、編譯

cluster glue
[root@node1 ~]# tar xf 0a7add1d9996.tar.bz2 
[root@node1 ~]# cd Reusable-Cluster-Components-glue--0a7add1d9996/
[root@node1 Reusable-Cluster-Components-glue--0a7add1d9996]# ./autogen.sh
]# ./configure --prefix=/usr/local/heartbeat --sysconfdir=/etc/heartbeat libdir=/usr/local/heartbeat/lib64 LIBS='/lib64/libuuid.so.1' --with-daemon-user=hacluster --with-daemon-group=haclient
#LIBS如果是32位系統自行更改
]# make && make install
 
resource agents
[root@node1 ~]# tar xf resource-agents-3.9.6.tar.gz
[root@node1 ~]# cd resource-agents-3.9.6
[root@node1 resource-agents-3.9.6]# ./autogen.sh 
[root@node1 resource-agents-3.9.6]# ./configure --prefix=/usr/local/heartbeat --sysconfdir=/etc/heartbeat libdir=/usr/local/heartbeat/lib64 CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib64 LIBS='/lib64/libuuid.so.1' --with-daemon-user=hacluster --with-daemon-group=haclient
[root@node1 resource-agents-3.9.6]# make && make install
 
heartbeat
[root@node1 ~]# tar xf 958e11be8686.tar.bz2 
[root@node1 ~]# cd Heartbeat-3-0-958e11be8686/
[root@node1 Heartbeat-3-0-958e11be8686]# ./bootstrap 
]# ./configure --prefix=/usr/local/heartbeat --sysconfdir=/etc/heartbeat CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib64 LIBS='/lib64/libuuid.so.1' --with-daemon-user=hacluster --with-daemon-group=haclient
 
#編譯報錯,路徑重覆,google後得出刪除 glue_config.h 中配置文件路徑即可
[root@node1 Heartbeat-3-0-958e11be8686]# make && make install
../include/config.h:390:1: error: this is the location of the previous definition
gmake[1]: *** [strlcpy.lo] Error 1
gmake[1]: Leaving directory `/root/Heartbeat-3-0-958e11be8686/replace'
make: *** [all-recursive] Error 1
 
[root@node1 Heartbeat-3-0-958e11be8686]# vim /usr/local/heartbeat/include/heartbeat/glue_config.h
define HA_HBCONF_DIR "/usr/local/heartbeat/etc/ha.d/"
#刪除最後一行即上行內容


 

  5、複製配置文件至/etc//heartbeat/ha.d中

[root@node1 Heartbeat-3-0-958e11be8686]# cp doc/ha.cf /etc/heartbeat/ha.d/
[root@node1 Heartbeat-3-0-958e11be8686]# cp doc/haresources /etc/heartbeat/ha.d/
[root@node1 Heartbeat-3-0-958e11be8686]# cp doc/authkeys /etc/heartbeat/ha.d/

  6、將heartbeat加入系統服務,並開機啟動

[root@node1 ~]# chkconfig --add heartbeat
#之後可以用service來進行start|stop操作了
[root@node1 ~]# chkconfig heartbeat on

     7、修改認證文件許可權為600,不然heartbeat無法工作

[root@node1 ~]# chmod 600  /etc/heartbeat/ha.d/authkeys

  8、為resource-agents建立腳本軟連接

[root@node1 ~]# ln -s /usr/local/heartbeat/usr/lib/ocf /usr/lib/ocf

四、配置文件

1、配置authkeys文件,指明啟用何種演算法,使用何種密鑰,本文件須更改許可權為400
auth 2
#1 crc
2 sha1 2SIEok+gXAvB6G4seA8mhw
#3 md5 Hello!
  
生成隨機字元串作為密鑰
[root@node2 ~]# openssl rand -base64 16
2SIEok+gXAvB6G4seA8mhw==
  
  
2、配置ha.cf文件,定義高可用集群的基本工作方式
  
定義日誌文件位置(二選一) logfacility為將日誌交由syslog管理     
logfile        /var/log/ha-log
#logfacility     local0
多長時間發送一次心跳信息,預設為2秒
#keepalive 2
多長時間宣佈某節點死亡,預設30秒
#deadtime 30
多長時間警告對方心跳信息延遲了,預設10秒
#warntime 10
第一次死去時間,避免因網路問題導致宣佈死亡
#initdead 120
使用udp694埠傳遞心跳,並選擇哪種方式傳遞心跳
#udpport        694
串列線纜傳遞心跳
#serial /dev/ttyS0      # Linux
#serial /dev/cuaa0      # FreeBSD
#serial /dev/cuad0      # FreeBSD 6.x
#serial /dev/cua/a      # Solaris
串列線纜的工作頻率
#baud   19200
廣播傳遞心跳
#bcast  eth0            # Linux
#bcast  eth1 eth2       # Linux
#bcast  le0             # Solaris
#bcast  le1 le2         # Solaris
多播傳遞心跳,網卡必須支持多播,ifconfig | grep MULTICAST
mcast eth0 225.0.0.1 694 1 0          #埠694,TTL為1,不允許回傳為0
#啟用網卡支持多播
[root@node1 ha.d]# ip link set eth0 multicast on
  
單薄傳遞心跳
#ucast eth0 192.168.1.2
自動故障轉回
auto_failback on
指明節點
#node   ken3
#node   kathy
node    node1
node    node2
指明網關為ping node設備(仲裁設備)
#ping 10.10.10.254
ping 192.168.0.1
指明一個組為ping node設備(仲裁設備)
#ping_group group1 10.10.10.254 10.10.10.253
指明節點間傳送的壓縮演算法
compression     bz2
指明節點間傳送數據壓縮的最小數據為2KB
compression_threshold 2
 
3、配置haresources文件,定義集群資源
直接加入資源
node1 192.168.0.17/24/eth0/192.168.0.255 httpd
 
4、將httpd設置為開機不啟動
[root@node1 ha.d]# chkconfig httpd off
 
5、啟動服務
[root@node1 ~]# service heartbeat start

以上所有配置均所有節點一致

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 現在的公司一般都會有很多內部管理系統,比如OA、ERP、CRM、郵件系統等。員工入職之後如果每個系統都創建一個賬號和密碼,首先員工記系統賬號就是一件非常頭疼的事情,如果公司有一百個系統那就得創建一百個賬號(所在的公司就有估計200個系統、8萬員工)。就算我們用日記本把賬號統一記錄起來,可以解決賬號登 ...
  • 最近有個小項目需要安裝10台顯卡為Quadro K620的機子,期間查看了許多教程都不太完整,所以整理了一下,把自己成功的經驗分享給大家,給自己寫博客開個小頭,有問題可以留言。 系統版本:CentOS7 CUDA版本:CUDA-9.1 安裝方式:離線U盤拷貝,控制台界面,cuda.run包安裝(不需 ...
  • 1.chgrp——改變所屬群組 每個檔案都有三個屬性,擁有者、群組、其他人,chgrp就可以更改檔案的群組,如下 上面1.txt和2.txt的群組都是zyj,相當於在zyj群組中的用戶都只能讀取檔案1.txt和2.txt 接下來我們改變檔案的群組為root後就可以修改檔案的內容了,如下 2.chow ...
  • 推輓輸出,可以輸出高電平,連接數字器件: 輸出0時,N-MOS導通,P-MOS高阻,輸出0。 輸出1時,N-MOS高阻,P-MOS高阻,輸出1;(不需要外部上拉電阻) 開漏輸出: 輸出端相當於三極體的集電極,要得到高電平狀態需要上拉電阻才行,適合做電流型驅動; 輸出0時,N-MOS導通,P-MOS不 ...
  • 1.什麼操作出現:當我在項目中添加產品或者修改時,瀏覽器出現HTTP Status 500 Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not e ...
  • #!/usr/bin/expect -f set pwffd [lindex $argv 0] spawn ssh cmesvr2i expect "*password:" send "$pwffd\r" expect "*#" interact ...
  • 二周第三次課(12月20日)2.14 更改文件和目錄許可權chmod 2.15 更改所有者和所屬組chown2.16 umask2.17 隱藏許可權lsattr/chattr 更改文件和目錄許可權:命令:#chmod >> change mode (-R=文件所有者·文件所屬組·其他用戶一起更改) # r ...
  • Linux下一次刪除百萬文件 Linux下一次刪除百萬文件 線上環境遇到的一個問題,文件數量過多,執行rm命令報錯 # rm -f ./* -bash: /bin/rm: Argument list too long # rm -f ./* -bash: /bin/rm: Argument list ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...