linux集群实施与部署-----Nginx

 

 ( 1 ) 配置基本环境

//安装虚拟工具
#cd /media/VMware\ Tools/
#cp VMwareTools-10.0.6-3595377.tar.gz/tmp/  
#cd /tmp/
#tar-xvzf VMwareTools-10.0.6-3595377.tar.gz
#cd vmware-tools-distrib/
#./vmware-install.pl

 停止和关闭NetworkManager服务:#service NetworkManager status

#service NetworkManager stop
#chkconfig--level 2345 NetworkManager off
临时关闭SELinux: #setenforce 0
永久关闭SELinux: #vi /etc/selinux/config     //7 SELINUX=disabled 
#iptables -F                    //清除防火墙规则
#service iptables save

修改主机名

#vi /etc/hosts
1  127.0.0.1   localhost node1 node1.edu.cn
2  ::1            localhost node1 node1.edu.cn
#vi /etc/sysconfig/network

2  HOSTNAME=node1.edu.cn

配置本地YUM源

#cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.ba #vi /etc/yum.repos.d/CentOS-Base.repo
                     1  [dvd]
                     2  name=install dvd
                     3  baseurl=file:///media/Centos_6.5_Final
                     4  enable=1
                     5  gpgcheck=1
                     6  pgpkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
          
#yum clean all
#yum makecache

(2)配置各服务器的网络(Real1、Real2同类)

[root@real1  桌面]#setup
[root@real1  桌面]#vi /etc/sysconfig/network-scripts/ifcfg-eth0  //ONBOOT=yes
[root@real1  桌面]#service network restart

 ( 3 )LVS配置IP地址,添加VIP:

ifconfig eth0:0 192.168.0.100 broadcast 192.168.0.255 netmask 255.255.255.0 up

( 4 )LVS设置负载均衡条目:

#yum install ipvsadm -y
#internet protocol virtual server admin 互联网协议虚拟服务器管理器
#ipvsadm -A -t 192.168.1.100:80 -s rr (-A 添加 virtual server)
#ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.12:80 -g
#ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.13:80 -g

( 5 )LVS使配置永久生效

#ipvsadm -save>/etc/sysconfig/ipvsadm
#systemctl enable ipvsadm

( 6 )设置web服务器

给两个web服务器上配置web服务:

#echo "this is real 2222"> /var/www/html/index.html
#server httpd给两个web服务器的lo网卡配置子网掩码为32位的VIP:
rs1:#ifconfig lo:0 192.168.0.123/32
rs2:#ifconfig lo:0 192.168.0.123/32

给两个web服务器设置内核参数(rs1\rs2)

#echo 1>/proc/sysconfig/network/ipv4/config/all/arp_igonre  //忽略ARP响应,不允许收
#echo 2>/proc/sysconfig/network/ipv4/config/all/arp_announce  //让ARP发包出去,不允许发

(7)客户端测试 (ctrl+F5)

#curl http://192.168.0.100

 

posted @ 2019-06-30 00:23  Block翊树  阅读(678)  评论(0编辑  收藏  举报