LVS和keepalived安装过的配置语句
来源:互联网 发布:unity3d有安卓版吗 编辑:程序博客网 时间:2024/06/05 06:02
1.LB安装
apt-get install ipvsadm
2.LB配置
#!/bin/bash
vip=10.5.0.200
rs1=10.5.0.171
rs2=10.5.0.121
#
/sbin/ifconfig eth0:0 10.43.1.4 broadcast 10.43.1.4 netmask 255.255.255.255 up
/sbin/route add -host 10.43.1.4 dev eth0:0
#clear ipvs tables
/sbin/ipvsadm -C
#set LVS Server
/sbin/ipvsadm -A -t 10.43.1.4:80 -s rr
/sbin/ipvsadm -a -t 10.43.1.4:80 -r 10.43.1.7:80 -g
/sbin/ipvsadm -a -t 10.43.1.4:80 -r 10.43.1.8:80 -g
#run lvs
/sbin/ipvsadm
# update /etc/sysctl.conf
#echo "0" >/proc/sys/net/ipv4/ip_forward
#echo "1" >/proc/sys/net/ipv4/conf/all/send_redirects
#echo "1" >/proc/sys/net/ipv4/conf/default/send_redirects
#echo "1" >/proc/sys/net/ipv4/conf/eth0/send_redirects
#/sbin/sysctl -p
3.RS配置
#!/bin/bash
vip=10.5.0.200
/sbin/ifconfig lo:0 $vip broadcast $vip netmask 255.255.255.255 up
/sbin/route add -host $vip dev lo: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
/sbin/sysctl -p
在linux安装LVS后,配置的广播地址,以后负载的真实服务器,真实服务器最好要使用物理机,不要用到虚拟机服务器。因为LVS-DR模式,请求数据里通过IP对应的MAC物理地址。(因为虚拟机的MAC地址和物理主机上有关联原因),导致只会找到主机的MAC地址。
======================================================
1.LB安装
apt-get install ipvsadm
2.LB配置
#!/bin/bash
vip=10.43.1.190
rs1=10.43.1.7
rs2=10.43.1.8
/sbin/ifconfig eth4:0 10.43.1.190 broadcast 10.43.1.190 netmask 255.255.255.255 up
/sbin/route add -host 10.43.1.190 dev eth4:0
/sbin/ifconfig eth0:0 10.43.1.190 broadcast 10.43.1.190 netmask 255.255.255.255 up
/sbin/route add -host 10.43.1.190 dev eth0:0
/sbin/ifconfig eth0:0 10.43.1.120 broadcast 10.43.1.120 netmask 255.255.255.255 up
/sbin/route add -host 10.43.1.120 dev eth0:0
#clear ipvs tables
/sbin/ipvsadm -C
#set LVS Server
/sbin/ipvsadm -A -t 10.43.1.190:8888 -s wrr
/sbin/ipvsadm -a -t 10.43.1.190:8888 -r 10.43.1.9:8888 -w 1
/sbin/ipvsadm -a -t 10.43.1.190:8888 -r 10.43.1.200:8888 -w 1
/sbin/ipvsadm -A -t 10.43.1.120:80 -s rr
/sbin/ipvsadm -a -t 10.43.1.120:80 -r 10.43.1.12:80 -g
/sbin/ipvsadm -a -t 10.43.1.120:80 -r 10.43.1.11:80 -g
/sbin/ipvsadm -a -t 10.43.1.120:80 -r 10.43.1.8:80 -g
#run lvs
/sbin/ipvsadm
update /etc/sysctl.conf
echo "0" >/proc/sys/net/ipv4/ip_forward
echo "1" >/proc/sys/net/ipv4/conf/all/send_redirects
echo "1" >/proc/sys/net/ipv4/conf/default/send_redirects
echo "1" >/proc/sys/net/ipv4/conf/eth0/send_redirects
/sbin/sysctl -p
3.RS配置
#!/bin/bash
vip=10.43.1.190
/sbin/ifconfig lo:0 10.43.1.180 broadcast 10.43.1.180 netmask 255.255.255.255 up
/sbin/route add -host 10.43.1.180 dev lo:0
/sbin/ifconfig lo:0 10.43.1.120 broadcast 10.43.1.120 netmask 255.255.255.255 up
/sbin/route add -host 10.43.1.120 dev lo: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
/sbin/sysctl -p
4.windows
netsh interface ipv4 set interface "本地连接 2" weakhostreceive=enabled
netsh interface ipv4 set interface "本地连接 2" weakhostsend=enabled
netsh interface ipv4 set interface "realserver" weakhostreceive=enabled
netsh interface ipv4 set interface "realserver" weakhostsend=enabled
=========================================
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state SLAVE #指定Keepalived的角色,MASTER为主机服务器,BACKUP为备用服务器
interface eth4
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.43.1.180
}
}
virtual_server 10.43.1.180 80 {
delay_loop 6
lb_algo rr
lb_kind DR
protocol TCP
real_server 10.43.1.11 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 10.43.1.12 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
=================================
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state SLAVE #指定Keepalived的角色,MASTER为主机服务器,BACKUP为备用服务器
interface eth4
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.43.1.180
}
}
virtual_server 10.43.1.180 80 {
delay_loop 6
lb_algo rr
lb_kind DR
protocol TCP
real_server 10.43.1.11 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 10.43.1.12 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
========================================
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
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 {
10.43.1.120
}
}
virtual_server 10.43.1.120 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.255
protocol TCP
real_server 10.43.1.8 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 10.43.1.11 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 10.43.1.12 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
===========================================
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.43.1.120
}
}
virtual_server 10.43.1.120 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.255
protocol TCP
real_server 10.43.1.8 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 10.43.1.11 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 10.43.1.12 80 {
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
- LVS和keepalived安装过的配置语句
- lvs+keepalived的安装与配置
- keepalived+lvs的配置
- lvs和keepalived的结合配置
- lvs keepalived 安装配置详解
- lvs+keepalived集群安装配置
- keepalived + LVS 配置和部署
- Keepalived 的安装和配置
- Keepalived 的安装和配置
- Keepalived的安装和配置
- Keepalived 的安装和配置
- Centos 5.5 lvs+keepalived 安装配置
- lvs(DR)+keepalived+nginx+tomcat安装配置
- LVS+Keepalived+httpd安装及配置
- LVS+Keepalived+nginx安装及配置
- LVS+keepalived keepalived.conf配置
- lvs+keepalived简单配置
- lvs+keepalived简单配置
- postgresql的一些操作记录
- XMPP中常用对象们:
- ajax 向服务器传递数组
- plsql连接远程机器
- FastReport产品介绍及免费下载地址
- LVS和keepalived安装过的配置语句
- HBase总结(十四)LINUX下用Eclipse构建HBase开发环境
- 纠结很久的internal server error
- xmpp 图片、音频
- 【LeetCode刷题Java版】Evaluate Reverse Polish Notation(计算逆波兰表达式)
- 子鬃谞租资啄咨撞最抓桩捉专佐砖柞转灼
- 《我与葡萄城的故事》— 征文大赛
- 中间人攻击
- 程序猿12个人艰不拆的真相