• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • apache+resin+pureftp的虛擬主機和負載均衡

    發表于:2007-07-04來源:作者:點擊數: 標簽:
    apache+resin+pureftp的虛擬主機和負載均衡 作者:peng 轉自:china unix 1、前言 apache+resin來做想來大家都比較熟悉了,一般的配置都是很熟悉的了,我查看了一些論壇上的文章,這方便的文章比較多。在這里,我只要寫寫apache+resin實現獨立的虛擬主機和r
    apache+resin+pureftp的虛擬主機和負載均衡
    作者:peng 轉自:chinaunix

    1、前言
    apache+resin來做想來大家都比較熟悉了,一般的配置都是很熟悉的了,我查看了一些論壇上的文章,這方便的文章比較多。在這里,我只要寫寫apache+resin實現獨立的虛擬主機和resin自帶的負載均衡。

    2、系統和環境:
    redhat9 and solaris9
    httpd-2.50
    resin-3.06
    pure-ftpd-1.0.17a.tar.gz
    3、安裝軟件:

    3.1、安裝apache:

    # tar zxvf httpd-2.49.tar.gz
    # cd httpd-2.49
    # ./configure --prefix=/usr/local/apache2 --enable-so --with-mpm=worker
    # make
    # make install

    3.2、安裝resin:

    # tar zxvf resin-3.06.tar.gz
    # cd resin03.06
    # ./configure --prefix=/usr/local/resin --with-apxs=/usr/local/apache2/bin/apxs
    # make
    # make install

    3.3、安裝pureftp

    # tar zxvf pure-ftpd-1.0.17a.tar.gz
    # cd pure-ftpd-1.0.17a
    # ./configure --prefix=/usr/local/pureftpd
    --without-.netd --with-puredb
    --with-cookie --with-throttling
    --with-ratios --with-quotas
    --with-ftpwho --with-largefile
    --with-welcomemsg
    # make
    # make install
    # mkdir /usr/local/pureftpd/etc

    4、配置軟件:

    目的:用apache和resin做基于域名的虛擬主機,啟用resin自身的負載均衡的引擎。resin的負載均衡引擎實際上是可以啟動多個java響應進程,通過內部機制來進行負載均衡。

    4.1、配置apache:

    # vi /usr/local/apache2/conf/httpd.conf
    ---------------------------------------
    DirctoryIndex index.html index.jsp
    AddDefaultCharset Off
    User nobody
    Group nobody
    NamevirtualHost 211.11.11.11
    <VirtualHost 211.11.11.11:80>
    ServerAdmin
    peng.zhang@bj.china.com
    DocumentRoot /data/web/xcity
    ServerName xcity.chinaunix.com
    ErrorLog logs/xcity.chinaunix.com-error_log
    CustomLog logs/xcity.chinaunix.com-aclearcase/" target="_blank" >ccess_log common
    </VirtualHost>

    <VirtualHost 211.11.11.11:80>
    ServerAdmin
    peng.zhang@bj.china.com
    DocumentRoot /data/web/sports
    ServerName sports.chinaunix.com
    ErrorLog logs/sports.chinaunix.com-error_log
    CustomLog logs/sports.chinaunix.com-access_log common
    </VirtualHost>
    ........
    ....
    # mod_caucho Resin Configuration
    #

    LoadModule caucho_module /usr/local/apache2/modules/mod_caucho.so

    ResinConfigServer 127.0.0.1
    ---------------------------------------

    4.2、配置resin:

    # vi /usr/local/resin/conf/resin.conf
    ----------------------------------------

    <cluster>
    <srun id="a" host="127.0.0.1" port="6801" index="1"/>
    <srun id="b" host="127.0.0.1" port="6802" index="2"/>
    <srun id="c" host="127.0.0.1" port="6803" index="3"/>
    <srun id="d" host="127.0.0.1" port="6804" index="4"/>
    </cluster>

    ---注解:
    (這里面,我用了系統本身的127.0.0.1,綁定了4個端口做伏在均衡。還可以用不同的ip地址和同一端口,來作。例如:
    <cluster>
    <srun id="a" host="211.11.11.11" port="6802" index="1"/>
    <srun id="b" host="211.11.11.12" port="6802" index="2"/>
    <srun id="c" host="211.11.11.13" port="6802" index="3"/>
    <srun id="d" host="211.11.11.14" port="6802" index="4"/>
    </cluster>
    還有些人,喜歡在apache中設置每一個java進程服務一個虛擬,這里我們不推薦,這樣做,就會失去引擎本身的意義。)

    <!-- configures the default host, matching any host name -->
    <host id='xcity.chinaunix.com'>
    <document-directory>/data/web/xcity</document-directory>
    <!-- configures the root web-app -->
    <web-app id='/'>
    <!-- adds xsl to the search path -->
    <class-loader>
    <simple-loader path="$host-root/xsl"/>
    </class-loader>
    <servlet-mapping url-pattern="/servlet/*" servlet-name="invoker"/>
    </web-app>
    </host>

    <host id='sports.chinaunix.com'>
    <document-directory>/opt/web/sports</document-directory>
    <!-- configures the root web-app -->
    <web-app id='/'>
    <!-- adds xsl to the search path -->
    <class-loader>
    <simple-loader path="$host-root/xsl"/>
    </class-loader>
    <servlet-mapping url-pattern="/servlet/*" servlet-name="invoker"/>
    </web-app>
    </host>
    ........
    ....

    --------------------------------------------------

    ---注:這里面是基于域名的虛擬主機,如果是針對ip的虛擬主機,在<host id='*.*.*.*'>中,就應該是對應虛擬主機的ip了。也就是說,apache和resin關于虛擬主機的地方要保持一致。還有,在resin中,對于每個虛擬主機所用的web-app目錄,其實是相對于她的家目錄下的/目錄。

    4.3、配置pureftp
    1、添加用戶:
    # pure-pw useradd xcityr -f /usr/local/pureftp/etc/ftppasswd -u nobody -g nobody -d /data/web/xcity -m

    # pure-pw useradd sports -f /usr/local/pureftp/etc/ftppasswd -u nobody -g nobody -d /data/web/sports -m

    ---注:xcity :ftp用戶
    -f ftppasswd:存放用戶密碼信息的文件
    -u 用戶uid 一般是系統的一個用戶,就是你的ftp用戶的家目錄的用戶
    -g 用戶組id
    -d 鎖定用戶在家目錄
    -m 使pureftp.d.passwd寫進pureftpd.pdb,使更改生效。

    *修改用戶:
    # pure-pw usermod --help

    *刪除用戶:
    # pure-pw userdel <login> [-f <passwd file>] [-m]

    *更改擁護密碼:

    # pure-pw passwd <login> [-f <passwd file>] [-m]

    *查看用戶詳細內容:

    # pure-pw show <login> [-f <passwd file>]

    *生成db文件,使密碼生效:
    # pure-pw mkdb [<puredb database file> [-f <passwd file>]]

    *列出所有用戶:
    # pure-pw list [-f <passwd file>]


    5、啟動腳本:

    當系統在solaris下:

    apache和resin的啟動腳本:
    # vi /etc/rc2.d/S99webapp
    -------------------------------
    /usr/local/resin/bin/httpd.sh -pid srun1.pid -server a start
    /usr/local/resin/bin/httpd.sh -pid srun2.pid -server b start
    /usr/local/resin/bin/httpd.sh -pid srun3.pid -server c start
    /usr/local/resin/bin/httpd.sh -pid srun4.pid -server d start
    /usr/local/apache2/bin/apachectl start
    --------------------------------

    pureftp啟動腳本:
    --------------------------------
    #!/bin/sh

    /usr/local/pureftpd/sbin/pure-ftpd -j -lpuredb:/usr/local/pureftpd/etc/pureftpd.pdb &
    -----------------------------------

    linux下,直接放到響應的開機啟動等級目錄下就ok了。

    6、總結
    apache+resin應該是個很好的java應用平臺了。實際使用中,還是有很多技巧??戳藃esin官方論壇的一些資料,說resin3.x以上的版本,對image和html的支持,比apache響應更快。我對此測試過,感覺還是有所欠缺。所以說,在大型一點的發布平臺上,還是要apache和resin結合比較好。
    對于resin的負載均衡使用上啟動的進程數,我認為還是要根據自己的機器實際情況來考慮的。少了達不到效果,多了會機器系統也是一個負載。個人認為,4個可以作為一個默認的選擇來考慮。

    聲明:
    寫文章的時候,參考很多網友資料,如有雷同,不一定純屬巧合。
    以上過程,都是本人親自測試和使用,但也難保證有書寫遺漏,歡迎指出。
    本著自由、共享的精神,網友可以任意轉貼,轉貼時請注明作者、出處。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>