最近对负载均衡进行搭建具体方法如下:

  • haproxy 修改部分(haproxy-cfg.cfg)
global
daemon
maxconn 4500
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 180000ms
stats enable
stats uri /stats
stats auth admin:age!^*
frontend http-in
bind *:<span style="color: #ff0000;"><strong>9090</strong></span>
default_backend dynamic_servers
backend dynamic_servers
mode http
option httpclose
option forwardfor header X-Forwarded-For
appsession JSESSIONID len 52 timeout 30m
balance roundrobin
server server_9091 191.29.70.6:9091 maxconn 250
server server_9092 191.29.70.6:9092 maxconn 250
server server_9093 191.29.70.6:9093 maxconn 250
server server_9094 191.29.70.6:9094 maxconn 250
server server_9095 191.29.70.6:9095 maxconn 250

使用haproxy做端口转发,只需要修改tomcat的 到不同的端口(保证端口不被占用)

在haproxy映射即可。

启动方法 ./haproxy -f haproxy-cfg.cfg

haproxy 有编译好的版本,也可以自行编译参考方法

http://wenku.baidu.com/view/0a7a28154431b90d6c85c760.html

tomcat示例

<!-- Note:  A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server <strong><span style="color: #ff0000;">port="9005"</span></strong> shutdown="SHUTDOWN"> <!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
--> <!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector <span style="color: #ff0000;"><strong>port="9091"</strong></span> protocol="HTTP/1.1"
connectionTimeout="100000"
redirectPort="8443" URIEncoding="gbk"/>
<!-- A "Connector" using the shared thread pool-->
<!-- <Connector executor="tomcatThreadPool"
port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
.....

haproxy简单负载均衡搭建的更多相关文章

  1. 基于 Haproxy 构建负载均衡集群

    1.HAPROXY简介 HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种负载均衡解决方案.HAProxy特别适用于那些负载特大的web ...

  2. Haproxy 构建负载均衡集群

    1.HAPROXY简介 HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种负载均衡解决方案.HAProxy特别适用于那些负载特大的web ...

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

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

  4. 05.haproxy+mysql负载均衡 整合 redis集群+ssm

    本篇重点讲解haproxy+mysql负载均衡,搭建完成后与之前搭建的redis+ssm进行整合 (注:这里用到了两台mysql数据库,分别安装两台虚拟机上,已经成功实现主主复制,如果有需要,请查看我 ...

  5. Haproxy+Keepalived负载均衡

    Haproxy介绍 HAProxy是一个特别适用于高可用性环境的TCP/HTTP开源的反向代理和负载均衡软件.在7层负载均衡方面的功能很强大(支持cookie track, header rewrit ...

  6. 使用Nginx负载均衡搭建高性能.NETweb应用程序(转)

    一.遇到的问题 当我们用IIS服务器部署了一个web应用以后,当很多用户高并发访问的时候,客户端响应就会很慢,客户的体验就会很差,由于IIS接受到客户端请求的时候,就会创建一个线程,当线程达到几千个时 ...

  7. Nginx,Haproxy/lvs负载均衡的优缺点分析

    PS:Nginx/LVS/HAProxy是目前使用最广泛的三种负载均衡软件,本人都在多个项目中实施过,参考了一些资料,结合自己的一些使用经验,总结一下. 一般对负载均衡的使用是随着网站规模的提升根据不 ...

  8. 使用Nginx负载均衡搭建高性能.NETweb应用程序二

    在文章<使用Nginx负载均衡搭建高性能.NETweb应用程序一>中,让我们对Nginx有了一个初步认识,下面我们将在windows平台下面使用Nginx演示集群部署我们的web应用. 一 ...

  9. HAProxy 的负载均衡服务器,Redis 的缓存服务器

    问答社区网络 StackExchange 由 100 多个网站构成,其中包括了 Alexa 排名第 54 的 StackOverflow.StackExchang 有 400 万用户,每月 5.6 亿 ...

随机推荐

  1. bzoj4033

    http://www.lydsy.com/JudgeOnline/problem.php?id=4033 树形DP. 我们发现,每条边都是一条桥,若我们知道这条边其中一侧有多少个黑点,我们就可以知道这 ...

  2. TCP头分析+面试题

    一.测试程序 我们先用python来写两个测试脚本,非常简单,看代码: 服务端: from socket import * def accept(): sock = socket(AF_INET, S ...

  3. maven编写主代码与测试代码

    3.2 编写主代码 项目主代码和测试代码不同,项目的主代码会被打包到最终的构件中(比如jar),而测试代码只在运行测试时用到,不会被打包.默认情况下,Maven假设项目主代码位于src/main/ja ...

  4. HDU 2689 sort it - from lanshui_Yang

    Problem Description You want to processe a sequence of n distinct integers by swapping two adjacent ...

  5. Servlet登陆功能的实现

    (1)创建动态的Login页面 //登陆界面 package com.lc; import javax.servlet.http.*; import java.io.*; public class L ...

  6. VC中遍历目标进程中的模块

    VC中遍历目标进程中的模块 MFC代码win32 也可以用 在下面代码进行修改转换就可以了CString strModule; 可以换成 char* 但是MODULEENTRY32结构中的szModu ...

  7. lightoj 1236 正整数唯一分解定理

    A - (例题)整数分解 Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB     6 ...

  8. sql 用openxml 将xml转换为数据表Table

    CREATE PROCEDURE up_OpenXml ( @xml XML ) AS BEGIN DECLARE @Pointer INT EXECUTE sp_xml_preparedocumen ...

  9. MYSQL 磁盘临时表和文件排序

    因为Memory引擎不支持BOLB和TEXT类型,所以,如果查询使用了BLOB或TEXT列并且需要使用隐式临时表,将不得不使用MyISAM磁盘临时表,即使只有几行数据也是如此. 这会导致严重的性能开销 ...

  10. Injector Job深入分析

    Injector Job的主要功能是根据crawlId在hbase中创建一个表,将将文本中的seed注入表中. (一)命令执行 1.运行命令 [jediael@master local]$ bin/n ...