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. hosts文件被修改后的惨案

    在公司MAC电脑上/etc/hosts中尝试反向解析一个ip到localhost, 即:xxx.xxx.xxx.xxx localhost 然后发现tomcat起不来;

  2. AVR 嵌入式单片机芯片的中断系统介绍

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  3. 机器学习之朴素贝叶斯&贝叶斯网络

    贝叶斯决决策论       在所有相关概率都理想的情况下,贝叶斯决策论考虑基于这些概率和误判损失来选择最优标记,基本思想如下: (1)已知先验概率和类条件概率密度(似然) (2)利用贝叶斯转化为后验概 ...

  4. “ORA-12154: TNS: 无法解析指定的连接标识符”错误解决办法

    某政府项目中用.Net网站连接Oracle数据库,web.config使用的连接字符串如下: <add key="connstring_ora" value="Us ...

  5. php上传文件配置

    根据需要调整php.ini文件内容,完成后重启服务器即可. 上传文件相关配置内容: file_uploads = on ;是否允许通过HTTP上传文件的开关.默认为ON即是开 upload_tmp_d ...

  6. selenium中的对文本进行全选,复制,粘贴,剪切和删除的操作

    # 键盘全选操作from selenium.webdriver.common.keys import Keysdriver.find_element_by_css_selector('#key-dem ...

  7. ansible 变量详解

    定义变量的方法 1. 主机变量,在hosts文件中设置变量, [atlanta] host1 http_port= maxRequestsPerChild= host2 http_port= maxR ...

  8. Redis安装以及Java客户端jedis连接不上相关问题解决

    安装步骤 1.由于Redis是由C 语言编写的 所以虚拟机编译需要C的编译环境 用命令 yum install gcc-c++ 2.用SFTP上传Redis安装包并解压 3.进入Redis源码目录 b ...

  9. VMSTAT监控CPU使用率,内存使用,虚拟内存交换情况

    Linux性能监控分析命令(一)—vmstat命令详解 一.vmstat介绍 语法格式: vmstat [-V] [-n] [-S unit] [delay [count]] -V prints ve ...

  10. Linux命令 ls 和 ll 的使用方法与基本区别

    Linux 命令 ls 和 ll 的使用方法: ll:罗列出当前文件或目录的详细信息,含有时间.读写权限.大小.时间等信息 ,像Windows显示的详细信息.ll是“ls -l"的别名.相当 ...