注:高可用集群节点之间是靠节点名称(名称需要解析为IP)来识别的 heartbeat v2 ha web node1,node2 节点名称:/etc/hosts 节点名称必须与uname -n命令的执行结果一致 SSH互信通信 时间同步
node1:192.168.0.109
node2:192.168.0.110
vip:192.168.0.100
#修改node1节点主机名称
[root@localhost ~]# hostname node1.tye.com
[root@localhost ~]# hostname
node1.tye.com
[root@localhost ~]# vim /etc/host
host.conf hosts hosts.allow hosts.deny
[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=node1.tye.com
#使用代码修改主机名
#!/bin/bash
#
chostname=node2.tye.com
hostfile=/etc/sysconfig/network
#临时修改本机的主机名
/bin/hostname $chostname
sed -i '/HOSTNAME/d' $hostfile
sed -i '$a \HOSTNAME='$chostname $hostfile
配置双机互信
#在node1和node2上分别执行以下程序,最后会提示输入密码后,将生成的公钥拷贝到互信的主机上,生成/root/.ssh/authorized_keys文件
#!/bin/bash
#
keyfile=~/.ssh/id_rsa
publickeyfile=~/.ssh/id_rsa.pub
algorithm=rsa
trustip=192.168.0.110
#生成key
/usr/bin/ssh-keygen -t $algorithm -f $keyfile -P ''
/usr/bin/ssh-copy-id -i $publickeyfile "root@$trustip"
#测试互信
[root@localhost ~]# ssh 192.168.0.110 ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:44:28:94
inet addr:192.168.0.110 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe44:2894/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7657 errors:0 dropped:0 overruns:0 frame:0
TX packets:6766 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:602504 (588.3 KiB) TX bytes:6600790 (6.2 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:336 (336.0 b) TX bytes:336 (336.0 b)
#修改hosts配置
[root@localhost ~]# vim /etc/hosts
192.168.0.109 node1.tye.com node1
192.168.0.110 node2.tye.com node2
[root@localhost ~]# ping node2
PING node2.tye.com (192.168.0.110) 56(84) bytes of data.
64 bytes from node2.tye.com (192.168.0.110): icmp_seq=1 ttl=64 time=0.422 ms
64 bytes from node2.tye.com (192.168.0.110): icmp_seq=2 ttl=64 time=0.285 ms
^C
--- node2.tye.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1885ms
rtt min/avg/max/mdev = 0.285/0.353/0.422/0.071 ms
安装heartbeat3.0.6 到Linux-HA网站上下载
#安装heartbeat报错1
[root@node1 Heartbeat-3-0-958e11be8686]# ./bootstrap
#执行了./bootstrap报以下错误
libtoolize: `COPYING.LIB' not found in `/usr/share/libtool/libltdl'
#解决方法
[root@node1 Heartbeat-3-0-958e11be8686]# yum install -y libtool-ltdl-devel
#安装heartbeat报错2
configure: error: Core development headers were not found
#解决方法
安装Cluster Glue 1.0.12
#安装heartbeat报错3
configure: error: C compiler cannot create executables
#解决方法
#安装Cluster Glue 1.0.12报错1
configure: error: You need glib2-devel installed in order to build cluster-glue
[root@node1 Reusable-Cluster-Components-glue--0a7add1d9996]# yum install -y glib2-devel
#安装Cluster Glue 1.0.12报错2
configure: error: BZ2 Development headers not found
#解决方法
[root@node1 Reusable-Cluster-Components-glue--0a7add1d9996]# yum install -y bzip2-devel
#安装Cluster Glue 1.0.12报错3
make[2]: a2x: Command not found
#解决方法
yum install -y asciidoc
#安装Resource Agents 3.9.6报错1
unable to parse metadata-IPv6addr.xml
解决:xml 没用下载成功,执行make clean ,再重新编译
安装过程
#安装所需要的包
yum install gcc gcc-c++ autoconf automake libtool glib2-devel libxml2-devel bzip2 bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel asciidoc
#1.安装Cluster Glue 1.0.12
[root@node1 filefolder]# tar xf 0a7add1d9996.tar.bz2
[root@node1 filefolder]# ls
0a7add1d9996.tar.bz2 Heartbeat-3-0-958e11be8686
958e11be8686.tar.bz2 Reusable-Cluster-Components-glue--0a7add1d9996
[root@node1 filefolder]# cd Reusable-Cluster-Components-glue--0a7add1d9996/
[root@node1 Reusable-Cluster-Components-glue--0a7add1d9996]# ls
AUTHORS cluster-glue-fedora.spec configure.ac doc include lrm README
autogen.sh cluster-glue-suse.spec COPYING GNUmakefile lib Makefile.am replace
ChangeLog config COPYING.LIB hb_report logd NEWS
[root@node1 Reusable-Cluster-Components-glue--0a7add1d9996]# ./autogen.sh
[root@node1 Reusable-Cluster-Components-glue--0a7add1d9996]# ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
[root@node1 Reusable-Cluster-Components-glue--0a7add1d9996]#make && make install
#2.安装Resource Agents 3.9.6
[root@node1~]# wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz
[root@node1 ~]# tar xf v3.9.6.tar.gz
[root@node1 ~]# cd resource-agents-3.9.6/
[root@node1 resource-agents-3.9.6]# ./autogen.sh
[root@node1 resource-agents-3.9.6]# ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
[root@node1 resource-agents-3.9.6]# make && make install
#3.安装heartbeat3.0.6
[root@node1 Heartbeat-3-0-958e11be8686]# ./bootstrap
[root@node1 Heartbeat-3-0-958e11be8686]#export CFLAGS="$CFLAGS -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib"
[root@node1 Heartbeat-3-0-958e11be8686]#./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
[root@node1 Heartbeat-3-0-958e11be8686]#make && make install
|