fun

           

          2009年5月7日

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

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

           

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

          CAP原則
          BASE策略
          異步(MessageQueue)
          數(shù)據(jù)庫
             數(shù)據(jù)的水平切分及垂直切分
              數(shù)據(jù)庫讀寫分離
              避免分布式事務(wù)
              反范式的數(shù)據(jù)庫設(shè)計(jì)
          負(fù)載均衡
              DNS負(fù)載均衡
              反向代理負(fù)載均衡
               LVS
          緩存
              數(shù)據(jù)庫緩存
               服務(wù)器緩存/頁面緩存/數(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) | 評論 (3)編輯 收藏

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

          在命令提示符窗口,進(jìn)入Tomcat目錄,執(zhí)行以下命令:
          keytool -genkey -alias tomcat -keyalg RSA -keypass changeit -storepass changeit -keystore server.keystore -validity 3600
          通過以上步驟生成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"/> 
          到這一步訪問https;//ip:8443/item

          一般Tomcat默認(rèn)的SSL端口號是8443,但是對于SSL標(biāo)準(zhǔn)端口號是443,這樣在訪問網(wǎng)頁的時候,直接使用https而不需要輸入端口號就可以訪問,如http://www.bt285.cn
          想要修改端口號,需要修改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端口號改為:443
          2.SSL HTTP/1.1 Connector定義的地方,修改端口號為: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" />

          重新啟動Tomcat就可以了。到這一步可以形成訪問方式 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ù)器,在這一步可以直接通過https:ip來訪問項(xiàng)目

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

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

          Struts 2.0攔截器

          簡介

           

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

           

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

           

          實(shí)例

           

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

          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| 編輯 收藏

          Spring中的定時任務(wù)介紹

          下面我們來看一下Spring中提供的定時任務(wù)開發(fā):
          在Spring中開發(fā)定時任務(wù),分為3個步驟。
          1 創(chuàng)建定時任務(wù)
          2 注冊定時任務(wù)
          3 啟動定時任務(wù)
          分別來看一下
          1 創(chuàng)建定時任務(wù):

          package org.jnotnull;
          import java.util.TimerTask;
          public class MyTesk extends TimerTask{
          ....
          public void run(){
          //添加任務(wù)
          }
          ....
          }

          2 注冊定時任務(wù),并設(shè)置參數(shù)
          我們來配置TimerConfig.xml防御WEB-INF下

          <bean id="myTesk" class="edu.cumt.jnotnull.action.TaskAction">  
                  
          <property name="newsManageService">  
                      
          <ref bean="newsManageService" />  
                  
          </property>  
              
          </bean>  
              
          <bean id="stTask"  
                  class
          ="org.springframework.scheduling.timer.ScheduledTimerTask">  
                  
          <property name="delay">  
                      
          <value>20000</value>  
                  
          </property>  
                  
          <property name="period">  
                      
          <value>30000</value>  
                  
          </property>  
                  
          <property name="timerTask">  
                      
          <ref bean="myTesk" />  
                  
          </property>  
              
          </bean>  
              
          <bean id="timerFactory"  
                  class
          ="org.springframework.scheduling.timer.TimerFactoryBean">  
                  
          <property name="scheduledTimerTasks">  
                      
          <list>  
                          
          <ref bean="stTask" />  
                      
          </list>  
                  
          </property>  
              
          </bean>  
          3 啟動定時任務(wù)   
          <PRE class=xml name="code"><?xml version="1.0" encoding="UTF-8"?>  
          <web-app>  
          <context-param>  
          <param-name>contextConfigLocation</param-name>  
          <param-value>http://www.bt285.cn /WEB-INF/TimerConfig.xml</param-value>  
          </context-param>  
          <listener>  
          <listener-class>  
           org.springframework.web.context.ContextLoaderListener   
          </listener-class>  
          </listener>  
          </web-app>  
          </PRE>  
          <BR>  
          <BR>下面我們再來看看在Spring中如何使用Quartz實(shí)現(xiàn)定時功能   
          <BR>1 創(chuàng)建定時任務(wù):   
          <BR><PRE class=java name="code">package org.jnotnull;   
          import java.util.TimerTask;   
          /**
          *http://www.5a520.cn
          */
          public class MyTesk extends TimerTask{   
           
          public void excute(){   
          //添加任務(wù)   
          }   
          .   
          }   
          </PRE>  
          <BR>2 注冊定時任務(wù),并設(shè)置參數(shù)   
          <BR>我們來配置TimerConfig.xml防御WEB-INF下   
          <BR><PRE class=xml name="code"><?xml version="1.0" encoding="UTF-8">  
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"    
          "http://www.springframework.org/dtd/spring-beans.dtd">  
          <beans>  
          <bean id ="myTesk" class="org.jnotnull.MyTesk"/>  
          <bean id ="myJob"    
          class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
          <property name="targetObject">  
          <ref bean="myTask">  
          </property>  
          <propertyproperty ="targetMethod">  
          <value>execute</value>  
          </property>  
          </bean>  
          <bean id ="timeTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">  
          <property name="jobDetail">  
           <ref bean="myJob">  
          </property>  
          <property name="cronExpression">  
          <value>12,23****?</value>  
          </property>  
          </bean>  
          <bean id ="timerFactory"    
          class="org.springframework.scheduling.quartz.ScheduleFactoryBean">  
          <property name="triggers">  
          <list>  
          <refref="timeTrigger">  
          </list>  
          </property>  
          </bean>  
          </beans>  
          </PRE>  
          <BR>3 啟動定時任務(wù)   
          <BR><PRE class=xml name="code"><?xml version="1.0" encoding="UTF-8"
          ?>  
          <web-app>  
          <context-param>  
          <param-name>contextConfigLocation</param-name>  
          <param-value> http://www.bt285.cn /WEB-INF/TimerConfig.xml</param-value>  
          </context-param>  
          <listener>  
          <listener-class>  
           org.springframework.web.context.ContextLoaderListener   
          </listener-class>  
          </listener>  
          </web-app>  
          </PRE>    

          posted @ 2009-05-07 18:59 fun| 編輯 收藏

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(11)

          隨筆檔案

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 武强县| 云梦县| 南和县| 全南县| 调兵山市| 集安市| 海城市| 德阳市| 讷河市| 丘北县| 霍山县| 乡城县| 营口市| 双流县| 长春市| 宁波市| 平远县| 龙里县| 东辽县| 买车| 七台河市| 无锡市| 启东市| 锡林浩特市| 临湘市| 盐源县| 五指山市| 广饶县| 鸡东县| 青铜峡市| 涪陵区| 原阳县| 澳门| 怀宁县| 周宁县| 扎赉特旗| 华容县| 新乐市| 渑池县| 清水县| 长海县|