Table of Contents
网站集群部署解决方案
Home Database Mysql Tutorial Apache+Tomcat+Memcached共享Session的构架设计

Apache+Tomcat+Memcached共享Session的构架设计

Jun 07, 2016 pm 04:30 PM
shared

网站集群部署解决方案 一、???????方案目标 实现互动留言系统、后台发布系统的高可用性,有效解决高并发量对单台应用服务器的冲击,确保应用服务器单点故障不影响系统正常运行。 二、???????部署架构 采取Tomcat集群的部署方式,Apache通过proxy_module代理

网站集群部署解决方案

一、???????方案目标

实现互动留言系统、后台发布系统的高可用性,有效解决高并发量对单台应用服务器的冲击,确保应用服务器单点故障不影响系统正常运行。

二、???????部署架构

采取Tomcat集群的部署方式,Apache通过proxy_module代理方式对用户的请求进行负载均衡,转发至tomcat集群中的某一实例进行处理,tomcat集群之间通过Memcached高性能缓存集群共享持久Session。具体结构如下图:


三、???????完整解决方案

1、????????各服务器所需安装软件列表:

序号

角色

IP地址

所需软件

1

Apache生产服务器

10.10.19.1

Apache HTTP Server2.2*( proxy_module、proxy_http_module\proxy_balancer_module\

proxy_ajp_module模块)

2

Tomcat互动留言服务器NO.1

10.10.19.2

Tomcat 7.0.*,TOMCAT_HOMT/lib下的jar包:

memcached-session-manager-x.y.z.jar, 下载地址

memcached-session-manager-tc7-x.y.z.jar,

(或memcached-session-manager-tc6-x.y.z.jar)

spymemcached-x.y.z.jar, 下载地址

kryo-1.04.jar、kryo-serializers-0.10.jar、asm-3.2.jar、minlog-1.2.jar、msm-kryo-serializer-1.6.3.jar、reflectasm-1.01.jar

(kryo-serializer:? msm-kryo-serializer,? kryo-serializers-0.10?(0.10 is needed, as 0.20+ is for kryo2),? kryo,? minlog,? reflectasm,? asm-3.2)

3

Tomcat互动留言服务器NO.1

10.10.19.3

同上

4

生产服务器NO.1

10.10.19.4

Apache HTTP Server 2.2*(预览站点时使用)

其他同上

5

生产服务器NO.2

10.10.19.5

除Apache HTTP Server 2.2*外,其他同上

6

Memcached缓存服务器NO.1

10.10.19.6

libevent-2.0.21-stable(安装memcached时需要)和memcached1.4.15

7

Memcached缓存服务器NO.2

10.10.19.7

同上

8

数据库服务器

10.10.18.3

SQL Server 2008 R2

2、????????安装步骤:

1)编译安装Apache2.2*,除网站必须使用的模块外,加入proxy_module、proxy_http_module\proxy_balancer_module\

proxy_ajp_module模块。按如下方式配置Apache对jsp页面的请求进行负载均衡:

l? 发布服务器:

LoadModule proxy_module modules/mod_proxy.so

?

LoadModule proxy_http_modulemodules/mod_proxy_http.so

?

LoadModule proxy_balancer_modulemodules/mod_proxy_balancer.so

?

LoadModuleproxy_ajp_module??modules/mod_proxy_ajp.so

???BalancerMember ajp://10.10.19.2:8009 route=jvm1

???BalancerMember ajp://10.10.19.3:8009 route=jvm2

ProxyPass/ balancer://cluster/ stickysession=JSESSIONID|jsessionid

l? 生产服务器NO.1:

LoadModule proxy_module modules/mod_proxy.so

?

LoadModule proxy_http_module modules/mod_proxy_http.so

?

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

?

LoadModule proxy_ajp_module??modules/mod_proxy_ajp.so

??? BalancerMember ajp://10.10.19.4:8009route=jvm3

??? BalancerMember ajp://10.10.19.5:8009route=jvm4

ProxyPass / balancer://cluster/ stickysession=JSESSIONID|jsessionid

2)编译安装Memcached

注意,安装Memcached需要首先安装libevent-2.0.21-stable

启动Memcached:

memcached -d -m 4096 -l localhost -p 11211-u root

给出memcached启动命令参数详解.

-d选项是启动一个守护进程,

-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,

-u是运行Memcache的用户,我这里是root,

-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,

-p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,

-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,

-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,

-p 使用的TCP端口。默认为11211

-m 最大内存大小。默认为64M

-vv 用very vrebose模式启动,调试信息和错误输出到控制台

-d 作为daemon在后台启动

3)安装Java环境和Tomcat7.*。

将下载完成的9个jar包放入 TOMCAT_HOME/lib文件夹下,并按如下修改Tomcat的配置文件TOMCAT_HOME/conf/context.xml:

l? Tomcat互动留言服务器NO.1:

???memcachedNodes="n1:10.10.19.6:11211,n2:10.10.19.7:11211"

/*此前安装的两个Memcached服务器的IP地址,Memcached默认端口号为11211*/

???failoverNodes="n1"

???requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"

???transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"

???/>

l? Tomcat互动留言服务器NO.2:

???memcachedNodes="n1:10.10.19.6:11211,n2:19.7:11211"

/*此前安装的两个Memcached服务器的IP地址,Memcached默认端口号为11211*/

???failoverNodes="n2"

???requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"

???transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"

???/>

l? 生产服务器NO.1:

???memcachedNodes="n1:10.10.19.6:11211,n2:19.7:11211"

/*此前安装的两个Memcached服务器的IP地址,Memcached默认端口号为11211*/

???failoverNodes="n1"

???requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"

???transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"

???/>

l? 生产服务器NO.2:

???memcachedNodes="n1:10.10.19.6:11211,n2:19.7:11211"

/*此前安装的两个Memcached服务器的IP地址,Memcached默认端口号为11211*/

???failoverNodes="n2"

???requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"

???transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"

???/>

?

参考文章

1、???????? https://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration

2、???????? http://www.bradchen.com/blog/2012/12/tomcat-auto-failover-using-apache-memcached

3、???????? http://blog.csdn.net/ichsonx/article/details/6911358

4、???????? http://www.linuxidc.com/Linux/2012-08/69312.htm

?


?

作者:xxfigo 发表于2013-5-21 17:01:06 原文链接

阅读:122 评论:0 查看评论

Apache+Tomcat+Memcached共享Session的构架设计

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to share wallpaperengine with friends How to share wallpaperengine with friends Mar 18, 2024 pm 10:00 PM

Users can share the wallpapers they obtain with friends when using WallpaperEngine. Many users do not know how to share WallpaperEngine with friends. They can save their favorite wallpapers locally and then share them with friends through social software. How to share wallpaperengine with friends Answer: Save it locally and share it with friends. 1. It is recommended that you save your favorite wallpapers locally and then share them with friends through social software. 2. You can also upload it to the computer through a folder, and then click Share using the creative workshop function on the computer. 3. Use Wallpaperengine on the computer, open the options bar of the creative workshop and find

How to share screen on WeChat Enterprise How to share screen on WeChat Enterprise Feb 28, 2024 pm 12:43 PM

More and more enterprises choose to use exclusive enterprise WeChat, which not only facilitates communication between enterprises and customers and partners, but also greatly improves work efficiency. Enterprise WeChat has rich functions, among which the screen sharing function is very popular. During the meeting, by sharing the screen, participants can display content more intuitively and collaborate more efficiently. So how to share your screen efficiently in WeChat Enterprise? For users who don’t know yet, this tutorial guide will give you a detailed introduction. I hope it can help you! How to share screen on WeChat Enterprise? 1. In the blue area on the left side of the main interface of Enterprise WeChat, you can see a list of functions. We find the "Conference" icon. After clicking to enter, three conference modes will appear.

Quick Share feature not working on Samsung phones – Fix Quick Share feature not working on Samsung phones – Fix Sep 19, 2023 pm 04:25 PM

Quick Share can save Samsung users a lot of time transferring files between devices. But Samsung Galaxy users have complained about facing issues with the Quick Share feature on their phones. Typically, visibility issues in quick sharing cause this issue. So, this is the only guide you need to troubleshoot the Quick Share feature on your Galaxy device. Fix 1 – Change Quick Share Visibility Settings Toggle the Quick Share visibility setting on your phone. Quick Share might be set to the wrong settings, causing this issue. Step 1 – First, swipe up once to open the app drawer. Step 2 – Once there, open Settings. Step 3 – Go to the Settings page and open the Connected Devices tab. Step 4 – Turn on the “Quick Share” feature. Step 5

Windows 11 Folder Sharing Guide: Easily Share Your Files and Data Windows 11 Folder Sharing Guide: Easily Share Your Files and Data Mar 13, 2024 am 11:49 AM

In daily life and work, we often need to share files and folders between different devices. Windows 11 system provides convenient built-in folder sharing functions, allowing us to easily and safely share the content we need with others within the same network while protecting the privacy of personal files. This feature makes file sharing simple and efficient without worrying about leaking private information. Through the folder sharing function of Windows 11 system, we can cooperate, communicate and collaborate more conveniently, improving work efficiency and life convenience. In order to successfully configure a shared folder, we first need to meet the following conditions: All devices (participating in sharing) are connected to the same network. Enable Network Discovery and configure sharing. Know the target device

How to use NameDrop on iPhone iOS 17 How to use NameDrop on iPhone iOS 17 Sep 22, 2023 pm 11:41 PM

With the launch of the new Apple iPhone15 series mobile phones and the launch of the latest iOS17 mobile operating system, a wealth of new features, adjustments and enhancements have been brought to Apple devices. Users may be wondering how to use the new NameDrop feature on iPhone and iOS17. This guide will provide a brief overview of how to share your contact information quickly and efficiently using the new NameDrop system available on iOS17. NameDrop is a feature that allows iPhone users to quickly share their contact information with others. It's a convenient tool for social events, business meetings or social gatherings where you need to exchange contact details with new friends. However, it's important to note that NameDrop only works for sending new contacts

Shared printer cannot connect to printer Shared printer cannot connect to printer Feb 22, 2024 pm 01:09 PM

With the development of the digital era, shared printers have become an indispensable part of the modern office environment. However, sometimes we may encounter the problem that the shared printer cannot be connected to the printer, which will not only affect work efficiency, but also cause a series of troubles. This article aims to explore the reasons and solutions for why a shared printer cannot connect to the printer. There are many reasons why a shared printer cannot connect to the printer, the most common of which is network issues. If the network connection between the shared printer and the printer is unstable or interrupted, normal operation will not be possible.

How to protect the privacy of contact photos and posters on iPhone How to protect the privacy of contact photos and posters on iPhone Sep 18, 2023 am 10:49 AM

Who can view your contact photos and posters on iPhone? Apple offers options for personalizing how you appear on someone's iPhone when they call or send a message. The options include Memoji, simple text, or a custom photo with effects as your contact photo and display image. You are free to change these selections at any time and switch between profiles on the contact card. Additionally, Apple is giving you the ability to control who can view and access photos or display images of your choice on iOS17. You can decide to share these with individuals saved in your contact list, or you can set your iPhone to prompt you every time you interact with a contact. If you wish, you can also disable the name permanently

How to send files and photos using AirDrop proximity sharing: What's new in iOS 17 How to send files and photos using AirDrop proximity sharing: What's new in iOS 17 Sep 16, 2023 am 10:17 AM

In iOS 17, Apple makes sharing files and media easier than ever, thanks to a cool new AirDrop proximity feature that does most of the work for you. In previous versions of iOS, transferring files or photos between Apple devices involved opening the relevant file, tapping the Share button, selecting AirDrop, and then selecting the nearby device to which you wanted to send the file. In iOS17 and iPadOS17, this process still exists for sharing between Apple devices, but if you're transferring between iPhones or iPads, you can use AirDrop's new proximity sensing feature to eliminate some of the typical sharing steps. To initiate a transfer, select the

See all articles