|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
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-inetd --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-access_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应用平台了。实际使用中,还是有很多技巧。看了resin官方论坛的一些资料,说resin3.x以上的版本,对image和html的支持,比apache响应更快。我对此测试过,感觉还是有所欠缺。所以说,在大型一点的发布平台上,还是要apache和resin结合比较好。 对于resin的负载均衡使用上启动的进程数,我认为还是要根据自己的机器实际情况来考虑的。少了达不到效果,多了会机器系统也是一个负载。个人认为,4个可以作为一个默认的选择来考虑。 返回类别: 教程 上一教程: 八、设置HTTP应答头 下一教程: 缓冲技术提高JSP程序性能和稳定性 您可以阅读与"APACHE+RESIN+PUREFTP的虚拟主机和负载均衡"相关的教程: · Tomcat5.x中的虚拟主机配置方式 · Tomcat集群的三种负载均衡方法优缺点对照。 · 配置整合WIN+APACHE+PHP+MYSQL+TCOMCAT(或RESIN)完全手册 · JAVA/JSP学习系列之三(RESIN+APACHE的安装) · 怎样设置 JSP 的虚拟目录 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |