1、安裝cluster glue
安裝heartbeat之前需要安裝glue。
yum install autoconf automake libtool glib2-devel libxml2-devel bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel make wget(紅色標記處也需要安裝)
yum install docbook-dtds docbook-style-xsl
groupadd haclient
useradd -g haclient hacluster -s /sbin/nologin
cd /tmp
wget http://hg.linux-ha.org/glue/archive/glue-1.0.9.tar.bz2
tar xjf glue-1.0.9.tar.bz2
cd Reusable-Cluster-Components-glue--glue-1.0.9
./autogen.sh
./configure --prefix=/usr/local/heartbeat LIBS=’/lib/libuuid.so.1‘(64位系統上是LIBS=’/lib64/libuuid.so.1‘)
make && make install
安裝過程中會在INTERNET中校驗一些xml文件,會耗費大量時間,要耐心等待。如果報錯可能是網絡引起,多試幾次就行(yum install docbook-dtds docbook-style-xsl安裝這兩個包之後解決 )。
2、安裝Resource Agents
1、cd /tmp
2、wget --no-check-certificate https://github.com/ClusterLabs/resource-agents/tarball/v3.9.2
3、tar xzf v3.9.2
4、cd ClusterLabs-resource-agents-b735277/
5、./autogen.sh
6、./configure --prefix=/usr/local/heartbeat CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib LIBS=’/lib/libuuid.so.1‘(64位系統上是LIBS=’/lib64/libuuid.so.1‘)
7、ln -s /usr/local/heartbeat/lib/* /lib/ (64位系統是ln -s /usr/local/heartbeat/lib/* /lib64/ 解決libplumb.so.2等包找不到的問題,./configure的時候會產生一些需要的包)
8、 vi /usr/local/heartbeat/include/heartbeat/glue_config.h(找到如下幾個設置項刪除對應的行)
HA_SYSCONFDIR
HA_HBCONF_DIR
9、#
vi /etc/ld.so.conf (輸入如下行)
/usr/local/heartbeat/lib
# ldconfig
10、make && make install
3、安裝Heartbeat
- cd /tmp
- wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/7e3a82377fa8.tar.bz2
- tar xjf 7e3a82377fa8.tar.bz2
- cd Heartbeat-3-0-7e3a82377fa8/
- ./bootstrap
- ./configure --prefix=/usr/local/heartbeat CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib LIBS='/lib/libuuid.so.1'
- vim /usr/local/heartbeat/include/heartbeat/glue_config.h
- 刪除最後一行:#define HA_HBCONF_DIR “/usr/local/heartbeat/etc/ha.d/”(解決glue_config.h:99:1: error: "HA_HBCONF_DIR" redefined錯誤)
- make && make install
可能出現 cc1: warnings being treated as errorshbaping.c: In function 'hbaping_read':hbaping.c:326: warning: pointer targetsin passing argument 2 of 'msg2...
解決方法:
cd lib/plugins/HBcomm/
mv hbaping.loT hbaping.lo
cd -
make
make install
- cp doc/ha.cf /usr/local/heartbeat/etc/ha.d/
- cp doc/haresources /usr/local/heartbeat/etc/ha.d/
- cp doc/authkeys /usr/local/heartbeat/etc/ha.d/
- cp heartbeat/init.d/heartbeat /etc/rc.d/init.d/
- chkconfig --add heartbeat
- chkconfig heartbeat on
- chmod 600 /usr/local/heartbeat/etc/ha.d/authkeys
- sed -i 's#/usr/lib/ocf#/usr/local/heartbeat/usr/lib/ocf#g' /usr/local/heartbeat/etc/ha.d/shellfuncs
- sed -i 's#/usr/lib/ocf#/usr/local/heartbeat/usr/lib/ocf#g' /usr/local/heartbeat/usr/lib/ocf/lib//heartbeat/ocf-shellfuncs
- sed -i 's#/usr/lib/ocf#/usr/local/heartbeat/usr/lib/ocf#g' /usr/local/heartbeat/etc/ha.d/resource.d//hto-mapfuncs
(上面17、18、19三條是用新的路徑替換默認路徑,將/usr/lib/ocf替換爲/usr/local/heartbeat/usr/lib/ocf)