环境

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    #编译的时候出现这个错误不要慌张,

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

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  ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
upstream tomcat_web {
server 192.168.109.102: weight= max_fails= fail_timeout=30s;
server 192.168.109.104: weight= max_fails= fail_timeout=30s;
}
server {
listen ;
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_page /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- ~]# mv /usr/src/jdk1..0_75/ /usr/local/java
[root@tomcat- ~]# 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
<Context path="/" docBase="/www/web01" reloadable="true"/>
[root@hostname-109103 ~]# vim /usr/local/tomcat02/conf/server.xml
     <Context path="/" docBase="/www/web02"  reloadable="true"/>

[root@hostname-109102 ~]# cat /www/web01/index.jsp      #ps:这里是109.102机器的tomcat访问测试页面
<html>
<body>
<h1>JSP Test Page 11111</h1>
<%=new java.util.Date()%>
</body>
</html>

[root@hostname-109104 ~]# cat /www/web02/index.jsp       #ps:这里是109.104访问测试页面
<html>
<body>
<h1>JSP Test Page 22222</h1>
<%=new java.util.Date()%>
</body>
</html>


[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
}
}
}

  

tengine负载均衡高可用配置的更多相关文章

  1. Nginx+keepalived实现负载均衡高可用配置

    1. 什么是负载均衡高可用 nginx作为负载均衡器,所有请求都到了nginx,可见nginx处于非常重点的位置,如果nginx服务器宕机后端web服务将无法提供服务,影响严重. 为了屏蔽负载均衡服务 ...

  2. nginx负载均衡高可用部署和代理配置

    nginx负载均衡高可用配置 服务器A:172.16.100.2 服务器B:172.16.100.3 首先先在两台服务器上分别安装好nginx和keepalived后,再进行下面的操作 配置keepa ...

  3. linux系统下对网站实施负载均衡+高可用集群需要考虑的几点

    随着linux系统的成熟和广泛普及,linux运维技术越来越受到企业的关注和追捧.在一些中小企业,尤其是牵涉到电子商务和电子广告类的网站,通常会要求作负载均衡和高可用的Linux集群方案. 那么如何实 ...

  4. 实现基于Haproxy+Keepalived负载均衡高可用架构

    1.项目介绍: 上上期我们实现了keepalived主从高可用集群网站架构,随着公司业务的发展,公司负载均衡服务已经实现四层负载均衡,但业务的复杂程度提升,公司要求把mobile手机站点作为单独的服务 ...

  5. Lvs+keepAlived实现负载均衡高可用集群(DR实现)

    第1章 LVS 简介 1.1 LVS介绍 LVS是Linux Virtual Server的简写,意为Linux虚拟服务器,是虚拟的服务器集群系统,可在UNIX/LINUX平台下实现负载均衡集群功能. ...

  6. Nginx+Keepalived负载均衡高可用

    Nginx+Keepalived负载均衡高可用方案: Nginx 使用平台:unix.linux.windows. 功能: A.www web服务  http 80 b.负载均衡(方向代理proxy) ...

  7. Linux下"负载均衡+高可用"集群的考虑点 以及 高可用方案说明(Keepalive/Heartbeat)

    当下Linux运维技术越来越受到企业的关注和追捧, 在某些企业, 尤其是牵涉到电子商务和电子广告类的网站,通常会要求作负载均衡和高可用的Linux集群方案.那么如何实施Llinux集群架构,才能既有效 ...

  8. JAVAEE——宜立方商城03:Nginx负载均衡高可用、Keepalived+Nginx实现主备

    1 nginx负载均衡高可用 1.1 什么是负载均衡高可用 nginx作为负载均衡器,所有请求都到了nginx,可见nginx处于非常重点的位置,如果nginx服务器宕机后端web服务将无法提供服务, ...

  9. Nginx负载均衡高可用

    1.   Nginx负载均衡高可用 首先介绍一下Keepalived,它是一个高性能的服务器高可用或热备解决方案,Keepalived主要来防止服务器单点故障的发生问题,可以通过其与Nginx的配合实 ...

随机推荐

  1. SP375 QTREE - Query on a tree (树剖)

    题目 SP375 QTREE - Query on a tree 解析 也就是个蓝题,因为比较长 树剖裸题(基本上),单点修改,链上查询. 顺便来说一下链上操作时如何将边上的操作转化为点上的操作: 可 ...

  2. Java自学-数组 初始化数组

    Java 如何初始化数组 步骤 1 : 分配空间与赋值分步进行 public class HelloWorld { public static void main(String[] args) { i ...

  3. kubernetes--配置文件

  4. springmvc框架helloword

    spring框架提供了构建web的应用程序的全功能MVC模块-spring mvc.我们首先来写一个springmvc的hellword的配置文件的形式 工程结构如下 index.jsp <%@ ...

  5. 【转载】C#中List集合使用Contains方法判断是否包含某个对象

    在C#的List集合中,如果要查找List集合是否包含某一个值或者对象,如果不使用List集合类的扩展方法的话一般会使用for循环或者foreach遍历来查找,其实List集合类中的扩展方法Conta ...

  6. js基础闭包练习题

    题目描述 实现函数 makeClosures,调用之后满足如下条件:1.返回一个函数数组 result,长度与 arr 相同2.运行 result 中第 i 个函数,即 result[i](),结果与 ...

  7. nodeJS从入门到进阶二(网络部分)

    一.网络服务器 1.http状态码 1xx: 表示普通请求,没有特殊含义 2xx:请求成功 200:请求成功 3xx:表示重定向 301 永久重定向 302 临时重定向 303 使用缓存(服务器没有更 ...

  8. 安装nginx + nginx-gridfs + mongodb

    1.安装依赖包 yum -y install pcre-devel openssl-devel zlib-devel git gcc gcc-c++ git clone https://github. ...

  9. AIX安装单实例11gR2 GRID+DB

    AIX安装单实例11gR2 GRID+DB   一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以 ...

  10. js的insertRow和insertCell用法

    js的insertRow(-1)和insertCell(-1) 增加最后一行和增加最后一列 js的insertRow(5)和insertCell(5) 第5行后增加一行和增加第5列后增加一列