HA高可用方案之heartbeat v1的安裝配置

配置前提:

  1.時間必須同步,建議使用ntp協議

  2.節點之間必須要通過主機名互相通信;通信中使用的名字必須與其節點上"uname -n"命令展示出的名字一致

  3.需要仲裁設備

  4.雙方root用戶能基於ssh密鑰方式進行通信

  5.本地資源必須能夠正常運行,本文將使用httpd作爲案例

           注意:定義爲集羣服務中的任意資源都不能開機自動啓動,因爲他們將由CRM啓動

安裝方法:

[root@nod1 heartbeat1]# yum -y install net-snmp-libs libnet PyXML libltdl   注意配置epel源
[root@nod1 heartbeat1]# rpm -ivh heartbeat-2.1.4-12.el6.i686.rpm heartbeat-stonith-2.1.4-12.el6.i686.rpm heartbeat-pils-2.1.4-12.el6.i686.rpm  
Preparing...                ########################################### [100%]
   1:heartbeat-pils         ########################################### [ 33%]
   2:heartbeat-stonith      ########################################### [ 67%]
   3:heartbeat              ########################################### [100%]

同步時間:


crontab */3 * * * * /usr/sbin/ntpdate 172.16.0.1 &> /dev/null

節點1:建立加密關聯

ssh-keygen -P ''ssh-copey-id -i .ssh/id_rsa.pub root@node2
[root@nod1 ~]# ssh nod2 'date';date   保持兩個節點時間同步Mon Oct  5 17:38:47 HKT 2015Mon Oct  5 17:38:47 HKT 2015
[root@nod1 ~]# scp /etc/hosts nod2:/etc/hosts    兩個節點的hosts文件保持一致hosts                                                 100%  228     0.2KB/s   00:00
[root@nod2 ~]# ssh-keygen -t rsa -P ''       確保nod2加密連接到nod1
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
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:
b0:bc:2e:44:88:6e:7b:a7:d0:63:f6:9f:4f:f8:4d:55 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
| . .  .        E |
|. . .. o      .  |
|.  .  o S    .   |
| o. .  ..   .    |
|...*  .. . .     |
| .+.+o  + o      |
|  ..oooo.o .     |
+-----------------+[root@nod2 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@nod1The authenticity of host 'nod1 (192.168.1.10)' can't be established.RSA key fingerprint is 41:26:a8:88:6a:93:f6:56:aa:87:6b:d7:62:46:83:0d.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'nod1,192.168.1.10' (RSA) to the list of known hosts.root@nod1's password: Now try logging into the machine, with "ssh 'root@nod1'", and check in:   .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. [root@nod2 ~]# ssh nod1 'date';dateMon Oct  5 17:45:26 HKT 2015Mon Oct  5 17:45:26 HKT 2015

配置文件設置;

cd /usr/share/doc/heartbeat-2.1.4cp -p authkeys haresources ha.cf /etc/ha.d   #將備用的配置文件拷貝到配置目錄中   ha.cf:heartbeat的主配置文件,authkeys:集羣信息加密算法及密鑰,haresources:heartbeat v1的CRM配置接口cd /etc/ha.d/chmod 600 authkeys   修改權限400或600

修改ha.cf配置:           

vim ha.cflogfile /var/log/ha-log#logfacility    local0mcast eth0 228.203.101.1 694 1 0  採用多播地址,本地組播地址:239.0.0.0-239.255.255.255,僅在特定的本地範圍內有效 node nod1.mageedu.comnode nod2.mageedu.com   加入高可用集羣的計算機ping  192.168.1.1  仲裁設備,判斷計算機是否可用的標準compression bz2  選擇壓縮
  vim authkeys    auth 1   1 sha1  343434349   設置加密,可以使用openssl rand -hex 6生成加密密碼

 

  vim haresouces:  nod1.mageedu.com 192.168.1.15/24/eth0/192.168.1.255 httpd    Haresources文件用於指定雙機系統的主節點、集羣IP、子網掩碼、廣播地址以及啓動的服務等集羣資源s
scp -p authkeys haresouces ha.cf node2:/etc/ha.d/  確保主機2 配置,文件屬性相同-p
service heartbeart start; ssh node2 'service heartbeat start'啓動服務,訪問外網地址能正常訪問

wKiom1YSfV_xB3jNAACuG_nWLdE732.jpg

      

tail /var/log/ha-log 查看日誌
  cd /usr/lib64/heartbeat/    ./hb_standby 不作爲主    ./hb_takeover 作爲主 資源轉化用


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