haproxy+keepalived部署
Posted sailq21
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了haproxy+keepalived部署相关的知识,希望对你有一定的参考价值。
VIP1:10.90.11.196
VIP2:10.90.11.195
DIP1:10.90.11.96
DIP2:10.90.11.95
keepalived部署
Director1、Director2:
yum install keepalived -y
vim /etc/keepalived/keepalived.conf
10.90.11.96
|
10.90.11.95
|
---|---|
global_defs {
vrrp_instance VI_2 { |
global_defs {
virtual_ipaddress { vrrp_instance VI_2 { |
启动keepalived
/etc/init.d/keepalived start
部署haproxy
director1、director2:
安装haproxy:
wget http://pkgs.fedoraproject.org/repo/pkgs/haproxy/haproxy-1.6.9.tar.gz/c52eee40eb66f290d6f089c339b9d2b3/haproxy-1.6.9.tar.gz
tar zxf haproxy-1.6.9.tar.gz -C /usr/local/
cd /usr/local/haproxy-1.6.9
make TARGET=linux2628 ARCH=x86_64 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy
修改配置文件:
vim /usr/local/haproxy/haproxy.cfg
global listen tcptest |
---|
启动
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
重启
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg -st `cat /usr/local/haproxy/haproxy.pid`
停止
killall haproxy
将haproxy加入到系统服务中。脚本内容如下
vim /etc/init.d/haproxy
脚本内容如下:
|
---|
#! /bin/sh #PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/haproxy/sbin # Gracefully exit if the package has been removed. start() stop() restart() case "$1" in exit 0 |
以上是关于haproxy+keepalived部署的主要内容,如果未能解决你的问题,请参考以下文章