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的配合实 ...
随机推荐
- 获取本机的IP地址和mac地址
1. 以前一直用ipconfig来查看ip地址,哈哈哈,现在发现挺好玩 #获取本机的IP地址和mac地址 import uuid import socket def get_mac_address() ...
- Python进阶(八)----模块,import , from import 和 `__name__`的使用
Python进阶(八)----模块,import , from import 和 __name__的使用 一丶模块的初识 #### 什么是模块: # 模块就是一个py文件(这个模块存放很多相似的功能, ...
- Vue-webpack-hbuilderx 开发前端基本命令
--创建Vue 项目 pc 需要装 node 环境 ,安装完之后,就可以在cmd中使用npm 命令了 1:npm install -g vue-cli //电脑端需要安装vue 脚手架模板,电脑端一 ...
- 你忘记过VM密码吗?
翻出N年前的VM主机,但是忘记密码时如何处理?总不能扔吧....常见的方法有哪些?1.重装一个VM(但是里面数据就没了)2.做一个PE进去重置密码(如何身边没有PE怎么样)3.用我们的办法... 还记 ...
- Android数据库GreenDao配置版本问题
感谢该贴解决我多天的困惑:https://blog.csdn.net/u013472738/article/details/72895747 主要是降低了GreenDao版本 网上很多教程说的版本都是 ...
- nginx反向代理前后端分离项目(后端多台)
目前软件架构都比较流行前后端分离,前后端的分离也实现了前后端架构的分离,带来的好处 —— 整个项目的开发权重往前移,实现真正的前后端解耦,动态资源和静态资源分离,提高了性能和扩展性. 通常Spring ...
- JMeter性能测试,入门
原文转自:https://blog.csdn.net/lovesoo/article/details/78579547 Apache JMeter是一款纯java编写负载功能测试和性能测试开源工具软件 ...
- python连接mysql服务端
python连接mysql的客户端 import pymysql # 导入模块 conn = pymysql.connect( host='127.0.0.1', # 主机模块 port=3306, ...
- NFS服务启动:rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
nfs重启时提示: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused) 解决办法: 1 #service rpc ...
- 瑞克和莫蒂|S3E03 Rick为什么要把自己变成一根腌黄瓜?
给尚未入坑Rick and Morty的小伙伴们为一点背景知识 S3E1在说什么? rick从监狱里回来,顺手搞垮了统治地球的银河联邦政府.Jerry因此丢了工作,非常不高兴.于是向Beth质问 ...