环境配置
echo /opt/servers/lib > /etc/ld.so.conf.d/servers.conf
编译环境
CentOS 6.2 x86_64 Linux 2.6.32-220.el6.x86_64
编译环境要求
- wget
- mercurial
- gcc
- autoconf
- automake
- make
- libtool
- pkgconfig
- glib2-devel
- libxml2 libxml2-devel
- bzip2-devel
- libtool-ltdl-devel
- libuuid-devel
- libxslt-devel
编译glue
./autogen.sh ./configure --prefix=/opt/servers make make install
./configure 的输出
cluster-glue configuration: Version = 1.0.9 (Build: 0a08a469fdc8a0db1875369497bc83c0523ceb21) Features = Prefix = /opt/servers Executables = /opt/servers/sbin Man pages = /opt/servers/share/man Libraries = /opt/servers/lib Header files = /opt/servers/include Arch-independent files = /opt/servers/share Documentation = /opt/servers/share/doc/cluster-glue State information = /opt/servers/var System configuration = /opt/servers/etc Use system LTDL = yes HA group name = haclient HA user name = hacluster CFLAGS = -g -O2 -ggdb3 -O0 -fgnu89-inline -fstack-protector-all -Wall -Waggregate-return -Wbad-function-cast -Wcast-qual -Wcast-align -Wdeclaration-after-statement -Wendif-labels -Wfloat-equal -Wformat=2 -Wformat-security -Wformat-nonliteral -Winline -Wmissing-prototypes -Wmissing-declarations -Wmissing-format-attribute -Wnested-externs -Wno-long-long -Wno-strict-aliasing -Wpointer-arith -Wstrict-prototypes -Wwrite-strings -ansi -D_GNU_SOURCE -DANSI_ONLY -Werror Libraries = -lbz2 -lxml2 -lc -luuid -lrt -ldl -lglib-2.0 -lltdl Stack Libraries =
注意 Use system LTDL, 在未安装lib tool-ltdl-devel之前该项会显示为no,且编译会报错
Making all in libltdl gmake[1]: Entering directory `/root/build/Reusable-Cluster-Components-glue--glue-1.0.9/libltdl' gmake[1]: *** 没有规则可以创建目标“all”。 停止。 gmake[1]: Leaving directory `/root/build/Reusable-Cluster-Components-glue--glue-1.0.9/libltdl' make: *** [all-recursive] 错误 1
另外一个可能遇到的错误是关于uuid的,简单的yum install libuuid-devel可以解决,在解决这个问题的时候我google了一下,如果不行可能还会需要在configure的时候带上参数 LIBS=’/lib/libuuid.so.1′(注意,如果是64位则是/lib64/….)。
./.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] 错误 1 gmake[2]: Leaving directory `/root/build/Reusable-Cluster-Components-glue--glue-1.0.9/lib/clplumbing' gmake[1]: *** [all-recursive] 错误 1 gmake[1]: Leaving directory `/root/build/Reusable-Cluster-Components-glue--glue-1.0.9/lib' make: *** [all-recursive] 错误 1
编译Heartbeat 3
./bootstrap LIBS="/lib64/libuuid.so.1" CFLAGS="-I/opt/servers/include -L/opt/servers/lib" ./configure --prefix=/opt/servers make make install
因为我们的安装路径非标准路径,所以这里要指定一下CFLAGS 的include path,否则configure会因找不到glue_config.h而报错
checking for heartbeat/glue_config.h... no configure: error: in `/root/build/Heartbeat-3-0-7e3a82377fa8': configure: error: Core development headers were not found See `config.log' for more details.
虽然已经在ldconfig 里加上了/opt/servers/lib 但是如果不在CFLAGS里指定 lib path 还是会导致 ld 找不到 -lplumb (/opt/servers/lib/libplumb.so)。
另外如果没有安装libxslt-devel在make的时候还会导致 “gmake[1]: –xinclude: Command not found”。
./configure 输出
heartbeat configuration: Version = "3.0.5" Executables = "/opt/servers/sbin" Man pages = "/opt/servers/share/man" Libraries = "/opt/servers/lib64" Header files = "/opt/servers/include" Arch-independent files = "/opt/servers/share" Documentation files = "/opt/servers/share/doc/heartbeat" State information = "/opt/servers/var" System configuration = "/opt/servers/etc" Init (rc) scripts = "/etc/init.d" Init (rc) defaults = "/etc/sysconfig" Use system LTDL = "yes" HA group name = "haclient" HA group id = "65" HA user name = "hacluster" HA user user id = "17" Build dopd plugin = "yes" Enable times kludge = "yes" CC_WARNINGS = " -Wall -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wcast-qual -Wcast-align -Wbad-function-cast -Winline -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -Werror " Mangled CFLAGS = "-I/opt/servers/include -L/opt/servers/lib -I/opt/servers/include/heartbeat -Wall -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wcast-qual -Wcast-align -Wbad-function-cast -Winline -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -Werror -ggdb3 -funsigned-char" Libraries = "-lbz2 -lz -lc -luuid -lrt -ldl /lib64/libuuid.so.1 -lltdl" RPATH enabled = "" Distro-style RPMs = "no" Note: If you use the 'make install' method for installation you also need to adjust '/etc/passwd' and '/etc/group' manually.
到这里 cluster-glue 和 heartbeat 都编译完成了。
然后老大说要用rpm装。。。我了个去。。。
然后centos 6.2的源里 cluster-glue、resource-agents、pacemaker 都有,就是没有heartbeat。 幸好heartbeat的source里提供了.spec 可以用rpmbuild来生成rpm包。
下面继续 heartbeat.rpm 的 build过程
首先把下载下来的heartbeat源码包解压一份,然后再把源码包(.tar.gz)复制到 /root/rpmbuild/SOURCES/heartbeat.tar.bz2
tar -jxf Heartbeat-3.0.5.tar.bz2 cp Heartbeat-3.0.5.tar.bz2 /root/rpmbuild/SOURCES/heartbeat.tar.bz2 cd Heartbeat-XXXXXX # 解决依赖 yum install ncurses-devel openssl-devel gettext bison flex mailx cluster-glue-libs-devel docbook-dtds docbook-style-xsl # 开始生成。 (-bb 只编译二进制rpm包 -bs 只编译源码rpm包 -ba 同时编译二进制和源码rpm包) rpmbuild -ba heartbeat-Fedora.spec
最后生成文件
Wrote: /root/rpmbuild/SRPMS/heartbeat-3.0.5-1.el6.src.rpm Wrote: /root/rpmbuild/RPMS/x86_64/heartbeat-3.0.5-1.el6.x86_64.rpm Wrote: /root/rpmbuild/RPMS/x86_64/heartbeat-libs-3.0.5-1.el6.x86_64.rpm Wrote: /root/rpmbuild/RPMS/x86_64/heartbeat-devel-3.0.5-1.el6.x86_64.rpm
