公司nginx keepalived tomcat cxf 搭建高可用负载均衡实战系列1- keepalived安装配置
Posted 不甘平凡,叶育生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了公司nginx keepalived tomcat cxf 搭建高可用负载均衡实战系列1- keepalived安装配置相关的知识,希望对你有一定的参考价值。
1,ip说明
vip
|
10.50.13.67
|
server1
|
10.50.13.68
|
server2
|
10.50.13.140
|
2,keepalived安装
keepalived通常与lvs或者nginx结合使用保证集群的高可用,keepalived的master会绑定一个vip用来对外服务并定期向backup发送消息,当backup接收不到消息时则会判定master已经挂掉,backup将升为master并且绑定vip继续对外提供服务,从而保证高可用。下面介绍keepalived的安装
安装依赖 openssl-devel popt-devel
yum install -y gcc openssl-devel popt-devel
下载 /keepalived-1.2.24.tar.gz
wget http://www.keepalived.org/software/keepalived-1.2.24.tar.gz
tar zxvf keepalived-1.2.24.tar.gz
cd keepalived-1.2.24
./configure --prefix=/opt/wacos/aaatool/keepalived
make && make install
设置开机启动
cp /opt/wacos/aaatool/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
cp /opt/wacos/aaatool/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /ut/server/keepalived-1.2.24/sbin/keepalived /usr/sbin/
cp /opt/wacos/aaatool/keepalived/sbin/keepalived /usr/sbin/
chmod 755 /etc/init.d/keepalived
keepalived启动会默认读取keepalived/keepalived.conf配置文件
mkdir /etc/keepalived
拷贝keepalived.conf配置文件到/etc/keepalived/
keepalived.conf配置文件如下
! Configuration File for keepalived
global_defs {
router_id edu-proxy-02
}
vrrp_script chk_nginx {
script "/etc/keepalived/nginx_check.sh"
interval 2
weight -20
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
mcast_src_ip 10.50.13.68
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_nginx
}
virtual_ipaddress {
10.50.13.67
}
}
启动 关闭 keepalived
service keepalived start[stop]
ip a查看是否绑定虚拟ip10.50.13.67
3,备keepalived安装
和说明主keepalived 过程一样,只是配置文件/etc/keepalived/keepalived。conf一处需要修改
mcast_src_ip 10.50.13.140
4,测试高可用
关掉10.50.13.67的keepalived后,发现vip绑定到了10.50.13.140
重启10.50.13.67的keepalived,vip又重新绑定到了10.50.13.67
以上是关于公司nginx keepalived tomcat cxf 搭建高可用负载均衡实战系列1- keepalived安装配置的主要内容,如果未能解决你的问题,请参考以下文章
LVS+Keepalived+Nginx+Tomcat高可用集群搭建(转)
Nginx+Tomcat反向代理之负载均衡,redis存放session,keepalived暂未搭建
nginx +keepalived
Centos 7 Nginx+Keepalived+Tomcat 源码安装与运用
nginx+keepalived+tomcat实现的高可用
keepalived+nginx实现高可用+tomcat