tengine mysql_tengine负载均衡高可用配置

环境

Tengine-master:192.168.109.100

Tengine-slave:192.168.109.101

tomcat01:192.168.109.102

tomcat02:192.168.109.104

[Tengine部署]

# yum install -y gcc gcc-c++ make

#mkdir /opt/tengine-packages

#cd /opt/tengine-packages

# for tar in *.tar.gz;do tar xvf $tar;done

# cd /opt/tengine-packages/tengine-2.2.3

# ./configure --prefix=/opt/tengine --with-http_ssl_module --with-openssl=../openssl-1.1.1 --with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.11 --sbin-path=/opt/tengine/sbin/nginx --conf-path=/opt/tengine/conf/nginx.conf --pid-path=/opt/tengine/logs/nginx.pid

# make    #编译的时候出现这个错误不要慌张,

748969dc88ff8a21c6205a02eb60cf82.png

# vim ./objs/Makefile    #进入makefile编译makefile文件中将-lpthread修改为-pthread重新编译即可,如下图所示

0eac7ac785479bdbaac8e1d6a84b3e11.png

root@hostname-109102 tengine-2.2.3]#make

root@hostname-109102 tengine-2.2.3]#make install

[root@hostname-109101 conf]# ln -s /opt/tengine/sbin/nginx /usr/local/sbin/

worker_processes 1;

events {

worker_connections1024;

}

http {

include mime.types;

default_type application/octet-stream;

sendfile on;

keepalive_timeout65;

upstream tomcat_web {

server192.168.109.102:8080 weight=1 max_fails=2 fail_timeout=30s;

server192.168.109.104:8080 weight=1 max_fails=2 fail_timeout=30s;

}

server {

listen80;

server_name localhost;

location/{

root html;

index index.html index.htm;

proxy_next_upstream http_502 http_504 error timeout invalid_header;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://tomcat_web;

expires 3d;

}

error_page500 502 503 504 /50x.html;

location= /50x.html {

root html;

}

}

}

[root@hostname-109101 conf]# nginx -t

nginx: the configuration file /opt/tengine/conf/nginx.conf syntax is ok

nginx: configuration file /opt/tengine/conf/nginx.conf test is successful

[tomcat后端]

[root@tomcat-109103 ~]# mv /usr/src/jdk1.7.0_75/ /usr/local/java

[root@tomcat-109103 ~]# ln -s /usr/local/java/bin/*/usr/bin/

[root@tomcat-109103 ~]# vim /etc/profile.d/java.sh

export JAVA_HOME=/usr/local/java

export PATH=$PATH:$JAVA_HOME/bin

[root@tomcat-109103 ~]# source /etc/profile.d/java.sh

[root@tomcat-109103 ~]# java -version

java version "1.7.0_75"

Java(TM) SE Runtime Environment (build 1.7.0_75-b13)

Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

[root@tomcat-109103 ~]# cp -r apache-tomcat-7.0.65/ /usr/local/tomcat01

[root@tomcat-109103 ~]# cp -r apache-tomcat-7.0.65/ /usr/local/tomcat02

[root@hostname-109103 ~]# mkdir /www/{web01,web02}

[root@hostname-109103 ~]# vim /usr/local/tomcat01/conf/server.xml

[root@hostname-109103 ~]# vim /usr/local/tomcat02/conf/server.xml

[root@hostname-109102 ~]# cat /www/web01/index.jsp      #ps:这里是109.102机器的tomcat访问测试页面

JSP Test Page 11111

[root@hostname-109104 ~]# cat /www/web02/index.jsp       #ps:这里是109.104访问测试页面

JSP Test Page 22222

[keepalived]

yum install -y ipvsadm keepalived

! Configuration File for keepalived

global_defs {

notification_email {

acassen@firewall.loc

}

notification_email_from Alexandre.Cassen@firewall.loc

smtp_server 127.0.0.1

smtp_connect_timeout 30

router_id LVS_HOST

}

vrrp_instance VI_1 {

state MASTER/BACKUP

interface eth0

virtual_router_id 51

priority 100/50

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.109.188

}

}

virtual_server 192.168.109.188 8080 {

delay_loop 6

lb_algo rr

lb_kind DR

persistence_timeout 50

protocol TCP

real_server 192.168.109.102 8080 {

weight 1

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 8080

}

}

real_server 192.168.109.104 8080 {

weight 1

TCP_CHECK {

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

connect_port 8080

}

}

}

271e2f31f24587ef10ef488adc67f3b7.png

3cb3cdc556d79220e8614f09918e9634.png

e54f3731b9ca829ca7a5d239edcbb4cf.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值