国内私募机构九鼎控股打造APP,来就送 20元现金领取地址: 内部邀请码: C8E245J (不写邀请码,没有现金送) 国内私募机构九鼎控股打造,九鼎投资是在全国股份转让系统挂牌的公众公司,股票代码为430719,为“中国PE第一股”,市值超1000亿元。
------------------------------------------------------------------------------------------------------------------------------------------------------------------
lvs+DR置文档:(64位机器)
#create by laoseng
#lvs最好的是用url进行健康检测。但是端口方便,一般用。在配置文件,其中的url字符串是md5加密的值.学习补充!lvs重启后恢复需要15s环境: 系统版本:Centos5.4(64位) 软件版本:ipvsadm-1.24.tar.gz,keepalived-1.1.17.tar.gz lvs1(Master): eth0: 192.168.1.131 eth1:192.168.2.131vip: ip:192.168.1.133lvs2(Backup): eth0: 192.168.1.132 eth1:192.168.2.132vip: 暂时无#建议内网外ip分配采用最后8位相同的方式,这样便于管理web: realServer1 eth0:192.168.1.134 realServer2 eth0:192.168.1.135mkdir -p /tool/laoseng/lvscd /tool/laoseng/lvswget wget modprobe ip_vs #把ip_vs模块加载到内核lsmod|grep ip_vscat /etc/redhat-releaseuname -ryum install -y kernel-develln -s /usr/src/kernels/2.6.32-220.el6.i686 /usr/src/linux2.6.32-220.el6.i686#安装ipvsadm软件cd /tool/laoseng/lvstar zxvf ipvsadm-1.24.tar.gzcd ipvsadm-1.24makemake installcd ../#安装keepalived软件cd /tool/laoseng/lvstar zxvf keepalived-1.1.17.tar.gzcd keepalived-1.1.17./configuremakemake installcd ..#查看安装状况并复制到启动目录下:ls -l /usr/local/sbin/keepalivedls -l /usr/local/etc/rc.d/init.d/keepalivedls -l /usr/local/etc/sysconfig/keepalivedls -l /usr/local/etc/keepalivedcp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/mkdir /etc/keepalivedcp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/cp /usr/local/sbin/keepalived /usr/sbin/service keepalived start#配置转发及其防火墙 sed -i 's#net.ipv4.ip_forward = 0#net.ipv4.ip_forward=1#' /etc/sysctl.confsysctl -p#配置文档keepalived.confvim /etc/keepalived/keepalived.conf#====================lvs1上的======start=======================! Configuration File for keepalivedglobal_defs { #全局配置 notification_email { #通知邮件。 } notification_email_from smtp_server 127.0.0.1 #连接本机的mail smtp_connect_timeout 30 router_id LVS_laoseng01 #唯一的lvs1和lvs2应该配置不同名字。这里设置lvs1VS_laoseng01 lvs2:LVS_laoseng02}vrrp_instance VI_1 { #一个实例,一个实例代表一个服务 state MASTER #lvs1和lvs2上设置不同,lvs1:MASTER lvs2:BACKUP interface eth0 #获取数据的网卡,一般生产环境上是外网的ip。 lvs_sync_daemon_inteface eth1 virtual_router_id 51 priority 150 #备份服务上优先级要低于100,如改为90 advert_int 1 #检测的间隔,按秒。 authentication { #检测密钥,就是接头暗号。 auth_type PASS auth_pass 1111 } virtual_ipaddress { #是对外服务的ip。就是让用户访问的。VIP.就是以后网站对外提供服务的ip。域名需要绑定此ip #192.168.200.16 192.168.1.133 }}virtual_server 192.168.1.133 80 { #那个vip提供转发,就是接受到用户请求后转发的ip delay_loop 6 #轮训 lb_algo wrr #算法 lb_kind DR nat_mask 255.255.255.0 persistence_timeout 50 #会话保持 50秒 protocol TCP #tcp服务 real_server 200.166.188.108 80 { #转发给的真是的webip weight 1 TCP_CHECK { connect_timeout 8 #超时时间 nb_get_retry 3 #尝试次数。 delay_before_retry 3 #延迟。 connect_port 80 #连接端口。 } } real_server 200.166.188.109 80 { weight 1 TCP_CHECK { connect_timeout 8 nb_get_retry 3 delay_before_retry 3 connect_port 80 } }}#====================lvs1上的======end=========================#lvs2上配置更改根据上边。#启动服务/etc/init.d/keepalived start#查看进程和lvs状态ps -ef |grep keepalivedipvsadm -L -n#==========start======================在web realserver服务器=================================#在每个web端执行脚本ipvs_rs可以放到/usr/local/sbin/#!/bin/bash# Written by laoseng ()# description: Config realserver lo and apply noarp WEB_VIP=192.168.1.133. /etc/rc.d/init.d/functions #加载系统的函数库。case "$1" instart) ifconfig lo:0 $WEB_VIP netmask 255.255.255.255 broadcast $WEB_VIP #绑定ip.linux上一个网卡可以绑定多个,lo:0中的0只能到255 /sbin/route add -host $WEB_VIP dev lo:0 #添加一个主机路由到lo:0上 echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore #下边的四行是抑制arp响应。通过的arp欺骗来完成。让lvs选择发给谁,而不是让他们自动响应。 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 sysctl -p >/dev/null 2>&1 echo "RealServer Start OK" ;;stop) ifconfig lo:0 down route del $WEB_VIP >/dev/null 2>&1 echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce echo "RealServer Stoped" ;;status) # Status of LVS-DR real server. islothere=`/sbin/ifconfig lo:0 | grep "$WEB_VIP"` isrothere=`netstat -rn | grep "lo:0" | grep "$web_VIP"` if [ ! "$islothere" -o ! "isrothere" ];then # Either the route or the lo:0 device # not found. echo "LVS-DR real server Stopped." else echo "LVS-DR Running." fi;;*) # Invalid entry. echo "$0: Usage: $0 {start|status|stop}" exit 1;;esacexit 0#==========end======================在web realserver服务器===================================#查看ip状态ifconfig#解决694 udp端口iptables -A INPUT -p udp --dport 694 -j APPCPT;