安泰信息

2009年02月17日

笔记本电脑linux下cpu无法全速运行的解决方法

归档在: Linux — JACKEYJ @ 1:47 PM

公司采购一批dell 1310的笔记本,装了一个centos,结果发现T5670的cpu只能在800MHz下运行,性能可想可而知了.查找了很多的资料,有的说启动的时候禁用apmd也没什么反应,在bios里面也没相关的设置.

最后在poweroff的时候发现一个cpuspeed的服务关闭,于是抱着试试看,把这个服务关闭,重启之后发现已经全速运行了.

2008年11月18日

Optimal mod_jk configuration

归档在: Linux, apache, jboss — JACKEYJ @ 9:03 AM

Optimal mod_jk configuration

 

There are many potential problems associated with the default configuration of mod_jk.  Let’s say it is perfectly adequate for a very low traffic website, but when pushing any moderate to high load to mod_jk, there will be connection problems.  This is not due to any bug in mod_jk whatsoever, however, it is because the default configuration makes no assumption about your existing hardware or potential load, so, therefore, it is not tuned accordingly.

 

Note that the configuration recommendations here are optimal as a base configuration to avoid many of the common problems users experience with mod_jk. There exist many other useful optimizations, but these depend on the environment and web application in use. See http://tomcat.apache.org/connectors-doc/reference/workers.html for details on all available mod_jk properties.

 

Let’s take a look at a typical default configuration for Apache/Tomcat/mod_jk:
workers.properties

worker.list=loadbalancer,status

worker.node1.port=8009
worker.node1.host=node1.mydomain.com
worker.node1.type=ajp13
worker.node1.lbfactor=1

worker.node2.port=8009
worker.node2.host= node2.mydomain.com
worker.node2.type=ajp13
worker.node2.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2

worker.status.type=status

 
JBoss Web’s (Tomcat) server.xml AJP snippet:

<Connector port=”8009″ address=”${jboss.bind.address}” protocol=”AJP/1.3″
         emptySessionPath=”true” enableLookups=”false” redirectPort=”8443″ ></Connector>

 
Apache’s httpd.conf:

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

 

 

The above configuration, under load, may cause mod_jk to be very slow and unresponsive, cause http errors, and cause half-closed connections.   These problems can arise because there are no connection timeouts specified to take care of orphaned connections, no error handling properties defined in workers.properties, and no connection limits set in Apache and Tomcat.

 

 

First off, lets take care of Tomcat:

 
Configuring server.xml:

 

The main concern with server.xml is setting the connectionTimeout which

sets the SO_TIMEOUT of the underlying socket.  So when a connection in

Tomcat hasn’t had a request in the amount of time specified by

connectionTimeout, then the connection dies off.  This is necessary because if the connection hasn’t been used for a certain period of

time then there is the chance that it is half-close on the mod_jk end.

If the connection isn’t closed there will be an inflation of threads

which can over time hit the maxThreads count in Tomcat then Tomcat will

not be able to accept any new connections.  A connectionTimeout of 600000 (10 minutes) is a good number to start out with.  There may be a situation where the connections are not being recycled fast enough, in this instance the connectionTimeout could be lowered to 60000 or 1 minute.

 

When setting connectionTimeout in Tomcat, mod_jk should also have

connect_timeout/prepost_timeout set, which allows detection that the

Tomcat connection has been closed and preventing a retry request.

 

The recommended value of maxThreads is 200 per CPU, so here we assume the server is a single core machine.  If it has been quad core, we could push that value to 800, and more depending on RAM and other machine specs.

 

<Connector port=”8009″
           address=”${jboss.bind.address}”
           emptySessionPath=”true”
           enableLookups=”false”
           redirectPort=”8443″
           protocol=”AJP/1.3″
           maxThreads=”200″
           connectionTimeout=”600000″></Connector>

 

 

 

 
Configuring workers.properties:

 

See comments inline.

 

worker.list=loadbalancer,status

worker.template.port=8009
worker.template.type=ajp13
worker.template.lbfactor=1
worker.template.ping_timeout=1000
#ping_mode was introduced in 1.2.27, if not using 1.2.27 please specify connect_timeout=10000 and prepost_timeout=10000 as an alternative

worker.template.ping_mode=A
worker.template.socket_timeout=10
#It is not necessary to specify connection_pool_timeout if you are running the worker mpm
worker.connection_pool_timeout=600

#Referencing the template worker properties makes the workers.properties shorter and more concise
worker.node1.reference=worker.template
worker.node1.host=192.168.1.2

worker.node2.reference=worker.template
worker.node2.host=192.168.1.3

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2

worker.status.type=status

 

The key points in the above workers.properties is we’ve added limits for the connections mod_jk makes.  With the base configuration, socket timeouts default to infinite. The other important properties are ping_mode and ping_timeout which handle probing a connection for errors and connection_pool_timeout which must be set to equal server.xml’s connectionTimeout when using the prefork mpm.  When these two values are the same, after a connection has been inactive for x amount of time, the connection in mod_jk and Tomcat will be closed at the same time, preventing a half-closed connection.

 

 

 
Configuring Apache

 

Make note that maxThreads for the AJP connection should coincide with

the MaxClients set in Apache’s httpd.conf.  MaxClients needs to be set

in the correct module in Apache.

 

 

This can be determined by running httpd -V:

 

# httpd -V

Server version: Apache/2.2.3
Server built:   Sep 11 2006 09:43:05
Server’s Module Magic Number: 20051115:3
Server loaded:  APR 1.2.7, APR-Util 1.2.8
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with….
-D APACHE_MPM_DIR=”server/mpm/prefork”
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT=”/etc/httpd”
-D SUEXEC_BIN=”/usr/sbin/suexec”
-D DEFAULT_PIDLOG=”logs/httpd.pid”
-D DEFAULT_SCOREBOARD=”logs/apache_runtime_status”
-D DEFAULT_LOCKFILE=”logs/accept.lock”
-D DEFAULT_ERRORLOG=”logs/error_log”
-D AP_TYPES_CONFIG_FILE=”conf/mime.types”
-D SERVER_CONFIG_FILE=”conf/httpd.conf”

 

Which tells me the Server MPM is Prefork.  This is not always 100% accurate so you should also view the output of /etc/sysconfig/httpd to see if the following line is there: HTTPD=/usr/sbin/httpd.worker.  If it is commented out you are running prefork, otherwise if uncommented worker.

 

httpd.conf:

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
MaxClients       200
MaxRequestsPerChild  0
</IfModule>

 

Or if Apache is using worker, it is
<IfModule worker.c>
StartServers         2
MaxClients         200
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

 

MaxRequestsPerChild is 0, this is the recommended value when using

mod_jk as mod_jk keeps open persistent connections.  The key values in

the above configuration are MaxClients and MaxRequestsPerChild, the rest

of the values are left as default.  Note that MaxRequestsPerChild is

recommended to be 0 however the value may need to be greater than 0

depending on if Apache is used for other modules also, especially in the

case of resource leakage.

 

 
Advanced worker-mpm Configuration

 

To get the most out of your mod_jk setup you should be using Apache’s worker mpm which provides a definite performance improvement over the prefork mpm.  The following section will detail how to configure Apache/mod_jk/Tomcat with the worker mpm and the math behind the configuration.

 

Let’s start out with the worker mpm configuration

<IfModule mpm_worker_module>

ThreadLimit 100
StartServers 5
MaxClients 1000
MinSpareThreads 100
MaxSpareThreads 1000
ThreadsPerChild 100
MaxRequestsPerChild 0
</IfModule>

 

The optimal configuration completely depends on the hardware being used and the load requirements.  But a general rule of thumb, keep processes low and thread count high.  To determine the number of processes Apache will use simply divide MaxClients by ThreadPerChild.  So in this case MaxClients (1000) / ThreadsPerChild (100) = Processes (10), so Apache will allocate a maximum of 100 threads per each 10 child processes resulting in a total of 1000 possible clients.

 

Now to translate this to mod_jk, mod_jk maintains a connection pool for each worker defined in workers.properties.  By default with Apache mod_jk sets connection_pool_size to ThreadsPerChild, so in the above case that would translate to 100, giving 1000 possible connections to JBoss.  This may or may not be desired.

 

Let’s take a common example, there will be 3 JBoss servers that combined needed to be able to handle 900 concurrent connections

 

worker.list=loadbalancer,status
 

worker.template.type=ajp13
worker.template.port=8009
worker.template.ping_mode=A
worker.template.connection_pool_size=30
worker.template.socket_timeout=10
worker.template.retries=20
 

worker.node1.reference=worker.template
worker.node1.host=192.168.0.101

worker.node2.reference=worker.template
worker.node2.host=192.168.0.102

worker.node3.reference=worker.template
worker.node3.host=192.168.0.103
 

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2, node3
worker.sticky_session=True

worker.status.type=status

 

The above configuration tells mod_jk to multiplex 30 connections to the available Apache processes, which is 10 processes.  So that means 30 connections multiplexed over 10 processes gives 300 possible connections to each backend worker.  Furthermore, the total connections able to be used in this configuration from Apache is 900 which means  100 connections will be left over for static content or whatnot.

 

 

Next configure maxThreads in each ajp connector to match the above.

 

Node 1 ajp connector:

<Connector port=”8009″
           address=”${jboss.bind.address}”
           emptySessionPath=”true”
           enableLookups=”false”
           redirectPort=”8443″
           protocol=”AJP/1.3″
           maxThreads=”300″
           connectionTimeout=”600000″></Connector>

 

Node 2 ajp connector:

<Connector port=”8009″
           address=”${jboss.bind.address}”
           emptySessionPath=”true”
           enableLookups=”false”
           redirectPort=”8443″
           protocol=”AJP/1.3″
           maxThreads=”300″
           connectionTimeout=”600000″></Connector>

 

Node 3 ajp connector:

<Connector port=”8009″
           address=”${jboss.bind.address}”
           emptySessionPath=”true”
           enableLookups=”false”
           redirectPort=”8443″
           protocol=”AJP/1.3″
           maxThreads=”300″
           connectionTimeout=”600000″></Connector>

 

Remember when using connectionTimeout which is always recommended, prepost_timeout and connect_timeout also need to be set, which is done.  I’m not showing sticky session configuration, but that covered in the main mod_jk article in using mod_jk with JBoss.

 reference from :http://www.jboss.org/community/docs/DOC-11543

UsingMod_jk1.2WithAFirewall

归档在: Linux, apache, jboss — JACKEYJ @ 8:38 AM

Setting up mod_jk with a firewall:

 
Configuring workers.properties:

# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
#Using an IP prevents a DNS lookup
worker.node1.host=192.168.1.2
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.connect_timeout=10000
worker.node1.prepost_timeout=10000
worker.node1.socket_keepalive=True

# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=192.168.1.3
worker.node2.type=ajp13
worker.node2.lbfactor=1
worker.node2.connect_timeout=10000
worker.node2.prepost_timeout=10000
worker.node2.socket_keepalive=True

# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2

# Status worker for managing load balancer
worker.status.type=status

 

 

socket_keepalive=true is the most important setting. connect_timeout and

prepost_timeout are to “work-around” firewalls that

ignore keepalives or close the connection for unknown reasons.

 

 

 
Configuring server.xml:

The main concern with server.xml is setting the connectionTimeout which

sets the SO_TIMEOUT of the underlying socket.  So when a connection in

Tomcat hasn’t had a request in the amount of time specified by

connectionTimeout, then the connection dies off.  Why is this a good

thing?…because if the connection hasn’t been used for a certain period of

time then there is the chance that it is half-close on the mod_jk end.

If the connection isn’t closed there will be an inflation of threads

which can over time hit the maxThreads count in Tomcat then Tomcat will

not be able to accept any new connections.

 

When setting connectionTimeout in Tomcat, mod_jk should also have

connect_timeout/prepost_timeout set, which allows detection that the

Tomcat connection has been closed and preventing a retry request.

 

 

<Connector port=”8009″
           address=”${jboss.bind.address}”
           emptySessionPath=”true”
           enableLookups=”false”
           redirectPort=”8443″
           protocol=”AJP/1.3″
           maxThreads=”200″
           connectionTimeout=”60000″></Connector>

 
Configuring Apache

 

Make note that maxThreads for the AJP connection should coincide with

the MaxClients set in Apache’s httpd.conf.  MaxClients needs to be set

in the correct module in Apache. 

 

 

This can be determined by running httpd -V:

 

# httpd -V

Server version: Apache/2.2.3
Server built:   Sep 11 2006 09:43:05
Server’s Module Magic Number: 20051115:3
Server loaded:  APR 1.2.7, APR-Util 1.2.8
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with….
-D APACHE_MPM_DIR=”server/mpm/prefork”
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT=”/etc/httpd”
-D SUEXEC_BIN=”/usr/sbin/suexec”
-D DEFAULT_PIDLOG=”logs/httpd.pid”
-D DEFAULT_SCOREBOARD=”logs/apache_runtime_status”
-D DEFAULT_LOCKFILE=”logs/accept.lock”
-D DEFAULT_ERRORLOG=”logs/error_log”
-D AP_TYPES_CONFIG_FILE=”conf/mime.types”
-D SERVER_CONFIG_FILE=”conf/httpd.conf”

 

Which tells me the Server MPM is Prefork

 

httpd.conf:

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
MaxClients       200
MaxRequestsPerChild  0
</IfModule>

 

Or if Apache is using worker, it is
<IfModule worker.c>
StartServers         2
MaxClients         200
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

 

MaxRequestsPerChild is 0, this is the recommended value when using

mod_jk as mod_jk keeps open persistent connections.  The key values in

the above configuration are MaxClients and MaxRequestsPerChild, the rest

of the values are left as default.  Note that MaxRequestsPerChild is

recommended to be 0 however the value may need to be greater than 0

depending on if Apache is used for other modules also, especially in the

case of resource leakage.

2008年11月11日

redflag linux java中文乱码解决

归档在: 未分类, Linux, java — JACKEYJ @ 8:40 AM

最近运行一个jnlp程序,但中文显示成了方块,gg里面搜罗一下:

解决乱码问题

在redflag desktop6 sp1中可能打开java控制面板乱码,解决办法如下: 拷贝/usr/share/fonts/zh_CN/TrueType(其它版本可参考 /usr/share/fonts/chinese/TrueType)中的ttf文件到 “/zjant.com/jre/lib/fonts/fallback(如 /usr/java/jre1.6.0_06/lib/fonts/fallback)”夹下,如果在“java安装目录/jre/lib/fonts” 下没有 “fallback”这个目录,可以手工创建一个,即可解决。

2008年10月24日

安泰资讯:jconsole使用实例

归档在: Linux, jboss, java — JACKEYJ @ 4:07 PM

转载自:www.dangdangwanggoushu.net

环境:
服务器端: CentOS4.2 + jdk1.5 + JBoss4.2.3GA
客户端: Windows xp sp3 + jdk1.5.0.6
==================================================================================
jconsole远程监视的配置步骤如下:
服务器端:
1. cp $JAVA_HOME/jre/lib/management/jmxremote.password.template \
$JAVA_HOME/www.dangdangwanggoushu.net.jmxremote.password
chmod 600 $JAVA_HOME/jmxremote.password #必须的,否则提示"Error: Password file read access must be restricted…"

2. vi jmxremote.password 去掉#monitorRole RED前的注释并将RED修改为你要设置的密码。(安全起见,只开放有只读权限的用户).由于权限是只读使用:wq!保存退出。

3. 修改 $JBOSS/bin/run.conf,在JAVA_OPT添加三个参数:
-Dcom.sun.management.jmxremote.port=1010
-Dcom.sun.management.jmxremote.password.file=$JAVA_HOME/www.dangdangwanggoushu.net.jmxremote.password   
-Dcom.sun.management.jmxremote.ssl=false

下面是我的jboss配置启动参数:
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Dcom.sun.management.jmxremote\
        -Dcom.sun.management.jmxremote.port=9010\
        -Dcom.sun.management.jmxremote.ssl=false\
        -Dcom.sun.management.jmxremote.authenticate=false\
        -server -Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m\
        -Djava.rmi.server.hostname=192.168.1.122"
fi

提示:如果是在其他机器上进行监控,则必须加上-Djava.rmi.server.hostname=IP项,否则提示无法连接。

4. 执行hostname -i ,如果显示的是127.0.0.1,则需要修改/etc/hosts文件

5. vi /etc/hosts,修改如下:
#127.0.0.1              localhost localhost.localdomain localhost www.dangdangwanggoushu.net

服务器的真实IP地址        localhost localhost.localdomain localhost www.dangdangwanggoushu.net
具体原因是服务器端解释机器名的问题,相关问题见: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6209663
服务器端配置参见: http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#remote

6. 启动jboss 检查监听端口是否启动 netstat -na|grep 1010 查看1010端口是否已在监听

[root@download ~]# netstat -nap|grep 9010
tcp        0      0 0.0.0.0:9010                0.0.0.0:*                   LISTEN      15216/java

========================================================================================
客户端:
1. 到你的jdk安装路径bin目录下,运行jconsole

2. 指定连接参数
远程主机: 服务器的真实IP地址
端口: 9010 ($JAVA_ARGS中-Dcom.sun.management.jmxremote.port指定的端口)
用户名: monitorRole (jmxremote.password中指定的用户名)  #我配置的不需要认证,这个项目可以忽略
密码: your_password(jmxremote.password中设置的密码)    #我配置的不需要认证,这个项目可以忽略
3. 连接 -> OK

客户端配置参见: http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html
jconsole文档地址:http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jconsole.html

2008年09月25日

安泰资讯:主流web server对比

归档在: Linux, apache, ubuntu — JACKEYJ @ 4:58 PM

RoR的部署方式从架构上来说分为前端和后端:

一、前端
前端的作用就是处理静态资源,将动态请求分发到后端,有时候也带有一些额外的功能,例如对特定URL进行rewrite和redirect,对HTTP输出进行gzip压缩等等。

前端目前已知的可以选择apache, lighttpd, litespeed, nginx, haproxy

1、apache2.2
apache是全球市场占有率最高的web server,超过全球互联网网站50%的网站都用apache。apache2.2 + mod_proxy_balancer是一个非常流行,非常稳定的方案。

使用apache2.2唯一的问题就是apache的性能和后面那些轻量级web server相比,差太远了。一方面在处理静态请求方面apache要比lighttpd慢3-5倍,内存消耗和CPU消耗也高出一个数量级,另一方面 mod_proxy_balancer的分发性能也不高,比haproxy差很远。

2、lighttpd
lighttpd是一个轻量级高性能web server,一个在MySQL Inc工作的德国人写的。性能很好,内存和CPU资源消耗很低,支持绝大多数apache的功能,是apache的绝好替代者。目前lighttpd已经 上升到全球互联网第四大web server,市场占有率仅此于apache,IIS和Sun。

lighttpd唯一的问题是proxy功能不完善,因此不适合搭配mongrel来使用。lighttpd下一个版本1.5.0的proxy模块重写过了,将会解决这个问题。

3、litespeed
和lighttpd差不多,商业产品,收费的。比lighttpd来说,多一个web管理界面,不用写配置文件了。litespeed专门为单机 运行的RoR开发了一个lsapi协议,号称性能最好,比httpd和fcgi都要好。他的proxy功能比lighttpd完善。

litespeed的缺点我却认为恰恰是这个lsapi。因为lsapi不是web server启动的时候启动固定数目的ruby进程,而是根据请求繁忙程度,动态创建和销毁ruby进程,貌似节省资源,实则和apache2.2进程模 型一样,留下很大的黑客攻击漏洞。只要黑客瞬时发起大量动态请求,就会让服务器忙于创建ruby进程而导致CPU资源耗尽,失去响应。

当然,litespeed也支持httpd和fcgi,这个和lighttpd用法一样的,到没有这种问题。

4、nginx
一个俄国人开发的轻量级高性能web server,特点是做proxy性能很好,因此被推荐取代apache2.2的mod_proxy_balancer,来和mongrel cluster搭配。其他方面和lighttpd到差不多。

要说缺点,可能就是发展的时间比较短,至今没有正式版本,还是beta版。没有经过足够网站的验证。

5、haproxy
就是一个纯粹的高性能proxy,不处理静态资源的,所有请求统统分发到后端。

二、后端
后端就是跑ruby进程,处理RoR动态请求了。运行后端ruby进程有两种方式:

1、fcgi方式
准确的说,不能叫做fcgi方式,其实就是启动一个ruby进程,让这个ruby进程监听一个tcp/unix socket,以fcgi协议和前端通讯。所以fcgi不是指ruby进程的运行方式,而是ruby进程使用的通讯协议。这就好比你tomcat可以用 http,ajp通讯一样,tomcat自己的运行方式都一样的,只是通讯方式不一样。

fcgi方式启动ruby进程,可以使用lighttpd带的一个spawn-fcgi工具来启动(JavaEye目前采用这种方式)。

值得一提的是,apache2.2的mod_fastcgi的方式也上面还不太一样,由apache动态创建fcgi进程和管理fcgi进程,这 种方式和litespeed的lsapi面临的问题是一样的,此外apache的mod_fastcgi自己也有很多严重的bug,是一种很糟糕的部署方 式。这种糟糕的部署方式也败坏了fcgi的名声。

fastcgi只是一种协议,虽然古老,但并不是不好用,http协议也很古老。没有必要因为apache的mod_fastcgi的运行方式的问题而连带把fastcgi都一同否定了。

2、http方式
也就是用mongrel去跑ruby进程,由于mongrel实际上已经是一个简单的http server,所以也可以单独作为web server使用。mongrel现在越来越受欢迎了。

用fcgi方式还是http方式,我个人觉得区别不大,关键还是看应用的场合,一般而言,推荐的搭配是:

lighttpd + fcgi 或者 nginx +mongrel,而apache因为性能差距,而不被推荐。

JavaEye为什么用lighttpd + fcgi呢?原因如下:

1) lighttpd发展了好几年了,市场占有率也相当高,是一个经过实践检验的server,它的文档也很全;而nginx还没有经过足够的市场检验,文档也很缺乏
2) JavaEye的ruby进程和web server在一台机器上面跑,通过unix socket使用fcgi协议通讯可以避免tcp的网络开销,其通讯速度比使用tcp socket使用http协议通讯要快一些。

什么场合使用haproxy?

大规模部署,例如你的RoR应用到十几台服务器上面去,你用haproxy会更好,可以方便的添加删除应用服务器节点,proxy性能更好。

安泰资讯:Nginx–apache的有力挑战者

归档在: Linux — JACKEYJ @ 4:47 PM

nginx [engine x] is a HTTP server and mail proxy server written by me (Igor Sysoev).

nginx has been running for more than three years on many heavily loaded Russian sites including Rambler (RamblerMedia.com).
In March 2007 about 20% of all Russian virtual hosts were served or proxied by nginx.
According to Google Online Security Blog year ago nginx served or proxied about 4% of all Internet virtual hosts, although Netcraft showed much less percent.
According to Netcraft in March 2008 nginx served or proxied 1 million virtual hosts. The growing in picture and colour!
2 of Alexa US Top100 sites use nginx.
Here are some of success stories: FastMail.FM, Wordpress.com.

The latest development version is nginx-0.7.17, the change log.
The latest stable version is nginx-0.6.32, the change log.
The latest legacy stable version is nginx-0.5.37, the change log.
The sources are licensed under 2-clause BSD-like license.

The English Wiki.

One of English mailling list archives.
How to subscribe.

The Russian documenatation.

Basic HTTP features:

  • Handling of static files, index files, and autoindexing; open file descriptor cache;
  • Accelerated reverse proxying without caching; simple load balancing and fault tolerance;
  • Accelerated support without caching of remote FastCGI servers; simple load balancing and fault tolerance;
  • Modular architecture. Filters include gzipping, byte ranges, chunked responses, XSLT, and SSI. Multiple SSI inclusions within a single page can be processed in parallel if they are handled by FastCGI or proxied servers.
  • SSL and TLS SNI support.

Mail proxy server features:

  • User redirection to IMAP/POP3 backend using an external HTTP authentication server;
  • User authentication using an external HTTP authentication server and connection redirection to internal SMTP backend;
  • Authentication methods:
    • POP3: USER/PASS, APOP, AUTH LOGIN PLAIN CRAM-MD5;
    • IMAP: LOGIN, AUTH LOGIN PLAIN CRAM-MD5;
    • SMTP: AUTH LOGIN PLAIN CRAM-MD5;
  • SSL support;
  • STARTTLS and STLS support.

Tested OS and platforms:

  • FreeBSD 3 — 7 / i386; FreeBSD 5 — 7 / amd64;
  • Linux 2.2 — 2.6 / i386; Linux 2.6 / amd64;
  • Solaris 9 / i386, sun4u; Solaris 10 / i386, amd64, sun4v;
  • MacOS X / ppc, i386;

Architecture and scalability:

  • one master process and several workers processes. The workers run as unprivileged user;
  • kqueue (FreeBSD 4.1+), epoll (Linux 2.6+), rt signals (Linux 2.2.19+), /dev/poll (Solaris 7 11/99+), event ports (Solaris 10), select, and poll support;
  • various kqueue features support including EV_CLEAR, EV_DISABLE (to disable event temporalily), NOTE_LOWAT, EV_EOF, number of available data, error codes;
  • sendfile (FreeBSD 3.1+, Linux 2.2+, Mac OS X 10.5), sendfile64 (Linux 2.4.21+), and sendfilev (Solaris 8 7/01+) support;
  • accept-filter (FreeBSD 4.1+) and TCP_DEFER_ACCEPT (Linux 2.4+) support;
  • 10,000 inactive HTTP keep-alive connections take about 2.5M memory;
  • data copy operations are kept to a minimum.

Other HTTP features:

  • name- and IP-based virtual servers;
  • keep-alive and pipelined connections support;
  • flexible configuration;
  • reconfiguration and online upgrade without interruption of the client processing;
  • access log formats, bufferred log writing, and quick log rotation;
  • 4xx-5xx error codes redirection;
  • rewrite module;
  • access control based on client IP address and HTTP Basic authentication;
  • PUT, DELETE, MKCOL, COPY and MOVE methods;
  • FLV streaming;
  • speed limitation;
  • limitation of simultaneous connections from one address.

Experimental features:

  • embedded perl.

安泰信息:Debian Linux Apahe2.0.63 JBoss 4.2.2 Java 1.5 集群安装

归档在: Linux, apache, jboss, java, ubuntu — JACKEYJ @ 11:43 AM

Apahe2/JBoss/Java Cluster Guide

1 Download needed software

1.1 Jboss4.2.2 GA

Please go http://www.jboss.org/download/ to find the jboss-4.2.3.GA.zip to download.

 

1.2 Java SE 5.0 updated 16

Please go
https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-1.5.0_16-oth-JPR@CDS-CDS_Developer

And select Platform with Linux, Language with Multi-language, then download
jdk-1_5_0_16-linux-i586.bin.

 

1.3 Apache httpd 2.0.63

Please go http://httpd.apache.org/download.cgi to find httpd-2.0.63.tar.gz to download.

 

1.4 Tomcat Connectors 1.2.9

Please go http://apache.deathculture.net/tomcat/tomcat-connectors/jk/source/jk-1.2.26/ to find tomcat-connectors-1.2.26-src.tar.gz to download

 

2 Java installation

Login debian OS with root user, then create a linux user. E.g ‘deploy’.

Login with ‘deploy’ account, then upload jdk-1_5_0_16-linux-i586.bin to home directory.

chmod 755 jdk-1_5_0_16-linux-i586.bin

./ jdk-1_5_0_16-linux-i586.bin

ln –s jdk-1_5_0_16-linux-i586 jdk

Extract java and link it to jdk as above. Then modify envirement variable on profile.

cd /home/deploy

vi .bash_profile

#add for Jboss and jdk begin

JAVA_HOME=/home/deploy/jdk;export JAVA_HOME

CLASSPATH=./:/home/deploy/jdk/lib/dt.jar:/home/deploy/jdk/lib/tools.jar;export CLASSPATH

PATH=$PATH:/home/deploy/jdk/bin:/home/deploy/jdk/jre/bin;export PATH

alias l=”/bin/ls -al”

export HOME=/home/deploy

export PS1=’$PWD>’

set EDITOR=vi

set -o vi

after modify the .bash_profile and save it, then logout.

3 JBoss installation

Login with deploy account, then upload jboss-4.2.3.GA.zip to home directory.

3.1 Extract Jboss package

unzip jboss-4.2.3.zip

move jboss-4.2.3 jboss

Extract jboss-4.2.3.GA.zip to jboss-4.2.3.GA and rename the directory to jboss.

 

3.2 Copy need LIB and jar to default deployment

If Jboss need to run on cluster, copy some LIB and jar file from its ‘all’ directory to ‘default’ directory. Please execute those commands as follows:

cd ~/jboss/server/default/lib/

cp ~/jboss/server/all/lib/jgroups.jar .

cp ~/jboss/server/all/lib/jbossha.jar .

cd ~/jboss /server/default/deploy

cp -r ~/jboss/server/all/deploy/jboss-web-cluster.sar/ .

cp ~/jboss/server/all/deploy/cluster-service.xml .

cd jboss/server/default/deploy/jboss-web.deployer/META-INF/

 

3.3 Configure cluster parameter

vi jboss-server.xml

Then, for each JBoss Tomcat instance in the cluster, we need to tell it to add the jvmRoute value to its session cookies so that mod_jk can route incoming requests. Locate the <attribute> element with a name of UseJK, and set its value to true line 114 on jboss-server.xml.

 

cd ~/jboss/server/default/deploy/jboss-web.deployer/

vi server.xml

Please find the line as <Engine name=”jboss.web” defaultHost=”localhost”>, and add jvmRoute=”debian01″ to this line, different nodes should different jvmRoute name, result as follows:

<Engine name=”jboss.web” jvmRoute=”debian01″ defaultHost=”localhost”>

 

cd ~/jboss/server/default/deploy

vi cluster-service.xml

Cluster might apply UDP and TCP communication protocol, mask UDP configure node from line 39 to 80, then unmask TCP configure node.

locate line 85, find bind_addr=”thishost” and change thishost to ip address of the current host.

find start_port=”7800″ and change 7800 to 7820.

find TCPPING initial_hosts=”thishost[7800],otherhost[7800]”, change thishost to ip address of the current host,

change otherhost to ip address of another node. thange the two “7800″ to “7820″.

Sample TCP configure as follows:

         <Config>

            <TCP bind_addr=”10.5.6.44” start_port=”7820” loopback=”true”

                 tcp_nodelay=”true”

                 recv_buf_size=”20000000″   

                 send_buf_size=”640000″

                 discard_incompatible_packets=”true”          

                 enable_bundling=”false”

                 max_bundle_size=”64000″

                 max_bundle_timeout=”30″       

                 use_incoming_packet_handler=”true”

                 use_outgoing_packet_handler=”false”

                 down_thread=”false” up_thread=”false”   

                 use_send_queues=”false”                            

                 sock_conn_timeout=”300″

                 skip_suspected_members=”true”/>

            <TCPPING initial_hosts=”10.5.6.44[7820],10.5.6.246[7820]” port_range=”3″

                     timeout=”3000″

                     down_thread=”false” up_thread=”false”

                     num_initial_members=”3″/>    

            <MERGE2 max_interval=”100000″                       

                    down_thread=”false” up_thread=”false” min_interval=”20000″/>

            <FD_SOCK down_thread=”false” up_thread=”false”/>

            <FD timeout=”10000″ max_tries=”5″ down_thread=”false” up_thread=”false” shun=”true”/>

            <VERIFY_SUSPECT timeout=”1500″ down_thread=”false” up_thread=”false”/>

            <pbcast.NAKACK max_xmit_size=”60000″

                           use_mcast_xmit=”false” gc_lag=”0″

                           retransmit_timeout=”300,600,1200,2400,4800″

                           down_thread=”false” up_thread=”false”

                           discard_delivered_msgs=”true”/>

            <pbcast.STABLE stability_delay=”1000″ desired_avg_gossip=”50000″

                           down_thread=”false” up_thread=”false”

                           max_bytes=”400000″/>

            <pbcast.GMS print_local_addr=”true” join_timeout=”3000″

                        down_thread=”false” up_thread=”false”

                        join_retry_timeout=”2000″ shun=”true”

                        view_bundling=”true”/>

            <pbcast.STATE_TRANSFER down_thread=”false” up_thread=”false” use_flush=”false”/>

         </Config>

 

3.4 JNDI DataSource

cd ~/jboss/server/default/deploy

cp ~/jboss/docs/examples/jca/postgres-ds.xml .

vi postgres-ds.xml

Please modify servername, port, database name, user name and password on postgres-ds.xml.

 

3.5 Configure other node as above.

 

4 Apache2.0.x and connctors installation

It seem that debian sarge don’t support apache2.2.x version. If you install apache via apt-get method, apache might not support mod_jk. So should compile and install apache2.0.x by manual.

4.1 Upload apache package

Please upload httpd-2.0.63.tar.gz to /usr/src directory.

 

4.2 Compile & Install apache2.0.x

Login with root

cd /usr/src/

tar zxvf httpd-2.0.63.tar.gz

cd httpd-2.0.63

./configure -prefix=/usr/local/apache2 –enable-so –enable-modules=all  –enable-mods-shared=all

If debian has multiple CPU, please add -with-mpm=prefork to above command line.

make clean

make

make install

 

4.3 Complie connectors

Upload tomcat-connectors-1.2.26-src.tar.gz to /usr/src directory.

cd /usr/src/tomcat-connectors-1.2.26-src/native

./configure –with-apxs=/usr/local/apache2/bin/apxs

If debian has multiple CPU, please add –enable-prefork to above command line.

make

make install

You can see mod_jk.so on /usr/local/apache2/modules directory.

 

4.4 Apache & connectors configure

cd /usr/local/apache2/conf

Please add the line to httpd.conf.

Include conf/mod_jk.conf 

Please add mod_mk.conf on /usr/local/apache2/conf directory, its content as follows:

# Load mod_jk module

# Specify the filename of the mod_jk lib

LoadModule jk_module modules/mod_jk.so

#LoadModule jk_module modules/mod_jk-1.2.26-httpd-2.2.4.so

 

# Where to find workers.properties

JkWorkersFile conf/workers.properties

 

# Where to put jk logs

JkLogFile logs/mod_jk.log

 

# Set the jk log level [debug/error/info]

JkLogLevel info

 

# Select the log format

JkLogStampFormat  “[%a %b %d %H:%M:%S %Y]”

 

# JkOptions indicates to send SSK KEY SIZE

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

 

# JkRequestLogFormat

JkRequestLogFormat “%w %V %T”

 

# Mount your applications

JkMount /application/* loadbalancer

 

# You can use external file for mount points.

# It will be checked for updates each 60 seconds.

# The format of the file is: /url=worker

# /examples/*=loadbalancer

#JkMountFile conf/uriworkermap.properties

 

# Add shared memory.

# This directive is present with 1.2.10 and

# later versions of mod_jk, and is needed for

# for load balancing to work properly

JkShmFile logs/jk.shm

 

# Add jkstatus for managing runtime data

<Location /jkstatus/>

    JkMount status

    Order deny,allow

    Deny from all

    Allow from 127.0.0.1

</Location>

 

Please add workers.properties on /usr/local/apache2/conf directory, its content as follows:

worker.list=loadbalancer,debian01,debian02

 

# Define the first node…

worker.debian01.port=8009

worker.debian01.host=10.5.6.246

worker.debian01.type=ajp13

 

worker.debian01.lbfactor=1

#worker.debian01.local_worker=1

worker.debian01.cachesize=100

 

# Define the 2nd node…

worker.debian02.port=8009

worker.debian02.host=10.5.6.44

worker.debian02.type=ajp13

worker.debian02.lbfactor=1

#worker.debian02.local_worker=1

worker.debian02.cachesize=100

 

# Now we define the load-balancing behaviour

worker.loadbalancer.type=lb

worker.loadbalancer.balanced_workers=debian01,debian02

 

worker.loadbalancer.sticky_session=1

 

the debian01, debian02 are jvmRoute alias that defined on ~/jboss/server/default/deploy/jboss-web.deployer/server.xml.

10.5.6.246, 10.5.6.44 are ip address of two nodes.

 

4.5 Start/stop jboss and apache

Login with deploy account, then

cd ~/jboss/bin

./run.sh -b 0.0.0.0

If stop jboss, please input ctrl+c on terminal.

 

Login with root,

Cd /usr/local/apache2/bin

Start apache as follows:

./apachectl –k start

Stop apache as follows:

./apachectl stop

 

5 Deploy application on Jboss

2008年09月16日

安泰资讯:windows平台下的opennms

归档在: Linux — JACKEYJ @ 8:47 AM

       OpenNMS 从1.3.8起,提供了Windows的运行支持。虽然还存在一些问题,但是在Windows XP以及以上版本上安装运行OpenNMS还是可行的。
1       Install the JDK
n         从SUN网站下载Java 5 (1.5)或者以上JDK版本(java.sun.com),并安装
n         设置PATH和CLASSPATH
2       Install PostgreSQL
下载PostgreSQL for windows v8.2.6-2,并安装。(注意,文件分区格式要采用NTFS)
n         缺省数据库是:postgres,用户名是:postgres,密码自己设定(postgres是系统用户)
n         使用数据库提供的pgAdmin III 工具,针对postgres用户,新建数据库opennms
3       Install Jicmp
JAVA从来没有提供良好的icmp工具,OpenNMS 从1.3.6版本以来,Jicmp需要单独安装。
下载Jicmp(http://www.opennms.org/index.php/jicmp),并安装,并在环境变量Path中添加“JICMP_HOME”变量。
4       【可选】Install Jrrd
OpenNMS 从1.3.6版本以来,Jrrd需要单独安装。
下载Jrrd(http://www.opennms.org/index.php/jrrd,官方网站上没有提供Widows版本)并安装,并在环境变量Path中添加“JRRD_HOME”变量。
5       Install OpenNMS
准备工作:
n         下载opennms-installer-1.5.90.jar
n         从“服务”管理窗口或者“程序”启动PostgreSQL数据库服务
软件安装:
使用“JAVA(TM)2 Platform Standard Edition Binary”打开opennms-installer-1.5.90.jar,执行安装程式。安装过程中需要提供下面参数:
n         选择JDK Home
n         OpenNMS安装路径$OPENNMS_HOME
n         数据库连接参数
6       配置OpenNMS
6.1    log4j.properties
原始不是Windows下的,依据现有的安装环境进行修改:修改方法用$OPENNMS_HOME全文替换/opt/OpenNMS
$OPENNMS_HOME \contrib\qosdaemon\qos_example_configuration\opennms\log4j.properties
把修改后的文件复制到$OPENNMS_HOME \jetty-webapps\opennms\WEB-INF
6.2    其他配置
通过以上配置,系统已经能够正常运行了。根据情况自己进行其他配置。
7       Run OpenNMS
n         转至目录$OPENNMS_HOME\bin下,运行:opennms.bat start
n         打开IE,输入http://localhost:8980/opennms,用户名/密码都是admin
8       补充
OpenNMS是世界上第一个用开放原始码模式开发的企业级网络管理系统,通过这个文章,希望更多的爱好者能够使用它。当当网购书

2008年06月20日

grub引导恢复

归档在: Linux, ubuntu — JACKEYJ @ 11:31 AM

最近因为重新安装xp,结果原来的ubuntu的grub引导没有了。于是尝试使用live cd进行恢复。

步骤:

1. 先使用live cd启动

2. 在console中输入

grub

grub>find /boot/grub/stage1

返回结果:(hd0,3)

3. 执行重建引导

grub>root (hd0,3)

grub>setup (hd0)

4. 重启就可以了

下一页 »

Powered by ZJANT