标签:var drbd 方式 linux内核 eth aide lin 结果 boot
一、群集、集群Cluster,由多台主机构成,但对外只表现为一个整体
第六层、监控:AIDE、Zabbix
modprobe ip_vs
//添加内核对lvs模块的支持
lsmod | grep ip_vs
//过滤查看是否加载lvs模块
优点
1.开源,免费
2.在网上能找到一些相关技术资源
3.具有软件负载均衡的一些优点
缺点
1.最核心的就是没有可靠的支持服务,没有人对其结果负责;
2.功能比较简单,支持复杂应用的负载均衡能力较差,如算法较少等;
3.开启隧道方式需重编译内核;
4.配置复杂;
5.主要应用于LINUX,目前没有专门用于WINDOWS的版本,不过可以通过配置,使windows成为LVS集群中的real server(win2003、win2008中)。
1.配置IP地址
vim /etc/sysconfig/network-scrips/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
/etc/init.d/network restart
2.配置安装YUM
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
mount /dev/cdrom /mnt
3.部署httpd
yum -y install httpd
echo "Web1" >/var/www/html/index.html
/etc/init.d/httpd start && chkconfig --level 35 httpd on
1.配置IP地址
vim /etc/sysconfig/network-scrips/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.1.20
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
/etc/init.d/network restart
2.配置安装YUM
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
mount /dev/cdrom /mnt
3.部署httpd
yum -y install httpd
echo "Web2" >/var/www/html/index.html
/etc/init.d/httpd start && chkconfig --level 35 httpd on
1.配置IP
vim /etc/sysconfig/network-scrips/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
cp /etc/sysconfig/network-scrips/ifcfg-eth0 /etc/sysconfig/network-scrips/ifcfg-eth1
vim /etc/sysconfig/network-scrips/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=dhcp
/etc/init.d/network restart
2.配置安装YUM
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
mount /dev/cdrom /mnt
yum -y install ipvsadm
modprobe ip_vs //加载lvs模块
lsmod | grep ip_vs //过滤查看是否加载lvs
3.开启路由转发
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1 //开启路由转发
sysctl -p
4.配置负载分配策略
/etc/init.d/ipvsadm stop //清除原LVS规则
ipvsadm -A -t 192.168.12.149:80 -s rr //指定192.168.12.149:80作为调度器,监听客户端请求
ipvsadm -a -t 192.168.12.149:80 -r 192.168.1.10:80 -m -w 1 //LVS使用NAT模式,将客户端192.168.1.10:80加入到调度器的Web集群中,权值设为1
ipvsadm -a -t 192.168.12.149:80 -r 192.168.1.20:80 -m -w 1 //LVS使用NAT模式,将客户端192.168.1.20:80加入到调度器的Web集群中,权值设为1
service ipvsadm save //保存LVS规则
详解:
-A:添加一条新的记录,记录调度器地址和端口
-a:添加一条新的记录,记录真实服务器(这里指Web服务器)地址和端口
-t:指明调度器提供的是tcp服务
-s:指定算法;常用选项(rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq)
-r:指定真实服务器(这里指Web服务器)的地址和端口
-m:指定LVS的工作模式为NAT模式;还有-i(指定工作模式为TUN隧道模式)、-g(指定工作模式为DR直接路由模式)
-w:指定真实服务器(这里指Web服务器)的权值,值越大越优先分配
ipvsadm -L -n //查看lvs规则
5.测试
1.网络参数配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-lo:0
/etc/sysconfig/network-scripts/ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.1.254
NETMASK=255.255.255.255
ONBOOT=yes
reboot
2.路由添加
route add -host 192.168.1.254 dev lo:0
echo "route add -host 192.168.1.254 dev lo:0" >>/etc/rc.local
3.内核参数配置
vim /etc/sysctl.conf
8 net.ipv4.conf.all.arp_ignore = 1 //定义对目标地址为本地IP的ARP询问不同的应答模式。不响应来自本地网卡的ARP请求
9 net.ipv4.conf.all.arp_announce = 2 //对查询目标使用最适当的本地地址。使用lo:0地址回应ARP请求
sysctl -p
4.YUM源配置并安装软件包
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
mount /dev/cdrom /mnt
yum -y install httpd && chkconfig --level 35 httpd on
5.测试页面准备
echo "Web1" >/var/www/html/index.html
6.启动服务
/etc/init.d/httpd start
1.网络参数配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.1.20
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-lo:0
/etc/sysconfig/network-scripts/ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.1.254
NETMASK=255.255.255.255
ONBOOT=yes
reboot
2.路由添加
route add -host 192.168.1.254 dev lo:0
echo "route add -host 192.168.1.254 dev lo:0" >>/etc/rc.local
3.内核参数配置
vim /etc/sysctl.conf
8 net.ipv4.conf.all.arp_ignore = 1
9 net.ipv4.conf.all.arp_announce = 2
sysctl -p
4.YUM源配置并安装软件包
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
mount /dev/cdrom /mnt
yum -y install httpd
5.测试页面准备
echo "Web2" >/var/www/html/index.html
6.启动服务
/etc/init.d/httpd start && chkconfig --level 35 httpd on
1.网络参数配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.1.254
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
reboot
2.YUM源配置并安装软件包
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
mount /dev/cdrom /mnt
yum -y install ipvsadm
modprobe ip_vs
echo "modprobe ip_vs" >>/etc/rc.local
lsmod | grep ip_vs
3.负载策略编写
/etc/init.d/iptables stop
/etc/init.d/ipvsadm stop
ipvsadm -A -t 192.168.1.254:80 -s rr
ipvsadm -a -t 192.168.1.254:80 -r 192.168.1.10:80 -g -w 1
ipvsadm -a -t 192.168.1.254:80 -r 192.168.1.20:80 -g -w 1
/etc/init.d/ipvsadm save && chkconfig --level 35 ipvsadm on
1.网络配置配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=dhcp
reboot
2.开启路由转发
vim /etc/sysctl.conf
7 net.ipv4.ip_forward = 1
sysctl -p
3.编写防火墙规则
/etc/init.d/iptables stop
iptables -t nat -I PREROUTING -d 192.168.10.139 -i eth1公网接口) -p tcp --dport 80 -j DNAT --to-destination 192.168.1.254:80
/etc/init.d/iptables save && chkconfig --level 35 iptables on
IE --> http://192.168.10.139
标签:var drbd 方式 linux内核 eth aide lin 结果 boot
原文地址:http://blog.51cto.com/13770206/2161273