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

# 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负载均衡高可用配置的更多相关文章
- Nginx+keepalived实现负载均衡高可用配置
1. 什么是负载均衡高可用 nginx作为负载均衡器,所有请求都到了nginx,可见nginx处于非常重点的位置,如果nginx服务器宕机后端web服务将无法提供服务,影响严重. 为了屏蔽负载均衡服务 ...
- nginx负载均衡高可用部署和代理配置
nginx负载均衡高可用配置 服务器A:172.16.100.2 服务器B:172.16.100.3 首先先在两台服务器上分别安装好nginx和keepalived后,再进行下面的操作 配置keepa ...
- linux系统下对网站实施负载均衡+高可用集群需要考虑的几点
随着linux系统的成熟和广泛普及,linux运维技术越来越受到企业的关注和追捧.在一些中小企业,尤其是牵涉到电子商务和电子广告类的网站,通常会要求作负载均衡和高可用的Linux集群方案. 那么如何实 ...
- 实现基于Haproxy+Keepalived负载均衡高可用架构
1.项目介绍: 上上期我们实现了keepalived主从高可用集群网站架构,随着公司业务的发展,公司负载均衡服务已经实现四层负载均衡,但业务的复杂程度提升,公司要求把mobile手机站点作为单独的服务 ...
- Lvs+keepAlived实现负载均衡高可用集群(DR实现)
第1章 LVS 简介 1.1 LVS介绍 LVS是Linux Virtual Server的简写,意为Linux虚拟服务器,是虚拟的服务器集群系统,可在UNIX/LINUX平台下实现负载均衡集群功能. ...
- Nginx+Keepalived负载均衡高可用
Nginx+Keepalived负载均衡高可用方案: Nginx 使用平台:unix.linux.windows. 功能: A.www web服务 http 80 b.负载均衡(方向代理proxy) ...
- Linux下"负载均衡+高可用"集群的考虑点 以及 高可用方案说明(Keepalive/Heartbeat)
当下Linux运维技术越来越受到企业的关注和追捧, 在某些企业, 尤其是牵涉到电子商务和电子广告类的网站,通常会要求作负载均衡和高可用的Linux集群方案.那么如何实施Llinux集群架构,才能既有效 ...
- JAVAEE——宜立方商城03:Nginx负载均衡高可用、Keepalived+Nginx实现主备
1 nginx负载均衡高可用 1.1 什么是负载均衡高可用 nginx作为负载均衡器,所有请求都到了nginx,可见nginx处于非常重点的位置,如果nginx服务器宕机后端web服务将无法提供服务, ...
- Nginx负载均衡高可用
1. Nginx负载均衡高可用 首先介绍一下Keepalived,它是一个高性能的服务器高可用或热备解决方案,Keepalived主要来防止服务器单点故障的发生问题,可以通过其与Nginx的配合实 ...
随机推荐
- dump net core lldb 分析
原文https://www.cnblogs.com/calvinK/p/9274239.html centos7 lldb 调试netcore应用的内存泄漏和死循环示例(dump文件调试) 写个dem ...
- Spring Security 解析(二) —— 认证过程
Spring Security 解析(二) -- 认证过程 在学习Spring Cloud 时,遇到了授权服务oauth 相关内容时,总是一知半解,因此决定先把Spring Security .S ...
- Python进阶(八)----模块,import , from import 和 `__name__`的使用
Python进阶(八)----模块,import , from import 和 __name__的使用 一丶模块的初识 #### 什么是模块: # 模块就是一个py文件(这个模块存放很多相似的功能, ...
- 你需要知道的 5 个 Linux 新手会犯的失误
Linux 爱好者们分享了他们犯下的一些最大错误. 终身学习是明智的 —— 它可以让你的思维敏捷,让你在就业市场上更具竞争力.但是有些技能比其他技能更难学,尤其是那些小菜鸟错误,当你尝试修复它们时可能 ...
- aria2 cmd set chmod, and others..
import 'package:flutter/material.dart'; import 'dart:io'; import 'dart:async'; import 'package:rxdar ...
- Spring AOP无法拦截Controller的原因
因为Spring的Bean扫描和Spring-MVC的Bean扫描是分开的, 两者的Bean位于两个不同的Application, 而且Spring-MVC的Bean扫描要早于Spring的Bean扫 ...
- 83.基于Vue SEO的四种方案(小结)
前言:众所周知,Vue SPA单页面应用对SEO不友好,当然也有相应的解决方案,下面列出几种最近研究和使用过的SEO方案,SRR和静态化基于Nuxt来说. 1.SSR服务器渲染:2.静态化:3.预渲染 ...
- Building Objective-C static libraries with categories
Q: How do I fix "selector not recognized" runtime exceptions when trying to use category m ...
- MongoDB 设置参数
服务器配置文件分析 bin目录下的mongod.cfg是服务器的配置文件,文件中主要的配置参数: 1.数据库文件的存放位置 2.服务器日志文件的存放位置 3.默认的IP地址.端口号 设置密码 默认情况 ...
- day 03 作业 预科
目录 作业 1.简述变量的组成 2.简述变量名的命名规范 3.简述注释的作用 4.使用turtle库构造一幅图,贴在markdown文档中 作业 1.简述变量的组成 变量由变量名.赋值符号.变量值所组 ...