單點登陸(cas)、緩存技術與負載均衡

提綱
動態緩存技術
集羣與負載均衡
網羅天下實現策略
關鍵技術
動態緩存
基於動態緩存的電子商務優化
針對電子商務網站的特色和性能要求,在Web服務器前端設置動態緩存服務器,做爲Web服務器的前置機,實現動態內容的緩存,加快了響應用戶訪問的速度;經過必定的替換和更新策略保證用戶訪問到最新的內容,對提升Web服務器峯值負載下的運行能力,減小訪問動態內容的延遲時間起到優化做用。
參考文獻: http://www.docin.com/p-152105671.html
《基於動態緩存的電子商務平臺優化研究》
集羣與負載均衡
welcome to use these PowerPoint templates, New Content design, 10 years experience
集羣 Cluster
概念:
一組獨立的計算機系統構成 一個鬆耦合的多處理器系統,他們之間經過網絡實現進程間的通訊。應用程序之間能夠經過網絡共享內存信息消息傳送。實現分佈式計算。
集羣與負載均衡
welcome to use these PowerPoint templates, New Content design, 10 years experience
負載均衡Load balance
概念:
網絡的負載均衡是一種動態均衡技術。基於現有的網絡結構,提供了一種擴展服務器帶寬和增長服務器吞吐量的廉價有效方法。提升了數據的處理能力、靈活性和可用性。
特色:
(1)高可靠性(HA)。利用集羣管理軟件,當主服務器故障時,備份服務器可以自動接管主服務器的工做,並及時切換過去,以實現對用戶的不間斷服務。 (2)高性能計算(HP)。即充分利用集羣中的每一臺計算機的資源,實現複雜運算的並行處理。 (3)負載平衡。即把負載壓力根據某種算法合理分配到集羣中的每一臺計算機上,以減輕主服務器的壓力,下降對主服務器的硬件和軟件要求。
網羅天下實施策略
整體網絡架構圖
Nginx代理RedisCluster Tomcat1Cluster Tomcat2Mysql MusterMysql SlaveFTP應用服務器集羣MysqlDB 主從緩存服務器5Web 服務器1PC1以太網2數據庫服務器1通訊鏈路1智能手機1雲1便攜電腦1平板電腦1防火牆1FTP 服務器.191代理服務器.14符號計數說明單位說明圖例Cluster Tomcat3Cluster Tomcat4
網羅天下實施策略 設計原理
Nginx:服務的代理與客戶端請求與分發。SSL證書的配置。80及443端口的監聽。
Redis:動態緩存服務器,Session共享。
Tomcat:Web應用服務器集羣。
JbossCache:單點登陸票據的共享。
關鍵技術
Nginx 安裝
安裝nginx,下載下面的插件安裝,不然nginx沒法識別tomcat中jvmRoute,從而沒法達到session複製的效果。
tar xzf nginx-upstream-jvm-route-0.1.tar.gz
tar xzf nginx-1.0.5.tar.gz
Nginx 配置
一、 nginx.conf中http{}中配置upstream wlotx {
ip_hash;
server 192.168.1.218:8080;#Tomcat1
server 192.168.1.219:8080; #Tomcat2
}
關鍵技術
Nginx 配置
二、 Server 80端口選段:
server {
listen 80;
server_name buseniss.wlotx.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
index index.html index.htm index.jsp;
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_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://wlotx;
}
關鍵技術
Nginx 配置
三、 HTTPS 443端口 Server 選段:
server {
listen 443;
server_name cas.wlotx.com;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
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_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://wlotx; } } 關鍵技術 Redis安裝及配置 daemonize yes pidfile /usr/local/redis/var/redis.pid port 6379 timeout 300 loglevel debug logfile /usr/local/redis/var/redis.log databases 16 save 900 1 save 300 10 save 60 10000 rdbcompression yes dbfilename dump.rdb dir /usr/local/redis/var/ appendonly no appendfsync always glueoutputbuf yes shareobjects no shareobjectspoolsize 1024 關鍵技術 Redis安裝及配置 將上面內容寫爲redis.conf並保存到/usr/local/redis/etc/目錄下。 而後在命令行執行: /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 便可在後臺啓動redis服務,這時經過 telnet 127.0.0.1 6379 可查看redis的服務狀態。 關鍵技術 JBossCacheTicketRegistry+組播 因爲單點登陸系統的特殊性,不能簡單使用session複製技術來實現多服務器間的登陸信息共享。 JBossCacheTicketRegistry提供了針對單點登陸系統集羣的共享策略。 在cas項目工程裏spring-configuration/ticketRegistry.xml文件裏面的DefaultTicketRegistry換成JBossCacheTicketRegistry緩存 ;在class文件裏添加jbossCache.xml文件添加jboss的緩存配置。 jbossCache.xml中依賴組播。 <attribute name="ClusterConfig"> <config> <UDP mcast_addr="224.0.0.8" mcast_port="48866" ip_ttl="32" ip_mcast="true" bind_addr="192.168.1.219" 關鍵技術 Tomcat Cluster 安裝 安裝tomcat tar zxf apache-tomcat-6.0.29.tar.gz mv apache-tomcat-6.0.29/usr/local/tomcat cp tomcat-replication.jar /usr/local/tomcat/lib 在另外一臺機器上安裝tomcat_2,步驟同1 分別在tomcat服務器安裝jdk chmod 755 jdk-6u26-linux-i586-rpm.bin ./jdk-6u26-linux-i586-rpm.bin cat >>/etc/profile <<EOF export JAVA_HOME=/usr/java/jdk1.6.0_26 export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin EOF; source /etc/profile //使環境變量當即生效 關鍵技術 Tomcat Cluster 配置1 <Connector port="8443" className="org.apache.coyote.http11.Http11Protocol" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="true" disableUploadTimeout="true" cceptCount="100" scheme="https" secure="true" SSLEnabled="true" clientAuth="false" keystoreFile="wlotx2012" keystorePass="wlotx2012" sslProtocol="TLS" truststorefile="%JAVA_HOME%/jre/lib/security/cacerts" truststoretype="JKS" truststorepass="changeit" /> 關鍵技術 Tomcat Cluster 配置2 <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1"> <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/> 注:標紅部分爲Nginx和TomcatSSL請求間的證書轉化。 關鍵技術 Tomcat Cluster 配置3 基於JBossCache的單點登陸系統Tomcat配置: <Host name="cas.wlotx.com" appBase="/data/www" unpackWARs="true" autoDeploy="false" deployOnStartup="false"> <Context path="" docBase="/data/www/cas" reloadable="true" distributable="true"> </Context> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="cas_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /> </Host> 關鍵技術 Tomcat Cluster 配置4 基於Redis session 共享的應用系統配置: <Host name="edu.wlotx.com" appBase="/data/www" unpackWARs="true" autoDeploy="false" distributable="true"> <Context path="" docBase="/data/www/teachmysql" reloadable="true" distributable="true"> <Valve className="com.radiadesign.catalina.session.RedisSessionHandlerValve" /> <Manager className=「com.radiadesign.catalina.session.RedisSessionManager」 host="192.168.1.218" port="6379" database="0" maxInactiveInterval="600" /> </Context> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="edu_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /> </Host> 關鍵技術 Nginx+Tomcat+SSL 實際上,大規模的網站都有不少臺Web服務器和應用服務器組成,用戶的請求多是經由 Varnish、HAProxy、Nginx以後纔到應用服務器,中間有好幾層。而中小規模的典型部署常見的是 Nginx+Tomcat 這種兩層配置,而Tomcat 會多於一臺,Nginx 做爲靜態文件處理和負載均衡。 若是Nginx做爲前端代理的話,則Tomcat根本不須要本身處理 https,全是Nginx處理的。用戶首先和Nginx創建鏈接,完成SSL握手,然後Nginx 做爲代理以 http 協議將請求轉給 tomcat 處理,Nginx再把 tomcat 的輸出經過SSL 加密發回給用戶,這中間是透明的,Tomcat只是在處理 http 請求而已。所以,這種狀況下不須要配置 Tomcat 的SSL,只須要配置 Nginx 的SSL 和 Proxy。
相關文章
相關標籤/搜索