lvs主主互备

项目名称:lvs双主负载均衡

项目描述:lvs双主负载web为CDN客户提供访问

项目技术:lvs双主负载Nginx

lvs+keepalived

192.168.110.130

vip1:192.168.110.140

lvs+keepalived

192.168.110.131

vip2:192.168.110.141

Nginx1

192.168.110.132

vip1:192.168.110.140

vip2:192.168.110.141

Nginx2

192.168.110.133

vip1:192.168.110.140

vip2:192.168.110.141

lvs上安装keepalived和ipvsadm

#!/bin/bash

#判断执行结果

judge() {

if [ $? -eq 0 ];then

echo "successfully...."

else

echo "filed...."

exit

fi

}

#http://www.linuxvirtualserver.org/software/kernel-2.6

#http://www.keepalived.org/software

echo "环境安装"

yum -y install gcc openssl openssl-devel popt popt-devel net-snmp  net-snmp-devel libnl* &>> /dev/null

judge

echo "安装ipvsadm"

cd /usr/local/src

yum -y install ipvsadm &>> /dev/null

judge

echo "下载并安装keepalived"

wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz &>> /dev/null

tar -zxf keepalived-1.2.7.tar.gz

cd keepalived-1.2.7

echo "执行configure"

./configure --prefix=/usr/local/keepalived --enable-snmp --sysconfdir=/etc &>> configure-`date +%F`.log

judge

echo "执行make"

make &>> make-`date +%F`.log

judge

echo "执行make install"

make install &>> make_install-`date +%F`.log

judge

rm -rf configure-`date +%F`.log make-`date +%F`.log make_install-`date +%F`.log

cp /usr/local/keepalived/sbin/keepalived  /sbin/

cp /usr/local/keepalived/bin/genhash /bin/

webserver上配置VIP

#!/bin/bash

#description:start realserver

#script_name:realserver_config

VIP1="192.168.110.140"     #虚拟IP

VIP2="192.168.110.141"     #虚拟IP

source /etc/init.d/functions

case "$1" in

start)

echo "start LVS of realserver."

echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignore

echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce

echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore

echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce

/sbin/ifconfig lo:0 $VIP1 broadcast $VIP1 netmask 255.255.255.255 up

/sbin/ifconfig lo:1 $VIP2 broadcast $VIP2 netmask 255.255.255.255 up

;;

stop)

echo "0" > /proc/sys/net/ipv4/conf/lo/arp_ignore

echo "0" > /proc/sys/net/ipv4/conf/lo/arp_announce

echo "0" > /proc/sys/net/ipv4/conf/all/arp_ignore

echo "0" > /proc/sys/net/ipv4/conf/all/arp_announce

/sbin/ifconfig lo:0 down

/sbin/ifconfig lo:1 down

;;

*)

echo "Usage: $0 {start|stop}"

exit 1

esac

lvs1配置keepalived

global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server [email protected]

smtp_connect_timeout 30

router_id LVS_DEVEL

}

vrrp_instance VI_1 {

state MASTER

interface eth0

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.110.140

}

}

virtual_server 192.168.110.140 80 {

delay_loop 6

lb_algo wrr

lb_kind DR

#   nat_mask 255.255.255.0

#   persistence_timeout 50

protocol TCP

real_server 192.168.110.132 80 {#real server上80端口

weight 5

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.110.133 80 {

weight 3

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

vrrp_instance VI_2 {

state BACKUP

interface eth0

virtual_router_id 52

priority 90

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.110.141

}

}

virtual_server 192.168.110.141 80 {

delay_loop 6

lb_algo wrr

lb_kind DR

#   nat_mask 255.255.255.0

#   persistence_timeout 50

protocol TCP

real_server 192.168.110.132 80 {#real server上80端口

weight 5

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.110.133 80 {

weight 3

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

lvs2配置keepalived

global_defs {

notification_email {

[email protected]

}

notification_email_from [email protected]

smtp_server [email protected]

smtp_connect_timeout 30

router_id LVS_DEVEL

}

vrrp_instance VI_1 {

state BACKUP

interface eth0

virtual_router_id 51

priority 90

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.110.140

}

}

virtual_server 192.168.110.140 80 {

delay_loop 6

lb_algo wrr

lb_kind DR

#   nat_mask 255.255.255.0

#   persistence_timeout 50

protocol TCP

real_server 192.168.110.132 80 {#real server上80端口

weight 5

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.110.133 80 {

weight 3

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

vrrp_instance VI_2 {

state MASTER

interface eth0

virtual_router_id 52

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.110.141

}

}

virtual_server 192.168.110.141 80 {

delay_loop 6

lb_algo wrr

lb_kind DR

#   nat_mask 255.255.255.0

#   persistence_timeout 50

protocol TCP

real_server 192.168.110.132 80 {#real server上80端口

weight 5

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 192.168.110.133 80 {

weight 3

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

时间: 2024-10-10 10:04:27

lvs主主互备的相关文章

centos lvs+keepalived+mysql实现mysql数据库热备主主复制-亲测ok

实验环境: linux:centos6.6 虚拟ip(vip):192.168.135.199 mysql master:192.168.20.193 mysql slave:192.168.20.195 (这里只是为了后文方便区分,一个叫master,一个叫slave,其实在主主复制中,都是master也都是slave,没有主从之分) mysql的版本: [[email protected] ~]# mysql -V mysql  Ver 14.14 Distrib 5.1.73, for r

MySQL主主互备模式(Keepalived)

MySQL双主-高可用 单台数据库实例安装 请参考:二进制包安装MySQL 资源规划 主机名 os 版本 MySQL 版本 主机 IP MySQL VIP db01.lyk.com centos 6.4 mysql-5.6.21-linux-glibc2.5-x86_64 172.31.30.12 172.31.30.222 db02.lyk.com centos 6.4 mysql-5.6.21-linux-glibc2.5-x86_64 172.31.30.11 3.修改MySQL配置文件

MySQL双主互备模式架构

MySql双主互备架构模式 操作系统 CentOS 6.3 MySql版本 mysql-5.0.56 keepalived keepalived-1.1.19.tar.gz Master DB1配置文件 修改MySql 配置文件  /etc/my.cnf 增加以下段落 [mysqld] server-id=1    节点标示 log-bin=mysql-bin   开启mysql的binlog日志功能 relay-log = mysql-relay-bin  用来定义日志文件命名格式 repli

mysql主主互备模式配置

本文为南非蚂蚁的书籍<循序渐进linux-第二版>-8.3.5的读笔记 mysql双主互备架构图 mysql主主互备模式配置 环境: DB1:主服务器  centos6.6  mysql5.1.73 IP:10.24.24.111 DB2:从服务器  centos6.6  mysql5.1.73 IP:10.24.24.112 mysql VIP:10.24.24.112 ---------------------------------------- centos6.x安装mysql # y

MySQL主主互备结合keepalived实现高可用

试验环境: master:192.168.1.210(CentOS6.5) slave:192.168.1.211(CentOS6.5) VIP:192.168.1.208 MySQL主主互备模式配置 step1:Master服务的/etc/my.cnf配置 [mysqld] basedir = /usr/local/mysql datadir = /var/lib/mysql port = 3306 socket = /var/lib/mysql/mysql.sock server_id = 

[Mysql高可用]——双主互备+keepalived

实验架构图    实验环境 主机名 操作系统 Mysql版本 keepalived版本 主机IP VIP lyj1(Master/Slave) Red Hat release 6.5 Mysql5.6.31 keepalived-1.2.12 10.0.100.201 10.0.100.220 lyj2(Slave/Master) Red Hat release 6.5 Mysql5.6.31 keepalived-1.2.12 10.0.100.202 构建双主互备 1. 分别修改DB1和DB

Keepalived+nginx双主互备模型实现

Keepalived双主互备模型实现 实验拓扑概述 本次实验所涉及的系统发行版本为:CentOS6.6-64bit:内核版本:2.6.32-504.el6.x86_64 (nod1)Nginx代理1:配置有nginx服务,向外部宣称一个公网ip接收外部客户端请求,网卡eth0桥接模式,配置有内网ip172.16.13.11:eth1(1.1.1.2/24)仅主机模式,模拟与出口路由器通信接口,nod1为VIP1的MASTER时,VIP(1.1.1.100/32)配置于eth1的别名eth1:1上

keepalived高可用lvs集群,主/备和主/主模型

利用keepalived高可用lvs集群,主/备和主/主: vrrp_script高可用双主nginx: keepalived主备:lvs-dr工作模型 网络搭建: 在前端2台调度器: DR1:172.18.11.111 DR2:172.18.11.112 VIP:172.18.11.7 后端2台web服务器,运行nginx: RS1:172.18.11.11 RS2:172.18.11.12 搭建web服务器: 提供简单的测试页面,以便容易观测到哪台RS被调度响应: 在RS1上: ]# yum

mysql主主互备架构

企业级mysql集群具备高可用,可扩展性,易管理,低成本的特点.mysql主主互备就是企业中常用的一个解决方案.在这种架构中,虽然互为主从,但同一时刻只有一台mysql 可读写,一台mysqk只能进行读操作 1.配置 环境: DB1(master)  mysql-5.1.73-3.el6_5.x86_64   192.168.32.130 DB2 (slave)    mysql-5.1.73-3.el6_5.x86_64    192.168.32.129 mysql vip : 192.16