只想知道 发表于 2015-1-14 20:25:07

来一发CentOS5.5下HAProxy+Keepalived高可用负载平衡设置

如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!1、体系情况:
体系版本:CentOS5.5x86_64
master_ip:172.20.27.40
backup_ip:172.20.27.50
vip:172.20.27.200
web_1:172.20.27.90
web_2:172.20.27.100
2、haproxy装置:
1.起首172.20.27.40装置上装置:
1.1装置
tarzxvfhaproxy-1.3.20.tar.gz
cdhaproxy-1.3.20
makeTARGET=linux26PREFIX=/usr/local/haproxy
makeinstallPREFIX=/usr/local/haproxy
1.2.设置
cd/usr/local/haproxy
mkdiretc
cdetc
vihaproxy.cfg


global
log127.0.0.1local0
maxconn65535
chroot/usr/local/haproxy
uid99
gid99
daemon
nbproc12
pidfile/usr/local/haproxy/haproxy.pid
defaults
log127.0.0.1local3
modehttp
optionhttplog
optionhttpclose
optiondontlognull
optionforwardfor
optionredispatch
retries2
maxconn65535
balancesource
statsuri/web-status
statsauthadmin:admin@admin
statsrefresh60s
contimeout5000
clitimeout50000
srvtimeout50000
listen172.20.27.200
bind*:80
modehttp
optionhttplog
logglobal
optionhttpchkHEAD/t.htmHTTP/1.0
serverweb1172.20.27.90:80weight5checkinter2000rise2fall3
serverweb2172.20.27.100:80weight5checkinter2000rise2fall3
然后启动haproxy,以下实行启动下令:
/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/etc/haproxy.cfg
2.起首172.20.27.50装置上装置:
2.1.装置
tarzxvfhaproxy-1.3.20.tar.gz
cdhaproxy-1.3.20
makeTARGET=linux26PREFIX=/usr/local/haproxy
makeinstallPREFIX=/usr/local/haproxy
2.2.设置
cd/usr/local/haproxy
mkdiretc
cdetc
vihaproxy.cfg


global
log127.0.0.1local0
maxconn65535
chroot/usr/local/haproxy
uid99
gid99
daemon
nbproc12
pidfile/usr/local/haproxy/haproxy.pid
defaults
log127.0.0.1local3
modehttp
optionhttplog
optionhttpclose
optiondontlognull
optionforwardfor
optionredispatch
retries2
maxconn65535
balancesource
statsuri/web-status
statsauthadmin:admin@admin
statsrefresh60s
contimeout5000
clitimeout50000
srvtimeout50000
listen172.20.27.200
bind*:80
modehttp
optionhttplog
logglobal
optionhttpchkHEAD/t.htmHTTP/1.0
serverweb1172.20.27.90:80weight5checkinter2000rise2fall3
serverweb2172.20.27.100:80weight5checkinter2000rise2fall3
然后启动haproxy,以下实行启动下令:
/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/etc/haproxy.cfg
3、keepalived装置:
1.起首172.20.27.40装置上装置:
1.1装置
tarzxvfkeepalived-1.1.17.tar.gz
cdkeepalived-1.1.17
./configure
make
makeinstall
cp/usr/local/etc/rc.d/init.d/keepalived/etc/rc.d/init.d
cp/usr/local/etc/sysconfig/keepalived/etc/sysconfig
mkdir/etc/keepalived
cp/usr/local/sbin/keepalived/usr/sbin/
cd/etc/keepalived
1.2.设置
vikeepalived.conf
!ConfigurationFileforkeepalived
global_defs{
notification_email{
331095659@qq.com
}
notification_email_from331095659@qq.com
smtp_server127.0.0.1
smtp_connect_timeout30
router_idLVS_DEVEL
}
vrrp_scriptchk_haproxy{
script"/usr/local/haproxy/shell/check_haproxy.sh"
interval2
weight2
}
#VIP1
vrrp_instanceVI_1{
stateBACKUP
inte***ceeth0
lvs_sync_daemon_intefaceeth0
virtual_router_id151
priority100
advert_int5
nopreempt
authentication{
auth_typePASS
auth_pass2222
}
virtual_ipaddress{
172.20.27.200
}
track_script{
chk_haproxy
}
}
mkdir-p/usr/local/haproxy/shell
cd/usr/local/haproxy/shell
#创建监控haproxy剧本
vicheck_haproxy.sh
#!/bin/bash
#autocheckhaproxprocess
#2014-6-30
killall-0haproxy
if[[$?-ne0]];then
/etc/init.d/keepalivedstop
fi
chmodu+xcheck_haproxy.sh
servicekeepalivedrestart
2.起首172.20.27.50装置上装置:
2.1装置
tarzxvfkeepalived-1.1.17.tar.gz
cdkeepalived-1.1.17
./configure
make
makeinstall
cp/usr/local/etc/rc.d/init.d/keepalived/etc/rc.d/init.d
cp/usr/local/etc/sysconfig/keepalived/etc/sysconfig
mkdir/etc/keepalived
cp/usr/local/sbin/keepalived/usr/sbin/
cd/etc/keepalived
2.2设置
vikeepalived.conf
!ConfigurationFileforkeepalived
global_defs{
notification_email{
331095659@qq.com
}
notification_email_from331095659@qq.com
smtp_server127.0.0.1
smtp_connect_timeout30
router_idLVS_DEVEL
}
vrrp_scriptchk_haproxy{
script"/usr/local/haproxy/shell/check_haproxy.sh"
interval2
weight2
}
#VIP1
vrrp_instanceVI_1{
stateBACKUP
inte***ceeth0
lvs_sync_daemon_intefaceeth0
virtual_router_id151
priority90
advert_int5
nopreempt
authentication{
auth_typePASS
auth_pass2222
}
virtual_ipaddress{
172.20.27.200
}
track_script{
chk_haproxy
}

飘飘悠悠 发表于 2015-1-16 17:51:26

来一发CentOS5.5下HAProxy+Keepalived高可用负载平衡设置

写学习日记,这是学习历程的见证,同时我坚持认为是增强学习信念的法宝。

简单生活 发表于 2015-1-23 05:34:23

硬盘安装及光盘安装,清楚了解安装Linux应注意的有关问题,如安装Linux应在最后一个分区内,至少分二个分区。

若相依 发表于 2015-1-31 16:25:29

一定要学好命令,shell是命令语言,命令解释程序及程序设计语言的统称,shell也负责用户和操作系统之间的沟通。

柔情似水 发表于 2015-2-6 22:54:39

选择交流平台,如QQ群,网站论坛等。

爱飞 发表于 2015-2-19 07:11:41

选择一些适于初学者的Linux社区。

乐观 发表于 2015-3-6 14:25:11

我感觉linux的学习,学习编程~!~!就去学习C语言编程!!

蒙在股里 发表于 2015-3-13 03:53:51

一定要学好命令,shell是命令语言,命令解释程序及程序设计语言的统称,shell也负责用户和操作系统之间的沟通。

第二个灵魂 发表于 2015-3-20 12:23:55

为什么要学Linux呢?每个人都有不同的看法,下面我说说自己的感想吧。?
页: [1]
查看完整版本: 来一发CentOS5.5下HAProxy+Keepalived高可用负载平衡设置