Loading
0

Linux 之HA集群配置

HA(高可用 High avaiilable)集群
Web1 提供服务,如果1主宕机了,2备就可以马上启用,这样有用户这端没有任何影响。
在架构的时候要配置一条心跳线来传递信息。流动IP 也是就是VIP,是主从对外共同的IP。

[root@LNMP ~]# iptables -F
[root@LNMP ~]# getenforce
Disabled
[root@LNMP ~]# vim /etc/hosts #在主上编译上
10.72.4.21 LNMP
10.72.4.14 OBird
[root@OBird ~]# vim /etc/hosts #复制到从上
10.72.4.21 LNMP
10.72.4.14 OBird
#
[root@LNMP ~]# wget  www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
#下载epel
[root@LNMP ~]# rpm -ivh epel-release-6-8_64.noarch.rpm  #安装(主从都安装)
[root@LNMP ~]# yum list |grep heartbeat
heartbeat.x86_64                            3.0.4-2.el6                  epel
heartbeat-devel.i686                        3.0.4-2.el6                  epel
heartbeat-devel.x86_64                      3.0.4-2.el6                  epel
heartbeat-libs.i686                         3.0.4-2.el6                  epel
heartbeat-libs.x86_64                       3.0.4-2.el6                  epel
主从各自安装 heaerbeat & libnet
[root@LNMP ~]# yum install -y heartbeat
[root@LNMP ~]# yum install libnet
[root@OBird ~]# yun install -y heartbeat
[root@OBird ~]# yum install libnet
[root@LNMP ~]# cd /usr/share/doc/heartbeat-3.0.4/ #进到目录下拷贝样例
[root@LNMP heartbeat-3.0.4]# ls
apphbd.cf  authkeys  AUTHORS  ChangeLog  COPYING  COPYING.LGPL  ha.cf  haresources  README
[root@LNMP heartbeat-3.0.4]# cp authkeys ha.cf haresources /etc/ha.d/
[root@LNMP heartbeat-3.0.4]#

[root@LNMP heartbeat-3.0.4]# cd /etc/ha.d/
[root@LNMP ha.d]# ls
authkeys  ha.cf  harc  haresources  rc.d  README.config  resource.d  shellfuncs
[root@LNMP ha.d]# vim authkeys  #编译验证配置文件
#auth 1  #打开更改为 auth 1
#1 crc
#2 sha1 HI!
#3 md5 Hello! #打开md5验证:3 md5 Hello!
[root@LNMP ha.d]# chmod 600 authkeys #编译目录权限,不然heartbeat 服务不能启动
[root@LNMP ha.d]# cd /etc/sysconfig/network-scripts/ #配置虚拟网卡&IP
[root@LNMP network-scripts]# ls
ifcfg-eth0   ifdown-eth   ifdown-post    ifdown-tunnel  ifup-eth   ifup-plip   ifup-routes    init.ipv6-global
ifcfg-lo     ifdown-ippp  ifdown-ppp     ifup           ifup-ippp  ifup-plusb  ifup-sit       net.hotplug
ifdown       ifdown-ipv6  ifdown-routes  ifup-aliases   ifup-ipv6  ifup-post   ifup-tunnel    network-functions
ifdown-bnep  ifdown-isdn  ifdown-sit     ifup-bnep      ifup-isdn  ifup-ppp    ifup-wireless  network-functions-ipv6
[root@LNMP network-scripts]# cp ifcfg-eth0 ifcfg-eth0\:1 #配置虚拟网卡&IP
[root@LNMP network-scripts]# vim ifcfg-eht0\:1
DEVICE=eth0:1
#HWADDR=00:0C:29:5A:02:3F
TYPE=Ethernet
#UUID=22567e42-4d72-40e9-8ca3-98098c239d9c
ONBOOT=no #开机不不启动,楼主是桥接模式,所以是静态且不启动
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.72.4.110
NETMASK=255.255.254.0
#GATEWAY=10.72.4.1

分页阅读: 1 2 3
【声明】:8090安全小组门户(http://www.8090-sec.com)登载此文出于传递更多信息之目的,并不代表本站赞同其观点和对其真实性负责,仅适于网络安全技术爱好者学习研究使用,学习中请遵循国家相关法律法规。如有问题请联系我们:邮箱hack@ddos.kim,我们会在最短的时间内进行处理。