首页 > 代码库 > LVS线上操作说明
LVS线上操作说明
目的
提供游戏前端的高可用性
上线步骤
1、给10.10.0.35 节点各分配一个LVS专用网段的IP:x.x.x.x
vi /etc/sysconfig/network-scripts/ifcfg-eth1:1
DEVICE="eth1:1"
BOOTPROTO="none"
ONBOOT="yes"
IPADDR=x.x.x.x
NETMASK=255.255.255.0
TYPE="Ethernet"
2、在x.x.x.x上操作如下:
echo "from 192.168.166.0/24 table ZW_1-4_LVS_LAN1" >/etc/sysconfig/network-scripts/rule-eth1
echo "default table ZW_1-4_LVS_LAN1 via 192.168.166.1" >/etc/sysconfig/network-scripts/route-eth1
echo "203 ZW_1-4_LVS_LAN1" >> /etc/iproute2/rt_tables
启动网卡
ifup eth1:1
3、在调度机(主:x.x.x.x;备:x.x.x.x)上操作如下:
A、路由功能设置:
ip rule add from x.x.x.x/32 table eth1
echo "from x.x.x.x/32 table eth1" >> /etc/sysconfig/network-scripts/rule-eth1
B、keepalived配置:
vi /etc/keepalived/youxi.conf(创建游戏项目配置文件)
virtual_server x.x.x.x 80 {
delay_loop 6
lb_algo wrr
lb_kind NAT
persistence_timeout 60
protocol TCP
include /etc/keepalived/realserver/youxi/192.168.166.35_80.conf
}
vi /etc/keepalived/lvs_module(加入游戏业务)
! youxi.conf
include /etc/keepalived/youxi.conf
vi /etc/keepalived/vrrpd_module(在vrrp_instance ZW_Account1_WAN2中加入x.x.x.x #游戏)
vrrp_instance ZW_Account1_WAN2 {
state MASTER
interface eth1
virtual_router_id 212
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 917C3D6A
}
virtual_ipaddress {
x.x.x.x # 账号: account
x.x.x.x # app.sjk.ijinshan.com
x.x.x.x # up.liebao.cn
x.x.x.x #CDN 下载
x.x.x.x #cs3
x.x.x.x #游戏
}
}
mkdir /etc/keepalived/realserver/youxi(创建放游戏节点的文件夹)
vi /etc/keepalived/realserver/youxi/192.168.166.35_80.conf(创建realserver配置文件:192.168.166.35)
real_server 192.168.166.35 80 { #创建realserver
weight 10 #权重
TCP_CHECK {
connect_timeout 10 #10秒无响应超时
nb_get_retry 3 #重连次数
delay_before_retry 3 #重连间隔,单位为秒
connect_port 80 #检测端口
}
/etc/init.d/keepalived reload;tailf /var/log/messages(切记不要重启keepalived,并查看日志是否有异常,)
3、验证服务是否正常
A、reload调度机后查看日志
B、用脚本检验是否所有VIP端口都正常服务,脚本如下(把所有vip:port加到hostlist里面):
#!/bin/bash
hostlist=" x.x.x.x:8080"
for i in $hostlist
do
curl -s $i -o /dev/null && echo "$i ok" || echo "$i fail"
done
C、ipvsadmin -Ln ipvsadm -Ln --stats 看数据包是否都正常调度
新业务模块的监控
录入http://ops.kisops.com/lvsadmin平台
新模块的日志切割和统计需求
无日志。
回滚步骤
此操作无需回滚,如果主调度重启keepalived之后有异常,停掉主调度的keepalived,业务自动切到备调度上。