fun

           

          2009年5月8日

          大規(guī)模網(wǎng)站架構(gòu)ppt

          為公司講解的一個(gè)PPT,相關(guān)內(nèi)容如下:

           

           http://www.bt285.cn BT下載 有300W部BT種子.
          http://www.5a520.cn 小說(shuō)520網(wǎng) 有300W部小說(shuō)

          CAP原則
          BASE策略
          異步(MessageQueue)
          數(shù)據(jù)庫(kù)
             數(shù)據(jù)的水平切分及垂直切分
              數(shù)據(jù)庫(kù)讀寫分離
              避免分布式事務(wù)
              反范式的數(shù)據(jù)庫(kù)設(shè)計(jì)
          負(fù)載均衡
              DNS負(fù)載均衡
              反向代理負(fù)載均衡
               LVS
          緩存
              數(shù)據(jù)庫(kù)緩存
               服務(wù)器緩存/頁(yè)面緩存/數(shù)據(jù)緩存/靜態(tài)化
              反向代理緩存

          HA
          Session

          Share Nothing Architecture架構(gòu)
          瀏覽器優(yōu)化
              瀏覽器緩存/CDN/小圖片合并
          分布式文件系統(tǒng)(MogileFS)

          下載地址為:http://www.bt285.cn/soft/res.ppt

           

          posted @ 2009-11-06 19:44 fun 閱讀(2556) | 評(píng)論 (3)編輯 收藏

          Tomcat配置成https方式訪問(wèn)(用單向認(rèn)證)

          在命令提示符窗口,進(jìn)入Tomcat目錄,執(zhí)行以下命令:
          keytool -genkey -alias tomcat -keyalg RSA -keypass changeit -storepass changeit -keystore server.keystore -validity 3600
          通過(guò)以上步驟生成server.keystore證書文件、

          將servlet.xml一下的的注釋打開(最好拷貝此段)
          <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->  
          <Connector protocol="org.apache.coyote.http11.Http11Protocol"    
                               port="8443" maxHttpHeaderSize="8192"  
                     maxThreads="150" minSpareThreads="25" maxSpareThreads="75"  
                     enableLookups="false" disableUploadTimeout="true"  
                     acceptCount="100" scheme="https" secure="true"  
                     clientAuth="false" sslProtocol="TLS"                   
                     keystoreFile="server.keystore"    
                     keystorePass="changeit"/> 
          到這一步訪問(wèn)https;//ip:8443/item

          一般Tomcat默認(rèn)的SSL端口號(hào)是8443,但是對(duì)于SSL標(biāo)準(zhǔn)端口號(hào)是443,這樣在訪問(wèn)網(wǎng)頁(yè)的時(shí)候,直接使用https而不需要輸入端口號(hào)就可以訪問(wèn),如http://www.bt285.cn
          想要修改端口號(hào),需要修改Tomcat的server.xml文件:
          1.non-SSL HTTP/1.1 Connector定義的地方,一般如下:
               <Connector port="80" maxHttpHeaderSize="8192"
                          maxThreads="500" minSpareThreads="25" maxSpareThreads="75"
                          enableLookups="false" redirectPort="443" acceptCount="100"
                          connectionTimeout="20000" disableUploadTimeout="true" />
          將其中的redirectPort端口號(hào)改為:443
          2.SSL HTTP/1.1 Connector定義的地方,修改端口號(hào)為:443,如下:
          <Connector    
             port="443" maxHttpHeaderSize="8192"
             maxThreads="150" minSpareThreads="25"
             maxSpareThreads="75"
             enableLookups="false"
             disableUploadTimeout="true"
             acceptCount="100" scheme="https"
             secure="true"
             clientAuth="false" sslProtocol="TLS"
             keystoreFile="conf/tomcat.keystore"
             keystorePass="123456" />
          3.AJP 1.3 Connector定義的地方,修改redirectPort為443,如下:
               <Connector port="8009"
                          enableLookups="false" redirectPort="443" protocol="AJP/1.3" />

          重新啟動(dòng)Tomcat就可以了。到這一步可以形成訪問(wèn)方式 http://www.5a520.cn /item

          到tomcat下面的webapps下面的ROOT下面的index.jsp文件的內(nèi)容
          <?xml version="1.0" encoding="ISO-8859-1"?>
            <%response.sendRedirect("/item");%>

          修改web.xml文件的內(nèi)容
          <?xml version="1.0" encoding="ISO-8859-1"?>
          <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
              version="2.4">

            <display-name>Welcome to Tomcat</display-name>
            <description> 
               http://www.feng123.com 蜂蜜交易網(wǎng)
            </description>

            <welcome-file-list>
             <welcome-file>/index.jsp</welcome-file>
            </welcome-file-list>
          </web-app>
          刪除lib目錄下的lib文件
          重啟Tomcat服務(wù)器,在這一步可以直接通過(guò)https:ip來(lái)訪問(wèn)項(xiàng)目

          posted @ 2009-05-12 11:35 fun| 編輯 收藏

          10分鐘學(xué)懂Struts 2.0 攔截器

          Struts 2.0攔截器

          簡(jiǎn)介

           

          Struts 2.0 中的攔截器,要實(shí)現(xiàn)com.opensymphony.xwork2.interceptor.Interceptor接口,在struts.xml中配置。可以用攔截器來(lái)完成調(diào)用Action業(yè)務(wù)邏輯之前的預(yù)處理或是之后的善后處理。還可以通過(guò)配置多個(gè)攔截器來(lái)滿足action需求。

           

          Interceptor stack是由多個(gè)攔截器組成的攔截器組,在攔截器組中可以對(duì)每一個(gè)攔截器映射。所有進(jìn)行配置攔截器時(shí),不必對(duì)每一個(gè)攔截器進(jìn)行配置,而只需對(duì)interceptor stack進(jìn)行配置即可。在struts 2中默認(rèn)配置了一個(gè)全局interceptor stack,包括Exception Interceptor、Validation Interceptor等。

           

          實(shí)例

           

          在這個(gè)實(shí)例當(dāng)中,我將配置一個(gè)時(shí)間攔截器,用來(lái)統(tǒng)計(jì)每個(gè)action的請(qǐng)求時(shí)間。

          package interceptor;      
               
          import com.opensymphony.xwork2.ActionInvocation;      
          import com.opensymphony.xwork2.interceptor.Interceptor;      
          /**
          *author by 
          http://www.bt285.cn http://www.5a520.cn
          */
               
          public class ActionTimer implements Interceptor{      
              
          public String intercept(ActionInvocation next) throws Exception {      
                  
          long t1 = System.currentTimeMillis();      
                  String s
          = next.invoke();      
                  
          long t2 = System.currentTimeMillis();      
                  System.out.println(
          "Action "+next.getAction().getClass().getName()+" took "+(t2-t1)+" millisecs");      
                  
          return s;      
              }
                
                    
              
          public void init() {      
              }
                
              
          public void destroy() {      
              }
                
          }
            
          struts.xml
          <?xml version="1.0" encoding="UTF-8" ?>     
          <!DOCTYPE struts PUBLIC      
              "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"      
              "http://struts.apache.org/dtds/struts-2.0.dtd"
          >     
          <struts>     
              
          <package name="interceptor" extends="struts-default">     
                  
          <interceptors>     
                      
          <interceptor name="actiontimer"     
                          class
          ="interceptor.ActionTimer" />     
               
                      
          <interceptor-stack name="demostack">     
                          
          <interceptor-ref name="defaultStack" />     
                          
          <interceptor-ref name="actiontimer" />     
                      
          </interceptor-stack>     
                  
          </interceptors>     
                  
          <default-interceptor-ref name="demostack" />     
                  
          <action name="InterceptorDemo"     
                      class
          ="interceptor.action.InterceptorDemo">     
                      
          <result>http://www.bt285.cn /interceptor/interceptordemo.jsp</result>     
                  
          </action>     
              
          </package>     
               
          </struts>   

          interceptordemo.jsp

          <html>     
          <head>     
               
          </head>     
          <body>     
          </body>     
          </html>   

           

           

          posted @ 2009-05-08 20:31 fun| 編輯 收藏

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(11)

          隨筆檔案

          友情鏈接

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 东方市| 丰都县| 蒙自县| 乐平市| 麻城市| 彩票| 聊城市| 乌拉特前旗| 上高县| 长武县| 乐清市| 静宁县| 治多县| 区。| 磴口县| 沭阳县| 洛宁县| 辛集市| 呼和浩特市| 西平县| 朝阳县| 定西市| 余干县| 视频| 神农架林区| 绩溪县| 迁安市| 滨州市| 安康市| 宁安市| 义马市| 贵州省| 北京市| 舒城县| 绵阳市| 金沙县| 筠连县| 鹤庆县| 西昌市| 隆德县| 普定县|