Lvs/DR for CentOS+Windows2008r2构架: 控制器+ 2008web处理服务器 控制器管理IP1.1.1.1, 绑定vip1.1.1.250 webIP:RS1=192.168.228.219 RS2=192.168.228.220 一. Director Server调度器配置[系统:Centos 6.4纯净班] #修改hostname sed -i 's/ebs-.*/Director-YYY/' /etc/sysconfig/network ; hostname Director-YYY #关闭防火墙 chkconfig iptables off service iptables stop #同步时间 yum install -y ntpdate /usr/sbin/ntpdate cn.pool.ntp.org crontab -e */30 * * * * /usr/sbin/ntpdate cn.pool.ntp.org #把内核目录做好软连接 ln -s /usr/src/kernels/`uname -r` /usr/src/linux #创建下载目录 mkdir /downloads ; cd /downloads #下载ipvsadm keepalived 源代码 wget -c http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz wget -c http://www.keepalived.org/software/keepalived-1.2.14.tar.gz #安装依赖包 yum -y install gcc make openssl-devel openssl net-snmp net-snmp-devel popt popt-devel #开机绑定vip和增加路由 vi /etc/rc.local /sbin/ifconfig eth0:0 1.1.1.250 broadcast 1.1.1.250 netmask 255.255.255.255 broadcast 1.1.1.250 up /sbin/route add -host 1.1.1.250 dev eth0:0 tar -zxvf /downloads/ipvsadm-1.24.tar.gz -C /downloads/ cd /downloads/ipvsadm-1.24 make && make install find / -name ipvsadm #查看安装是否成功 tar -zxvf /downloads/keepalived-1.2.14.tar.gz -C /downloads/ cd /downloads/keepalived-1.2.14 ./configure --enable-snmp && make && make install find / -name keepalived #查看安装是否成功 cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/ mkdir /etc/keepalived ln -s /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ ln -s /usr/local/sbin/keepalived /usr/sbin/ chkconfig keepalived on #设置自启动 #service keepalived start|stop #做成系统启动服务方便管理. #添加keepalived配置 vi /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { router_id LVS_YYY1 #负载均衡器标识,同一网段内,可以相同 }
vrrp_instance VI_YYY1 { state MASTER #主调度器 interface eth0 #实例绑定的网卡 #lvs_sync_daemon_inteface eth0 #主备间的监控接口 virtual_router_id 61 #vrrp唯一ID,主备id一致 priority 100 #优先级 advert_int 10 #主备间同步检查/秒 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 1.1.1.250 #vip,可以多个ip,每行一个 } } virtual_server 1.1.1.250 80 { #定义一个虚拟服务器
delay_loop 6 #健康检测间隔/秒 lb_algo wlc #调度算法 lb_kind DR #模式 persistence_timeout 30 #回话保持时间 protocol TCP #转发协议 #多个real_server重复本节点即可 real_server 192.168.228.219 80 { #定义一台真实服务器 weight 3 #权重 TCP_CHECK { #通过tcpcheck判断真实服务器状态 connect_timeout 10 #连接超时 nb_get_retry 3 #重试次数 delay_before_retry 3 #重试间隔 connect_port 80 #检测端口 } } } #重启服务器检查服务运行是否正常 二、Windows2008配置 创建windows环回网卡 这是一样很古老的东东了 打开 设备管理器—选中‘网络适配器’—操作---添加过时硬件 直接 下一步, 一直完成就OK;然后设置Ip 修改RS端网卡接口、环回接口连接模式(至关重要) 在cmd下 netsh interface ipv4 set interface "网卡名称" weakhostreceive=enabled netsh interface ipv4 set interface "网卡名称" weakhostsend=enabled netsh interface ipv4 set interface "环回网卡名称" weakhostreceive=enabled netsh interface ipv4 set interface "环回网卡名称" weakhostsend=enabled
此处的网卡名称要换为实例名称本例中应该是 “本地连接 11”(是外网)或者“本地连接 9”(是内网)和“本地连接 12”
好了,配置没有错误的话用1.1.1.250 就可以访问了!! RS为linux 的话配置就更简单 ifconfig eth0:1.1.1.250 netmask 255.255.255.255 broadcast 1.1.1.250 up route add -host 1.1.1.250 dev eth0:100 ipvsadm -C ipvsadm -A -t 1.1.1.250:80 -s rr ipvsadm -a -t 1.1.1.250:80 -r 192.168.228.220 -i ipvsadm -a -t 1.1.1.250:80 -r 192.168.228.219 -i ipvsadm 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 RS1和RS2设置如下: ifconfig tunl0 1.1.1.250 netmask 255.255.255.255 broadcast 1.1.1.250 up route add -host 1.1.1.250 dev tunl0 echo "0" > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/conf/tunl0/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/tunl0/arp_announce echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce echo 0 > /proc/sys/net/ipv4/conf/tunl0/rp_filter echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter 若无法访问注意防火墙,可关闭!!
|
|||||
>> 相关文章 | |||||