LVS DR SOP

1.1虚拟机地址信息
LVS-DR模式
DR1:172.31.0.29
DR2:172.31.0.28
RS1:172.31.0.25
RS2:172.31.0.26
lvs-client:172.31.0.35

1.2防火墙规则
添加vrrp协议端口号(112)

2、安装LVS+Keepalived软件
2.1、在DR1上安装ipvsadm和keepalived
yum install -y ipvsadm && yum install -y keepalived
2.2、在DR2上安装ipvsadm和keepalived
yum install -y ipvsadm && yum install -y keepalived

3、修改DR1系统配置文件
3.1、在DR1备份原来Keepalived自带的配置文件
mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
3.2、自己写入如下配置文件内容
vim /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
#nopreempt
state BACKUP
virtual_router_id 201
priority 200
interface eth0
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
garp_master_delay 10
preempt_delay 300
#debug

virtual_ipaddress {
172.31.0.201 dev eth0
}
}

virtual_server 172.31.0.201 12345 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 300
protocol TCP

real_server 172.31.0.25 12345 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12345
}
}

real_server 172.31.0.26 12345 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12345
}
}
}

virtual_server 172.31.0.201 12350 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 300
protocol TCP

real_server 172.31.0.25 12350 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12350
}
}

real_server 172.31.0.26 12350 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12350
}
}
}3.2.1启动keepalived并且配置开机自启
Systemctl start keepalived && systemctl enable keepalived
3.3、添加系统优化参数
3.3.1、备份sysctl.conf配置文件
cp /etc/sysctl.conf /etc/sysctl.conf.bak
3.3.2、添加如下参数
vim /etc/sysctl.conf
net.ipv4.ip_local_port_range=1024 65000
net.ipv4.tcp_mem=94500000 915000000 927000000
net.core.netdev_max_backlog=262144
net.ipv4.conf.all.arp_filter=1
#net.ipv4.conf.default.arp_filter=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.tcp_max_orphans=262144
net.ipv4.tcp_max_syn_backlog=262144
net.ipv4.tcp_synack_retries=1
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_max_tw_buckets=100000
net.ipv4.tcp_timestamps=0
net.ipv4.tcp_fin_timeout=30
net.ipv4.tcp_keepalive_time=600
net.ipv4.tcp_keepalive_probes=3
net.ipv4.tcp_keepalive_intvl=15
vm.swappiness=20
vm.vfs_cache_pressure=200
kernel.shmmax=2147483648
kernel.shmall=134217728
kernel.shmmni=4096
kernel.perf_event_max_sample_rate=100000
net.ipv4.ip_forward=1
#net.netfilter.nf_conntrack_max=41237300
#net.netfilter.nf_conntrack_tcp_timeout_established=180
3.3.2、添加/etc/security/limits.d/99-limits.conf参数
vim /etc/security/limits.d/99-limits.conf
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
root soft nproc 65535
root hard nproc 65535
* soft nproc 65535
* hard nproc 65535
root soft core 1048576
root hard core 1048576
* soft core 1048576
* hard core 1048576
3.4查看LVS主机ipvsadm策略
[root@lvs01 ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.31.0.201:12345 wrr persistent 300
-> 172.31.0.25:12345 Route 1 69 295
-> 172.31.0.26:12345 Route 1 50 180
TCP 172.31.0.201:12350 wrr persistent 300
-> 172.31.0.25:12350 Route 1 0 0
-> 172.31.0.26:12350 Route 1 3 0

4、在DR2上执行同DR1相同步骤操作
4.1、在DR2备份原来Keepalived自带的配置文件
mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
4.2、自己写入如下配置文件内容
vim /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
#nopreempt
state BACKUP
virtual_router_id 201
priority 190
interface eth0
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
garp_master_delay 10
preempt_delay 300
#debug

virtual_ipaddress {
172.31.0.201 dev eth0
}
}

virtual_server 172.31.0.201 12345 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 300
protocol TCP

real_server 172.31.0.25 12345 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12345
}
}

real_server 172.31.0.26 12345 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12345
}
}
}

virtual_server 172.31.0.201 12350 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 300
protocol TCP

real_server 172.31.0.25 12350 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12350
}
}

real_server 172.31.0.26 12350 {
weight 1
TCP_CHECK {
connect_timeout 10
#nb_get_retry 3
delay_before_retry 3
connect_port 12350
}
}
}4.2.1启动keepalived并且配置开机自启
Systemctl start keepalived && systemctl enable keepalived
4.3、添加系统优化参数
4.3.1、备份sysctl.conf配置文件
cp /etc/sysctl.conf /etc/sysctl.conf.bak
4.3.2、添加如下参数
vim /etc/sysctl.conf
net.ipv4.ip_local_port_range=1024 65000
net.ipv4.tcp_mem=94500000 915000000 927000000
net.core.netdev_max_backlog=262144
net.ipv4.conf.all.arp_filter=1
#net.ipv4.conf.default.arp_filter=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.tcp_max_orphans=262144
net.ipv4.tcp_max_syn_backlog=262144
net.ipv4.tcp_synack_retries=1
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_max_tw_buckets=100000
net.ipv4.tcp_timestamps=0
net.ipv4.tcp_fin_timeout=30
net.ipv4.tcp_keepalive_time=600
net.ipv4.tcp_keepalive_probes=3
net.ipv4.tcp_keepalive_intvl=15
vm.swappiness=20
vm.vfs_cache_pressure=200
kernel.shmmax=2147483648
kernel.shmall=134217728
kernel.shmmni=4096
kernel.perf_event_max_sample_rate=100000
net.ipv4.ip_forward=1
#net.netfilter.nf_conntrack_max=41237300
#net.netfilter.nf_conntrack_tcp_timeout_established=180
4.3.2、添加/etc/security/limits.d/99-limits.conf参数
vim /etc/security/limits.d/99-limits.conf
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
root soft nproc 65535
root hard nproc 65535
* soft nproc 65535
* hard nproc 65535
root soft core 1048576
root hard core 1048576
* soft core 1048576
* hard core 1048576
4.4查看ipvsadm策略
[root@sh-gtja-lvs02 ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.31.0.201:12345 wrr persistent 300
-> 172.31.0.25:12345 Route 1 0 0
-> 172.31.0.26:12345 Route 1 0 0
TCP 172.31.0.201:12350 wrr persistent 300
-> 172.31.0.25:12350 Route 1 0 0
-> 172.31.0.26:12350 Route 1 0 0

5、在后端RS上执行如下脚本
5.1在RS1上编写LVS-DR脚本内筒如下
[root@RS1 ~]# cat lvs-dr.sh
# vim /usr/local/sbin/lvs_dr_rs.sh
#! /bin/bash
vip=172.31.0.201
ifconfig lo:0 $vip broadcast $vip netmask 255.255.255.255 up
route add -host $vip eth0:0
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
5.2.1设置脚本开机自启
vim /etc/rc.d/rc.local
bash /root/lvs_dr_rs.sh
chmod +x /etc/rc.d/rc.local
5.2在RS2上编写LVS-DR脚本内筒如下
[root@RS2 ~]# cat lvs-dr.sh
# vim /usr/local/sbin/lvs_dr_rs.sh
#! /bin/bash

LVS-DR模式 SOP的更多相关文章

  1. LVS DR模式 负载均衡服务搭建

    LVS 负载均衡 最近在研究服务器负载均衡,阅读了网上的一些资料,发现主要的软件负载均衡方案有nginx(针对HTTP服务的负载均衡),LVS(针对IP层,MAC层的负载均衡).LVS模式工作在网络层 ...

  2. 一个公网地址部署LVS/DR模式

    http://blog.chinaunix.net/uid-7411781-id-3436142.html 一个公网地址部署LVS/DR模式   网上看了很多关于LVS的文章,在选取2种模式LVS/D ...

  3. LVS DR模式搭建、keepalived+lvs

    1.LVS DR模式搭建 条件: 即三台机器,在同一内网. 编辑脚本文件:/usr/local/sbin/lvs_dr.sh #! /bin/bashecho 1 > /proc/sys/net ...

  4. LVS DR模式搭建 keepalived lvs

    LVS DR模式搭建• 三台机器 • 分发器,也叫调度器(简写为dir)172.16.161.130 • rs1 172.16.161.131 • rs2 172.16.161.132 • vip 1 ...

  5. lvs之 lvs+nginx+tomcat_1、tomcat_2+redis(lvs dr 模式)

    前提:已经安装好 lvs+nginx+tomcat_1.tomcat_2+redis环境 ,可参考 (略有改动,比如tomcat_1.tomcat_2安装在两台机器上,而不是单机多实例 ,自行稍稍变动 ...

  6. CentOS下LVS DR模式负载均衡配置详解

    一安装LVS准备: 1.准备4台Centos 6.2 x86_64 注:本实验关闭 SELinux和IPtables防火墙. 管理IP地址 角色 备注 192.168.1.101 LVS主调度器(Ma ...

  7. Keepalived+LVS DR模式高可用架构实践

    Keepalived最初是为LVS设计,专门监控各服务器节点的状态(LVS不带健康检查功能,所以使用keepalived进行健康检查),后来加入了VRRP(虚拟路由热备协议(Virtual Route ...

  8. Linux centosVMware Linux集群架构LVS DR模式搭建、keepalived + LVS

    一.LVS DR模式搭建 三台机器 分发器,也叫调度器(简写为dir) davery :1.101 rs1 davery01:1.106 rs2 davery02:11.107 vip 133.200 ...

  9. LVS DR模式实验

    LVS DR模式实验 三台虚拟机,两个台节点机(Apache),一台DR实验调度机 一:关闭相关安全机制 systemctl stop firewalld iptables -F setenforce ...

  10. lvs dr 模式请求过程

    一. lvs dr 模式请求过程 1.整个请求过程如下: client在发起请求之前,会发一个arp广播的包,在网络中找"谁是vip",由于所有的服务器,lvs和rs都有vip,为 ...

随机推荐

  1. 将MD5值压缩成8位32进制生成8位长度的唯一英文数字组合字符串

    function str16to32($a){ for($a = md5( $a, true ), $s = '0123456789ABCDEFGHIJKLMNOPQRSTUV', $d = '', ...

  2. 如何下载最新Xshell版本、免费官方正版软件的技巧过程

    我们在操作和管理Linux VPS.服务器的时候,肯定需要使用SSH工具,对于这个工具网上有很多免费和付费版本.对于我们用户来说肯定会较多的选择免费软件.其中使用较多的还是Xshell工具,也是我认为 ...

  3. Python收发邮件

    发送邮件使用SMTP协议,接受POP3或IMAP: 创建邮件内容email模块,发送邮件smtplib模块.发送邮件比较简单,只需先创建SMTP对象,登录服务器后根据发收邮箱地址发送即可: POP3接 ...

  4. centos 远程授权

    centos 远程授权命令 ssh-copy-id root@192.168.15.70

  5. webservice接口,用Soapui

    webservice接口怎么测试呢,他不需要你在拼报文了,会给一个webservice的地址,或者wsdl文件,直接在soapui导入,就可以看到这个webservice里面的所有接口,也有报文,直接 ...

  6. 2016/12/21 dplの课练

    1.将/etc/passwd第行的最后一段全部改成/bin/bash cat 1 |sed -n '1,$p' |egrep '.*:' -o |sed 's/$/\bin\/bash/' 2.将/e ...

  7. c# 多线程的几种方式

    1.什么是线程? 进程作为操作系统执行程序的基本单位,拥有应用程序的资源,进程包含线程,进程的资源被线程共享,线程不拥有资源. 2.前台线程和后台线程的区别? 程序关闭时,后台线程直接关闭,但前台线程 ...

  8. python代码规范和命名规范

    一.简明概述 1.编码 如无特殊情况, 文件一律使用 UTF-8 编码 如无特殊情况, 文件头部必须加入#-*-coding:utf-8-*-标识 2.代码格式 2.1.缩进 统一使用 4 个空格进行 ...

  9. python学习-迭代器,列表解析和列表生成式

    迭代器为类序列对象提供了一个类序列的接口.Python 的迭代无缝的支持序列对象,而且还允许程序猿迭代非序列类型,包括用户定义的对象. 迭代器是一个next()方法的对象,而不是通过索引计数.当需要下 ...

  10. Linux三个网络监视器之《二》——nethogs

    当你想要快速了解谁占用了你的带宽时,Nethogs 是快速和容易的.以 root 身份运行,并指定要监听的接口.它显示了空闲的应用程序和进程号,以便如果你愿意的话,你可以杀死它. 1 1.在这个网址f ...