Linux学习-HA之heartbeatv3安装

注:高可用集群节点之间是靠节点名称(名称需要解析为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

配置heartbeat

#-----------node1上面修改相应的配置--------------
#将authkeys,ha.cf,haresources三个配置文件拷贝至/usr/local/heartbeat/etc/ha.d/
[root@node1 ~]# cp /usr/local/heartbeat/share/doc/heartbeat/authkeys ha.cf haresources /usr/local/heartbeat/etc/ha.d/
#authkeys配置文件内容如下---/usr/local/heartbeat/etc/ha.d/authkeys
#使用第1种认证方式
auth 1
#md5加密,最后面为盐值
1 md5 ae4ef4cd8ed
#ha.cf配置文件去除注释后内容如下---/usr/local/heartbeat/etc/ha.d/ha.cf
[root@node1 ~]# grep -v '^#' /usr/local/heartbeat/etc/ha.d/ha.cf
#调试日志
debugfile /var/log/ha-debug
#heartbeat日志
logfile	/var/log/heartbeat-log
#heartbeat之间的时间间隔为2秒
keepalive 2
#10秒连接不上宣布节点死亡
deadtime 10
#通过ens33网卡对192.168.0.110单播
ucast ens33 192.168.0.110
#一旦主节点重新恢复联机,将从从节点取回所有资源。
auto_failback on
#-----集群节点的名称---
node    node1.tye.com
node    node2.tye.com
#-----集群节点的名称---
#ping网关判断当前节点是否存活
ping 192.168.0.1
#haresources配置文件---/usr/local/heartbeat/etc/ha.d/haresources
[root@node1 ~]# grep -v '^#' /usr/local/heartbeat/etc/ha.d/haresources
#主机名---资源名称(位于/usr/local/heartbeat/etc/ha.d/resource.d目录)---虚拟IP/子网掩码(VIP)---启动的服务(位于/usr/local/heartbeat/etc/ha.d/resource.d或/etc/rc.d/init.d目录)
node1.tye.com  IPaddr::192.168.0.120/24/ens33 httpd
#--------------node2配置参考node1的配置,将node1修改为node2,修改ha.cf中ucast ens33 192.168.0.109
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值