码迷,mamicode.com
首页 > 其他好文 > 详细

LVS部署之YUM安装

时间:2016-10-31 18:43:55      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:default   class   format   lte   disable   root   shmall   tcp   print   

LVS NAT模式

  • 准备工作

4台机器、一台Director server、两台Real server (web01、web02)、一台windows 7客户机

Director 有两块网卡:eth0:192.168.119.132(内网)

           eth1:192.168.94.130 (外网)

web01网卡IP:192.168.119.134(内网)

web02网卡IP:192.168.119.134(内网)

  • 安装软件

director 安装ipvsadm

[root@lvs /]# yum -y install ipvsadm

 

给Director 添加一块网卡eth1

[root@lvs /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config (关闭selinux重启生效)
[root@lvs /]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@lvs /]# dmesg | grep -in eth
1583:e1000 0000:02:01.0: eth0: (PCI:66MHz:32-bit) 00:0c:29:21:bc:27
1584:e1000 0000:02:01.0: eth0: Intel(R) PRO/1000 Network Connection
1587:e1000 0000:02:05.0: eth1: (PCI:66MHz:32-bit) 00:0c:29:21:bc:31
1588:e1000 0000:02:05.0: eth1: Intel(R) PRO/1000 Network Connection
1610:e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
1611:eth0: no IPv6 routers present
[root@lvs /]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
[root@lvs /]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=00:0C:29:21:BC:31
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
[root@lvs /]# /etc/init.d/network reload
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  
Determining IP information for eth0... done.
                                                           [  OK  ]
Bringing up interface eth1:  
Determining IP information for eth1... done.
                                                           [  OK  ]

[root@lvs /]# ifconfig eth1 | awk -F [:B]+ NR==2 {printf $2}
192.168.94.130

 

两台Real server 安装httpd或nginx

[root@web01 /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config 
[root@web01 /]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@web01 /]# yum -y install httpd
[root@web01 /]# vim /etc/httpd/conf/httpd.conf 
[root@web01 /]# 
[root@web01 /]# echo "web01" > /var/www/html/index.html
[root@web01 /]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[root@web01 /]# curl 192.168.119.134
web01

[root@web02 /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
[root@web02 /]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@web02 /]# yum -y install httpd
[root@web02 /]# vim /etc/httpd/conf/httpd.conf 
[root@web02 /]# echo "web02" > /var/www/html/index.html
[root@web02 /]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[root@web02 /]# curl 192.168.119.135
web02
  •  Director配置NAT
[root@lvs /]# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
[root@lvs /]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296

 

LVS部署之YUM安装

标签:default   class   format   lte   disable   root   shmall   tcp   print   

原文地址:http://www.cnblogs.com/zzzhfo/p/6016754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!