网站集群部署解决方案 一、???????方案目标 实现互动留言系统、后台发布系统的高可用性,有效解决高并发量对单台应用服务器的冲击,确保应用服务器单点故障不影响系统正常运行。 二、???????部署架构 采取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的构架设计, 感谢原作者分享。

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

SQL commands in MySQL can be divided into categories such as DDL, DML, DQL, DCL, etc., and are used to create, modify, delete databases and tables, insert, update, delete data, and perform complex query operations. 1. Basic usage includes CREATETABLE creation table, INSERTINTO insert data, and SELECT query data. 2. Advanced usage involves JOIN for table joins, subqueries and GROUPBY for data aggregation. 3. Common errors such as syntax errors, data type mismatch and permission problems can be debugged through syntax checking, data type conversion and permission management. 4. Performance optimization suggestions include using indexes, avoiding full table scanning, optimizing JOIN operations and using transactions to ensure data consistency.

InnoDB achieves atomicity through undolog, consistency and isolation through locking mechanism and MVCC, and persistence through redolog. 1) Atomicity: Use undolog to record the original data to ensure that the transaction can be rolled back. 2) Consistency: Ensure the data consistency through row-level locking and MVCC. 3) Isolation: Supports multiple isolation levels, and REPEATABLEREAD is used by default. 4) Persistence: Use redolog to record modifications to ensure that data is saved for a long time.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function