一次lvs迁移记录
需求:从117.119.33.99迁移到122.14.206.125,lvs为dr模式,系统版本为debian7
1、安装lvs和keepalived
# aptitude install -y ipvsadm keepalived
# /etc/init.d/ipvsadm start
# update-rc.d ipvsadm enable
# /etc/init.d/keepalived start
# update-rc.d keepalived enable
2、修改配置文件
主配置文件使用了include进行拆分
# vim keepalived.conf
include /etc/keepalived/vi_bgp_VI1_yizhuang.inc
include /etc/keepalived/vi_bgp_VI2_yizhuang.inc
#include /etc/keepalived/vs_pub_yizhuang.inc
include /etc/keepalived/vs_web1_yizhuang.inc
include /etc/keepalived/vs_newad_yizhuang.inc
include /etc/keepalived/vs_public1_yizhuang.inc
include /etc/keepalived/vs_turbo2sdk_yizhuang.inc
#include /etc/keepalived/vs_china-max_yizhuang.inc
include /etc/keepalived/vs_dsproxy_yizhuang.inc
#include /etc/keepalived/vs_china-max6_yizhuang.inc
include /etc/keepalived/vs_china-turbo-2_yizhuang.inc
include /etc/keepalived/vs_cms_yizhuang.inc
节点角色配置,master和backup节点仅该文件不同,其他配置完全一样,可以用rsync同步
# vim state_VI1.conf
#uy-s-07
state MASTER
priority 150
#uy-s-45
# state BACKUP
# priority 100
# vim state_VI2.conf
#uy-s-07
state BACKUP
priority 100
#uy-s-45
# state MASTER
# priority 150
vrrp实例配置
# vim vi_bgp_VI1_yizhuang.inc
vrrp_instance VII_1 {
virtual_router_id 102
interface eth0
include /etc/keepalived/state_VI1.conf
preempt_delay 120
garp_master_delay 0
garp_master_refresh 5
lvs_sync_daemon_interface eth0
authentication {
auth_type PASS
auth_pass opsdk
}
virtual_ipaddress {
#web1 in yizhuang
122.14.206.128
#pub in yizhuang
122.14.206.127
#new ad in yizhuang
122.14.206.126
#new wood water in yizhuang
122.14.206.125
#turbo2sdk in yizhuang
122.14.206.122
#china-max in yizhuang
122.14.206.121
#china-max6 in yizhuang
122.14.206.120
#china-max6 in yizhuang
122.14.206.119
#china-turbo-2 in yizhuang
122.14.206.118
}
}
# vim vi_bgp_VI2_yizhuang.inc
vrrp_instance VII_2 {
virtual_router_id 202
interface eth0
include /etc/keepalived/state_VI2.conf
preempt_delay 120
garp_master_delay 0
garp_master_refresh 5
lvs_sync_daemon_interface eth0
authentication {
auth_type PASS
auth_pass opsdk
}
virtual_ipaddress {
#duanzi in yizhuang
122.14.206.117
}
}
virtual_server配置
# vim vs_public1_yizhuang.inc
###122.14.206.125:80 122.14.206.125:80 public1###
virtual_server 122.14.206.125 80 {
lb_algo sh
lb_kind DR
persistence_timeout 0
delay_loop 20
protocol TCP
# uy04-04 has address 122.14.206.140
real_server 122.14.206.140 80 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy04-05 has address 122.14.206.141
real_server 122.14.206.141 80 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy07-01 has address 122.14.206.143
real_server 122.14.206.143 80 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy07-02 has address 122.14.206.144
real_server 122.14.206.144 80 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy07-05 has address 122.14.206.146
real_server 122.14.206.146 80 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy07-06 has address 122.14.206.147
real_server 122.14.206.147 80 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
}
###122.14.206.125:443 122.14.206.125:443 public1###
virtual_server 122.14.206.125 443 {
lb_algo sh
lb_kind DR
persistence_timeout 0
delay_loop 20
protocol TCP
# uy01-01 has address 122.14.206.140
real_server 122.14.206.140 443 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy01-02 has address 122.14.206.141
real_server 122.14.206.141 443 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy01-03 has address 122.14.206.143
real_server 122.14.206.143 443 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy01-04 has address 122.14.206.144
real_server 122.14.206.144 443 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy01-05 has address 122.14.206.146
real_server 122.14.206.146 443 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
# uy01-06 has address 122.14.206.147
real_server 122.14.206.147 443 {
weight 10
TCP_CHECK {
connect_timeout 10
}
}
}
# vim vs_dsproxy_yizhuang.inc
###122.14.206.125:2012 122.14.206.125:2012 dsproxy###
virtual_server 122.14.206.125 2012 {
lb_algo rr
lb_kind DR
persistence_timeout 0
delay_loop 20
protocol UDP
# uy04-10-v09 has address 192.168.10.88
real_server 122.14.206.141 2012 {
weight 5
MISC_CHECK {
misc_path "/etc/keepalived/UDP_CHECK.sh 192.168.10.88 2012"
misc_timeout 10
}
}
# uy01-02-v12 has address 192.168.10.89
real_server 122.14.206.140 2012 {
weight 5
MISC_CHECK {
misc_path "/etc/keepalived/UDP_CHECK.sh 192.168.10.89 2012"
misc_timeout 10
}
}
}
udp检测脚本
# vim /etc/keepalived/UDP_CHECK.sh
#!/bin/bash
/bin/nc -unvz -w 1 $1 $2 2>&1 | grep open &> /dev/null
exit $?
配置文件同步及服务重载脚本,这里使用了git管理配置文件
# vim rsync2backup.sh
#!/bin/bash
git add ./*
git commit -m "commit on: $(date +%F' '%T)" -a
/etc/init.d/keepalived reload
cd /etc/keepalived
rsync -avz --delete --exclude=.git --exclude=state*.conf --exclude=rsync2backup.sh ./ 192.168.1.250:`pwd`/
ssh 192.168.1.250 '/etc/init.d/keepalived reload'
3、配置Real Server,这里有6台Real Server
a、在lo网卡上配置vip
# ifconfig lo:125 122.14.206.125 netmask 255.255.255.255 up
# vim /etc/network/interfaces
auto lo:125
iface lo:125 inet static
address 122.14.206.125
netmask 255.255.255.255
b、修改arp内核参数
# vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.ip_forward = 1
net.ipv4.nf_conntrack_max = 2048000
net.netfilter.nf_conntrack_max = 2048000
# sysctl -p
c、挑两台Real Server为udp服务设置iptables转发规则
# iptables -t nat -I PREROUTING -d 122.14.206.125 -p udp --dport 2012 -j DNAT --to 192.168.10.88:2012
# iptables -t nat -I POSTROUTING -p udp --dport 2012 -j SNAT --to-source 122.14.206.125
# iptables -vnL -t nat
# iptables-save
4、重载服务
# /etc/init.d/keepalived reload
这里可以使用同步脚本
5、查看lvs规则
# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=1048576)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 122.14.206.125:80 sh
-> 122.14.206.140:80 Route 10 37942 5108
-> 122.14.206.141:80 Route 10 37034 5506
-> 122.14.206.143:80 Route 10 46782 5907
-> 122.14.206.144:80 Route 10 37518 5844
-> 122.14.206.146:80 Route 10 37340 4928
-> 122.14.206.147:80 Route 10 46501 6221
TCP 122.14.206.125:443 sh
-> 122.14.206.140:443 Route 10 3999 4061
-> 122.14.206.141:443 Route 10 3904 3692
-> 122.14.206.143:443 Route 10 5116 4551
-> 122.14.206.144:443 Route 10 4529 4298
-> 122.14.206.146:443 Route 10 3944 3685
-> 122.14.206.147:443 Route 10 3916 3719
UDP 122.14.206.125:2012 rr
-> 122.14.206.140:2012 Route 5 0 260
-> 122.14.206.141:2012 Route 5 0 261
6、修改本地hosts,将域名指向新的vip在本地测试,这里略过
7、确认没问题就可以切换dns了,修改dns然后重载dns服务
# vim oupeng.com.zone.ALL
;outspot6-yizhuang IN A 117.119.33.99 ;117.119.33.11,117.119.33.12,117.119.33.13,117.119.33.14,117.119.33.41
outspot6-yizhuang IN A 122.14.206.125 ;122.14.206.140,122.14.206.141,122.14.206.143,122.14.206.144,122.14.206.146,122.14.206.147
至此,迁移就全部完成了,可以尝试访问一下lvs代理的服务确认一切正常。
一次lvs迁移记录的更多相关文章
- vsftp迁移记录笔记
由于之前的服务器用的window下的ftp安全性和稳定性都不好,所以我们才把ftp迁移到linux环境下 vsftp概述: vsftpd 它可以运行在多平台系统上面,是一个完全免费的.开放源代码的f ...
- Linux下一次数据仓库进行迁移记录
转载请把头部出处链接和尾部二维码一起转载,本文出自逆流的鱼yuiop:http://blog.csdn.net/hejjunlin/article/details/52768613 前言:数据库每天的 ...
- EFCore合并多条迁移记录
方法来自 merge-migrations-in-entity-framework-core 更新数据库到最新结构 删除迁移目录下的所有迁移脚本 新建一个迁移 注释掉Up()和Down()方法中的代码 ...
- weblogic服务目录迁移记录
weblogic服务,由于前期的规划不好,导致后期有点问题!为了更加规范运行服务及执行相关操作,故进行服务迁移... 先决条件:weblogic都是单个aminserver运行的,单个服务 问题解决: ...
- 【Python】Django删除数据迁移记录
find . -path "*migrations*" -name "*.py" -not -path "*__init__*" -exec ...
- LVS配置记录
目录: 一.NAT模式配置 二.DR模式配置 三.TUN模式配置 LVS原理及架构不再赘述. 一.NAT模式 部署环境 注意: 1) DIP.RIP必须为同网段: 2) RS网关必须指向DS: 3) ...
- MySQL-线上数据迁移实战记录
1. 迁移背景和限制条件 随着功能的迭代或者数据表中数据量的增加,将现有数据进行迁移已是工作中经常遇到的事情.通常我们在平时迁移数据数据的时候,只需要用mysqldump.mysqlimport指令就 ...
- lvs学习笔记
本人身为一个网工,最近一直在工作中学习linux的相关知识.前短时间通过自查资料学习了lvs的相关内容,摘录部分整理后和大家分享,内容较多,较琐碎,望见谅!!! LVS 从Linux内核版本2.6起, ...
- 全自动迁移数据库的实现 (Fluent NHibernate, Entity Framework Core)
在开发涉及到数据库的程序时,常会遇到一开始设计的结构不能满足需求需要再添加新字段或新表的情况,这时就需要进行数据库迁移. 实现数据库迁移有很多种办法,从手动管理各个版本的ddl脚本,到实现自己的mig ...
随机推荐
- 【Docker】第五篇 Docker 数据管理
一.基本介绍 数据管理的原因:Docker中的容器一旦删除,容器本身的rootfs文件系统就会被删除,容器中的所有数据就会被删除.为了对一些需要持久化的数据,不随容器删除而删除,所以我们可以通过多个容 ...
- windows下在virtualbox中的Fuel Openstack 9.0 安装过程
一.材料: 1.软件: virtualbox xshell(或putty,winscp) bootstrap.zip(580MB) mirrors(3.01GB) MirantisOpenStack- ...
- AES128加密算法完整实现
概述 原本想把自己AES加密算法的整个实现过程给详细复述下来,分享给想学习的同学,也方便自己复习,但后来发现该工作量太大,加上作业太多没有过多的时间去写.所以就想把自己在学习的过程中多遇到的好的文章进 ...
- dmesg命令详解
基础命令学习目录 http://linux.cn/article-3587-1.html dmesg 命令的使用范例 下面我们展示一些最负盛名的‘dmesg’命令工具以及其实际使用举例.‘dmesg’ ...
- python清空列表的方法
1.大数据量的list,要进行局部元素删除,尽量避免用del随机删除,非常影响性能,如果删除量很大,不如直接新建list,然后用下面的方法释放清空旧list. 2.对于一般性数据量超大的list,快速 ...
- 开发简单的IO多路复用web框架
自制web框架 1.核心IO多路复用部分 # -*- coding:utf-8 -*- import socket import select class Snow(): def __init__(s ...
- 设计与实现分离——面向接口编程(OO博客第三弹)
如果说继承是面向对象程序设计中承前启后的特质,那么接口就是海纳百川的体现了.它们都是对数据和行为的抽象,都是对性质和关系的概括.只不过前者是纵向角度,而后者是横向角度罢了.今天呢,我想从设计+语法角度 ...
- 课堂实践ASL博客
实践博客 二分法查找元素 1.首先定义三个位置min,mid,max 2.每次从所有元素所处位置的中间开始查找(所有元素必须以由小及大顺序排列完毕) 3.当中间元素大于所查找元素时,从中间元素(mid ...
- iOS开发学习-放大长图与屏幕等宽
/* 需要得到一个图片的放大比例,这个比例就是屏幕的宽度与图片真实宽度的比值 */ CGFloat newZoomScale = LZ_SCREEN_WIDTH / [_photoImageView. ...
- 《Spring2之站立会议9》
<Spring2之站立会议9> 昨天,添加了注册界面: 今天,添加了表情库: 遇到的问题:由于资源有限,感觉设计的不完美并且途中也遇到了好多问题.