resin负载均衡搭构,全过程呈现

网络 网络优化 网络运维
本文介绍了resin负载均衡配置的具体内容,首先是平台的建设,就是Apache的设置,然后是resin的设置。那么最后就是脚本的运行操作。希望对您能有所帮助。

前面的铺垫工作应经做好了,那么现在就是真正的resin负载均衡配置的过程了。在前面我们已经介绍了相关的apache的一些设置内容,不过它结合的是tomacat,那么其实两者还有着一些相同之处,如果您感兴趣的话可以跟之前文章进行一下比较。

resin负载均衡配置软件:

目的:用apache和resin做基于域名的虚拟主机,启用resin自身的负载均衡的引擎。resin的负载均衡引擎实际上是可以启动多个java响应进程,通过内部机制来进行负载均衡。

resin负载均衡配置1、配置apache:

#vi/usr/local/apache2/conf/httpd.conf

DirctoryIndexindex.htmlindex.jsp
AddDefaultCharsetOff
Usernobody
Groupnobody
NamevirtualHost211.11.11.11
<VirtualHost211.11.11.11:80>;
ServerAdminpeng.zhang@bj.china.com
DocumentRoot/data/web/xcity
ServerNamexcity.chinaunix.com
ErrorLoglogs/xcity.chinaunix.com-error_log
CustomLoglogs/xcity.chinaunix.com-access_logcommon
</VirtualHost>;

<VirtualHost211.11.11.11:80>;
ServerAdminpeng.zhang@bj.china.com
DocumentRoot/data/web/sports
ServerNamesports.chinaunix.com
ErrorLoglogs/sports.chinaunix.com-error_log
CustomLoglogs/sports.chinaunix.com-access_logcommon
</VirtualHost>;

#mod_cauchoResinConfiguration
#LoadModulecaucho_module/usr/local/apache2/modules/mod_caucho.so
ResinConfigServer127.0.0.1

#p#resin负载均衡配置2、resin:

#vi/usr/local/resin/conf/resin.conf
<cluster>;
<srunid="a"host="127.0.0.1"port="6801"index="1"/>;
<srunid="b"host="127.0.0.1"port="6802"index="2"/>;
<srunid="c"host="127.0.0.1"port="6803"index="3"/>;
<srunid="d"host="127.0.0.1"port="6804"index="4"/>;
</cluster>;


注解:(这里面,我用了系统本身的127.0.0.1,绑定了4个端口做伏在均衡。还可以用不同的ip地址和同一端口,来作。例如:

<cluster>;
<srunid="a"host="211.11.11.11"port="6802"index="1"/>;
<srunid="b"host="211.11.11.12"port="6802"index="2"/>;
<srunid="c"host="211.11.11.13"port="6802"index="3"/>;
<srunid="d"host="211.11.11.14"port="6802"index="4"/>;
</cluster>;


还有些人,喜欢在apache中设置每一个java进程服务一个虚拟,这里我们不推荐,这样做,就会失去引擎本身的意义。)

<!--configuresthedefaulthost,matchinganyhostname-->;
<hostid='xcity.chinaunix.com'>;
<document-directory>;/data/web/xcity</document-directory>;
<!--configurestherootweb-app-->;
<web-appid='/'>;
<!--addsxsltothesearchpath-->;
<class-loader>;
<simple-loaderpath="$host-root/xsl"/>;
</class-loader>;
<servlet-mappingurl-pattern="/servlet/*"servlet-name="invoker"/>;
</web-app>;
</host>;

<hostid='sports.chinaunix.com'>;
<document-directory>;/opt/web/sports</document-directory>;
<!--configurestherootweb-app-->;
<web-appid='/'>;
<!--addsxsltothesearchpath-->;
<class-loader>;
<simple-loaderpath="$host-root/xsl"/>;
</class-loader>;
<servlet-mappingurl-pattern="/servlet/*"servlet-name="invoker"/>;
</web-app>;
</host>;

注:这里面是基于域名的虚拟主机,如果是针对ip的虚拟主机,在<hostid='*.*.*.*'>;中,就应该是对应虚拟主机的ip了。也就是说,apache和resin关于虚拟主机的地方要保持一致。还有,在resin中,对于每个虚拟主机所用的web-app目录,其实是相对于她的家目录下的/目录。#p#

resin负载均衡配置3、pureftp

1、添加用户:

#pure-pwuseraddxcityr-f/usr/local/pureftp/etc/ftppasswd-unobody-gnobody-d/data/web/xcity-m
#pure-pwuseraddsports-f/usr/local/pureftp/etc/ftppasswd-unobody-gnobody-d/data/web/sports-m

注:xcity:ftp用户
-fftppasswd:存放用户密码信息的文件
-u用户uid一般是系统的一个用户,就是你的ftp用户的家目录的用户
-g用户组id
-d锁定用户在家目录
-m使pureftp.d.passwd写进pureftpd.pdb,使更改生效。

◆修改用户:#pure-pwusermod--help

◆删除用户:#pure-pwuserdel<login>;[-f<passwdfile>;][-m]

◆更改拥护密码:#pure-pwpasswd<login>;[-f<passwdfile>;][-m]

◆查看用户详细内容:#pure-pwshow<login>;[-f<passwdfile>;]

◆生成db文件,使密码生效:#pure-pwmkdb[<puredbdatabasefile>;[-f<passwdfile>;]]

◆列出所有用户:#pure-pwlist[-f<passwdfile>;]#p#

启动脚本:

当系统在solaris下,apache和resin的启动脚本:

  1. #vi/etc/rc2.d/S99webapp  
  2. /usr/local/resin/bin/httpd.sh-pidsrun1.pid-serverastart  
  3. /usr/local/resin/bin/httpd.sh-pidsrun2.pid-serverbstart  
  4. /usr/local/resin/bin/httpd.sh-pidsrun3.pid-servercstart  
  5. /usr/local/resin/bin/httpd.sh-pidsrun4.pid-serverdstart  
  6. /usr/local/apache2/bin/apachectlstart 

pureftp启动脚本:

  1. #!/bin/sh  
  2. /usr/local/pureftpd/sbin/pure-ftpd-j-lpuredb:/usr/local/pureftpd/etc/pureftpd.pdb& 

在linux下,直接放到响应的开机启动等级目录下就ok了。

resin负载均衡配置总结

apache+resin应该是个很好的java应用平台了。实际使用中,还是有很多技巧。看了resin官方论坛的一些资料,说resin3.x以上的版本,对image和html的支持,比apache响应更快。我对此测试过,感觉还是有所欠缺。所以说,在大型一点的发布平台上,还是要apache和resin结合比较好。对于resin的负载均衡使用上启动的进程数,我认为还是要根据自己的机器实际情况来考虑的。少了达不到效果,多了会机器系统也是一个负载。个人认为,4个可以作为一个默认的选择来考虑。

责任编辑:佟健 来源: 互联网
相关推荐

2010-05-04 16:20:11

resin负载均衡

2011-02-22 10:46:02

Samba配置

2009-12-08 17:56:16

WCF配置

2011-04-18 15:56:10

软件测试

2011-09-06 15:38:20

QT安装

2011-01-21 17:51:52

2009-04-13 12:37:18

2010-04-28 12:52:36

负载均衡策略

2010-04-26 00:42:08

DNS负载均衡

2010-03-01 17:01:03

Python编程技巧

2012-11-06 10:19:18

Java自定义加载Java类

2009-06-10 16:55:42

cygwin netb安装

2010-06-17 13:10:09

Linux Grub修

2010-11-19 10:11:49

Oracle物化视图

2010-03-10 13:24:45

Zend Debugg

2011-03-11 10:39:02

YUM安装LAMP

2010-07-21 14:51:19

telnet-serv

2010-06-12 10:03:20

Ubuntu Grub

2019-05-14 15:27:31

MongoDB自动备份数据库

2017-04-25 18:03:11

Caffe深度学习框架
点赞
收藏

51CTO技术栈公众号