在centos中配置高可用性設定組群

來源:互聯網
上載者:User



一、概述:


系統:Centos5.0



叢集軟體:Heartbeat



節點1IP(

):192.168.1.105



節點2IP(

):192.168.1.106



virtual IP:192.168.1.102


  在節點1
上使用
uname -n 
結果必須是
node01
,在節點
2
上同樣使用
uname -n
結果也必須是
node02

IP 192.168.1.102
是一個虛擬
IP
用來供
webserver
使用的。



二、下載安裝軟體包和配置:


1、需要以下軟體包:



heartbeat-2.1.2


heartbeat-2.1.2


heartbeat-stonith-2.1.2


也可以使用yum -y install heartbeat
來進行安裝,附件為所需要的軟體包:



檔案:



heartbeat.rar   大小
: 2627KB 
下載
:  
下載



2、在每個節點上配置
heartbeat
,需要有以下三個檔案
:



authkeys、
ha.cf

haresources
,它們存在於
/etc/ha.d/
目錄裡。



3、建立以上提到的三個檔案:



cp /usr/share/doc/heartbeat-2.1.2/authkeys  /etc/ha.d/


cp /usr/share/doc/heartbeat-2.1.2/ha.cf  /etc/ha.d/


cp /usr/share/doc/heartbeat-2.1.2/haresources  /etc/ha.d/


4、配置:



  4.1、首先編輯
authkeys
檔案
:



   vi /etc/ha.d/authkeys


   添加以下行:在這裡我們使用的是第二種認證方式(shal)



   auth 2


   2 sha1 test-ha


   接著把檔案的許可權改為600




   chmod 600 /etc/ha.d/authkeys


  4.2、編輯
/etc/ha.d/ha.cf
檔案
:



   vi /etc/ha.d/ha.cf加入如下行:



   logfile /var/log/ha-log


   logfacility local0


   keepalive 2


   deadtime 30


   initdead 120


   bcast eth0


   udpport 694


   auto_failback on


   node node01


   node node02


  4.3、編輯
/etc/ha.d/haresources
檔案:



   這個檔案中包含了使那個服務具有高可用性,在這裡我們使用的是httpd;



   vi /etc/ha.d/haresources加入下行:



   node01 172.16.4.82 httpd


  4.4、我們把
node01
上的
/etc/ha.d/
目錄複寫到節點
node02
上的
/etc
目錄裡。



   scp -r /etc/ha.d/  192.168.102.X:/


  4.5、在
httpd.conf
檔案裡我們添加如下行:



   vi /etc/httpd/conf/httpd.conf


   Listen 192.168.1.102:80 


  4.6、把節點
node01
上的
/etc/httpd/conf/httpd.conf
檔案複製到節點
node02
相應的目錄裡:



   scp /etc/httpd/conf/httpd.conf  192.168.102.X:/


  4.7、在兩個節點上分別建立一個
index
檔案來進行測試:



   在node01
上:



   echo "node01 apache test server" > /var/www/html/index.html


   在node02
上:



   echo "node02 apache test server" > /var/www/html/index.html


  4.8、在兩個節點上分別啟動
heartbeat:



    /etc/init.d/heartbeat start


  4.9、在
node01
上,開啟一個瀏覽器:輸入

http://192.168.1.102


   並斷行符號,將會看到


    node01 apache test server


  4.10、停止
node01
上的
heartbeat
進程,然後


瀏覽器裡輸入http://192.168.1.102  
並斷行符號,將會看到
node02 apache test server.



三、補充:


  這裡不需要建立一個虛擬網路介面和配置一個IP

192.168.1.102
)給它,因為
heartbeat
會協助我們來完成的,並啟動
httpd server


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.