centos6.4安裝heartbeat3.0版本安裝---超詳細


#此文檔其實可以當成腳本,只要把軟件下載到相應的目錄即可 在這裏軟件是放在/soft
#此實驗軟件下載地址:http://pan.baidu.com/share/link?shareid=600042051&uk=823269712
#環境說明:
#系統: Centos6.4 系統採用基本安裝
node1(主服務器):eth0:192.168.1.6(node1)eth1:10.0.9.103(priv1)
node2(從服務器):eth0:192.168.1.8(node2)eth1:10.0.9.121(priv2)
VIP地址:192.168.1.100
#新建用戶
groupadd haclient
useradd -g haclient hacluster
#定義變量
cat << EOF >> /root/.bash_profile
export PREFIX=/usr/local/ha
export LCRSODIR=$PREFIX/libexec/lcrso
export CLUSTER_USER=hacluster
export CLUSTER_GROUP=haclient
export CFLAGS="$CFLAGS -I$PREFIX/include -L$PREFIX/lib"
getent group ${CLUSTER_GROUP} >/dev/null || groupadd -r ${CLUSTER_GROUP}
getent passwd ${CLUSTER_USER} >/dev/null || useradd -r -g ${CLUSTER_GROUP} -d /var/lib/heartbeat/cores/hacluster -s /sbin/nologin -c "cluster user" ${CLUSTER_USER}
EOF
#安裝前,yum安裝缺的包
yum install -y glib2-devel bzip2-devel libxml2 libxml2-devel libtool-ltdl-devel buuid-devel automake autoconf docbook-style-xsl libxslt-devel gettext libaio-devel resource-agents
#安裝各個模塊軟件包
#安裝Cluster Glue
#這個放軟件的目錄 /soft
cd /soft
tar zxf Reusable-Cluster-Components-glue--02bdcf58f9a0.tar.gz
cd Reusable-Cluster-Components-glue--02bdcf58f9a0
./autogen.sh
./configure --prefix=$PREFIX --with-daemon-user=${CLUSTER_USER} --with-daemon-group=${CLUSTER_GROUP} --enable-fatal-warnings=no LIBS=/lib/libuuid.so.1
#注意:如果你是64位系統將LIBS=/lib64/libuuid.so.1 強烈建議安裝下面3個軟件業要指定一下,不然也會報錯
make && make install
#安裝Resource Agents
cd /soft
tar zxf resource-agents-3.9.5.tar.gz
cd resource-agents-3.9.5
./autogen.sh
./configure --prefix=$PREFIX --enable-fatal-warnings=no LIBS=/lib/libuuid.so.1
make && make install
#安裝heartbeat
cd /soft
tar zxf Heartbeat-3-0-545554f6fc0a.tar.gz
cd Heartbeat-3-0-545554f6fc0a
./bootstrap
./configure --prefix=$PREFIX --enable-fatal-warnings=no
make && make install
#安裝pacemaker
cd /soft
tar jxf Pacemaker-1-0-c3869c00c759.tar.bz2
cd Pacemaker-1-0-c3869c00c759
./autogen.sh
./configure --prefix=$PREFIX --with-lcrso-dir=$LCRSODIR --enable-fatal-warnings=no LIBS=/lib/libuuid.so.1
make && make install



#############################報錯信息###########################
You must have autoconf installed to compile the cluster-glue package.
Download the appropriate package for your system,
or get the source tarball at: ftp://ftp.gnu.org/pub/gnu/autoconf/
解決方法:
 yum install automake
Download the appropriate package for your system,
or get the source tarball at: ftp://ftp.gnu.org/pub/gnu/automake/
解決方法:
yum install autoconf
You must have libtool installed to compile the cluster-glue package.
Download the appropriate package for your system,
or get the source tarball at: ftp://ftp.gnu.org/pub/gnu/libtool/
解決方法:
yum install  libtool
./configure時出現configure: error: BZ2 libraries not found
解決辦法:yum -y install bzip2-devel glib2-devel
make的時候
安裝Reusable-Cluster-Components-glue--glue-1.0.9
 ./.libs/libplumb.so: undefined reference to `uuid_parse’
 ./.libs/libplumb.so: undefined reference to `uuid_generate’
 ./.libs/libplumb.so: undefined reference to `uuid_copy’
 ./.libs/libplumb.so: undefined reference to `uuid_is_null’
 ./.libs/libplumb.so: undefined reference to `uuid_unparse’
 ./.libs/libplumb.so: undefined reference to `uuid_clear’
 ./.libs/libplumb.so: undefined reference to `uuid_compare’
 collect2: ld returned 1 exit status
 gmake[2]: *** [ipctest] Error 1
 gmake[2]: Leaving directory `/root/Reusable-Cluster-Components-glue-1.0.6/lib/clplumbing’
 gmake[1]: *** [all-recursive] Error 1
 gmake[1]: Leaving directory `/root/Reusable-Cluster-Components-glue-1.0.6/lib’
 make: *** [all-recursive] Error 1
 解決辦法:
 ./configure --prefix=$PREFIX --with-daemon-user=${CLUSTER_USER} --with-daemon-group=${CLUSTER_GROUP} --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
 各位在./configure的時候指定一下LIBS,如果是32位系統的話改成LIBS='/lib/libuuid.so.1'。下面ClusterLabs-resource Heartbeat在./configure的時候都指定一下,要不然繼續報錯。
解決辦法:yum install e2fsprogs-devel libuuid-devel
make的時候報錯
/usr/bin/xsltproc \
--xinclude \
http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl hb_report.xml
error : Operation in progress
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
cannot parse http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
gmake[2]: *** [hb_report.8] Error 4
gmake[2]: Leaving directory `/heartbeat/Reusable-Cluster-Components-glue--5e06b2ddd24b/doc'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/heartbeat/Reusable-Cluster-Components-glue--5e06b2ddd24b/doc'
make: *** [all-recursive] Error 1
解決方法:
yum -y install docbook-style-xsl
查看日誌發現錯誤
grep -i error /var/log/ha-log
Sep 14 19:33:38 node1 pengine: [29617]: ERROR: unpack_resources: Resource start-up disabled since no STONITH resources have been defined
Sep 14 19:33:38 node1 pengine: [29617]: ERROR: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option
Sep 14 19:33:38 node1 pengine: [29617]: ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity
Sep 14 19:33:45 node1 pengine: [29617]: info: process_pe_message: Configuration ERRORs found during PE processing. Please run "crm_verify -L" to identify issues.
解決方法:STONITH默認是開啓的,而我們做實驗的時候是沒有這個設備,所以要關閉它
STONTIH設備詳解請參考:http://czmmiao.iteye.com/blog/1174667
關閉方法是:
[root@localhost ~]# /usr/local/ha/sbin/crm
abort: couldn't find crm libraries in [/usr/local/ha/sbin /usr/lib/python26.zip /usr/lib/python2.6 /usr/lib/python2.6/plat-linux2 /usr/lib/python2.6/lib-tk /usr/lib/python2.6/lib-old /usr/lib/python2.6/lib-dynload /usr/lib/python2.6/site-packages /usr/lib/python2.6/site-packages/gtk-2.0 /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info]
(check your install and PYTHONPATH)
解決方法:
vim .bash_profile
然後添加以下內容
export PYTHONHONME=/usr/local/ha
export PYTHONPATH=$PYTHONHOME:/usr/local/ha/lib/python2.6/site-packages
export PATH=$PATH:/usr/local/ha/sbin
最後執行 source .bash_profile


[root@node1 ~]# vim /etc/hosts  添加以下內容
192.168.1.6       node1
192.168.1.8       node2
10.0.9.103        priv1
10.0.9.121        priv2
拷貝配置文件
[root@node1 ~]# cp /usr/local/ha/share/doc/heartbeat/ha.cf  /usr/local/ha/etc/ha.d/
[root@node1 ~]# cp /usr/local/ha/share/doc/heartbeat/haresources  /usr/local/ha/etc/ha.d
[root@node1 ~]# cp /usr/local/ha/share/doc/heartbeat/authkeys  /usr/local/ha/etc/ha.d/
ha.cf配置文件部分參數詳解:
logfile /var/log/ha-log 
#指名heartbaet的日誌存放位置
keepalive 2 
#指定心跳使用間隔時間爲2秒(即每兩秒鐘在eth1上發送一次廣播)
deadtime 30
#指定備用節點在30秒內沒有收到主節點的心跳信號後,則立即接管主節點的服務資源
warntime 10
#指定心跳延遲的時間爲十秒。當10秒鐘內備份節點不能接收到主節點的心跳信號時,就會往日誌中寫入一個警告日誌,但此時不會切換服務
initdead 120
#在某些系統上,系統啓動或重啓之後需要經過一段時間網絡才能正常工作,該選項用於解決這種情況產生的時間間隔。取值至少爲deadtime的兩倍。
   
udpport 694
#設置廣播通信使用的端口,694爲默認使用的端口號。
baud    19200
#設置串行通信的波特率
      
bcast   eth0        # Linux  指明心跳使用以太網廣播方式,並且是在eth0接口上進行廣播。
#mcast eth0 225.0.0.1 694 1 0
#採用網卡eth0的Udp多播來組織心跳,一般在備用節點不止一臺時使用。Bcast、ucast和mcast分別代表廣播、單播和多播,是組織心跳的三種方式,任選其一即可。
#ucast eth0 192.168.1.2
#採用網卡eth0的udp單播來組織心跳,後面跟的IP地址應爲雙機對方的IP地址
auto_failback on
#用來定義當主節點恢復後,是否將服務自動切回,heartbeat的兩臺主機分別爲主節點和備份節點。主節點在正常情況下佔用資源並運行所有的服務,遇到故障時把資源交給備份節點並由備份節點運行服務。在該選項設爲on的情況下,一旦主節點恢復運行,則自動獲取資源並取代備份節點,如果該選項設置爲off,那麼當主節點恢復後,將變爲備份節點,而原來的備份節點成爲主節點
#stonith baytech /etc/ha.d/conf/stonith.baytech
# stonith的主要作用是使出現問題的節點從集羣環境中脫離,進而釋放集羣資源,避免兩個節點爭用一個資源的情形發生。保證共享數據的安全性和完整性。
#watchdog /dev/watchdog
#該選項是可選配置,是通過Heartbeat來監控系統的運行狀態。使用該特性,需要在內核中載入"softdog"內核模塊,用來生成實際的設備文件,如果系統中沒有這個內核模塊,就需要指定此模塊,重新編譯內核。編譯完成輸入"insmod softdog"加載該模塊。然後輸入"grep misc /proc/devices"(應爲10),輸入"cat /proc/misc |grep watchdog"(應爲130)。最後,生成設備文件:"mknod /dev/watchdog c 10 130" 。即可使用此功能
node node1  #主節點主機名,可以通過命令“uanme –n”查看。
node node2  #備用節點主機名
ping 192.168.12.237
#選擇ping的節點,ping 節點選擇的越好,HA集羣就越強壯,可以選擇固定的路由器作爲ping節點,但是最好不要選擇集羣中的成員作爲ping節點,ping節點僅僅用來測試網絡連接
ping_group group1 192.168.12.120 192.168.12.237
#類似於ping  ping一組ip地址
apiauth pingd  gid=haclient uid=hacluster
respawn hacluster /usr/local/ha/lib/heartbeat/pingd -m 100 -d 5s
#該選項是可選配置,列出與heartbeat一起啓動和關閉的進程,該進程一般是和heartbeat集成的插件,這些進程遇到故障可以自動重新啓動。最常用的進程是pingd,此進程用於檢測和監控網卡狀態,需要配合ping語句指定的ping node來檢測網絡的連通性。其中hacluster表示啓動pingd進程的身份。
#下面的配置是關鍵,也就是激活crm管理,開始使用v2 style格式
crm respawn
#注意,還可以使用crm yes的寫法,但這樣寫的話,如果後面的cib.xml配置有問題
#會導致heartbeat直接重啓該服務器,所以,測試時建議使用respawn的寫法
#下面是對傳輸的數據進行壓縮,是可選項
compression     bz2
compression_threshold 2
注意,v2 style不支持ipfail功能,須使用pingd代替
資源文件(/etc/ha.d/haresources)
node1   IPaddr::192.168.1.100/24/eth0   httpd
認證文件(/etc/ha.d/authkeys)
auth 1
1 crc








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