企业Web高可用集群实战之LVS+Keepalived+MySQL HA

前端用两台server做lvs+keepalived负载调度器,中间用apache+php作为web应用服务器,后端用两台做MySQL高可用,用nfs、mfs或作为web文件共享服务器

 

系统环境:

LVS调度主服务器:192.168.8.11

LVS调度从服务器:192.168.8.12

LVS VIP:192.168.8.10

apache服务器:192.168.8.20  192.168.8.21

MySQL主服务器:192.168.8.31

MySQL从服务器:192.168.8.32

MySQL VIP:192.168.8.30

 

 

由于工作时间比较紧,同时还要培训,架构图后期补上!!

 

用到软件准备:

所有服务器软件包都放在/opt 目录下,下面是下载地址:

wget http://www.keepalived.org/software/keepalived-1.1.20.tar.gz wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.24-linux2.6-x86_64.tar.gz  #64位 wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.24-linux2.6-i686.tar.gz    #32位 

一、LVS+Keepalived

1.安装ipvsadm

yum -y install ipvsadm kernel-devel

ln -sv /usr/src/kernels/2.6.18-308.8.2.el5-x86_64/ /usr/src/linux

 

2.安装keepalived

cd /opt/ tar zxf keepalived-1.1.20.tar.gz cd keepalived-1.1.20 ./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.18-308.11.1.el5-x86_64/  出现如下信息内核加载成功: Keepalived configuration ------------------------ Keepalived version       : 1.1.20 Compiler                 : gcc Compiler flags           : -g -O2 Extra Lib                : -lpopt -lssl -lcrypto  Use IPVS Framework       : Yes IPVS sync daemon support : Yes Use VRRP Framework       : Yes Use Debug flags          : No make;make install cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/ mkdir /etc/keepalived chkconfig keepalived on 

3.创建配置文件

cat /etc/keepalived/keepalived.conf  ! Configuration File for keepalived   global_defs {    notification_email {       250621008@qq.com    }    notification_email_from 250621008@qq.com    smtp_server smtp.163.com   #smtp_connect_timeout 30    router_id LVS_DEVEL  vrrp_instance VI_1 {     state MASTER             #备份服务器上将MASTER改为BACKUP        interface eth0     lvs_sync_daemon_inteface eth0     virtual_router_id 51     priority 100        #备份服务上将100改为低于100的数值     advert_int 5     authentication {         auth_type PASS         auth_pass 1111     }     virtual_ipaddress {         192.168.8.10     }   virtual_server 192.168.8.10 80 {     delay_loop 6                  #(每隔10秒查询realserver状态)     lb_algo wlc                   #(lvs 算法)     lb_kind DR                    #(Direct Route)     persistence_timeout 60        #(同一IP的连接60秒内被分配到同一台realserver)     protocol TCP                  #(用TCP协议检查realserver状态)       real_server 192.168.8.11 80 {         weight 100                #(权重)         TCP_CHECK {         connect_timeout 10        #(10秒无响应超时)         nb_get_retry 3         delay_before_retry 3         connect_port 80         }     }     real_server 192.168.8.12 80 {         weight 100         TCP_CHECK {         connect_timeout 10         nb_get_retry 3         delay_before_retry 3         connect_port 80         }      } 

PS :从配置文件参考以上主的配置文件,不同的地方是红色标注两处!

 

二、WEB集群

1、这里可以选择lamp、lnmp、lanmp等web架构,至于搭建略!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/d97f8152a936bfc51c890875a49d8fdc.html