存档

2008年8月 的存档

java调用awt做图片验证码显示的问题解决

2008年8月25日 评论已被关闭

错误症状:

500 Servlet Exception
java.lang.InternalError: Can’t connect to X11 window server using ‘localhost:0.0’
as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:134)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
    at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1041)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
    at java.lang.Thread.run(Thread.java:534)

google了半天,试过了安装xorg-x11-Xvfb包,export DISPLAY=:0等等,无奈,没有解决。
最后终于找到了解决方案:
可以在java的jvm上 加入参数   –Djava.awt.headless=true

分类: java 标签:

mysql OLD_PASSWORD’s problem

2008年8月25日 评论已被关闭

In my mysql slave and master’s
i meet a problem:
[MysqlDb.connectDB]java.sql.SQLException: Client does not support authentication protocol requested by server; consider upgrading MySQL client

this is a problem of mysql update version 4.1 and more!

to sovle it , we can do this

1st:
mysql> SET PASSWORD FOR
    -> ‘some_user’@’some_host’ = OLD_PASSWORD(‘newpwd’);
2nd:
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD(‘newpwd’)
    -> WHERE Host = ‘some_host’ AND User = ‘some_user’;
mysql> FLUSH PRIVILEGES;

分类: database 标签:

learn shell check_tcpconn.sh from nagios

2008年8月25日 评论已被关闭

#check_tcpconn.sh
# warning value
W=1500
# critical value
C=2190
if [ -f /proc/net/tcp6 ]
        then
                TCP_FILE6=”/proc/net/tcp6″
fi
if [ -f /proc/net/tcp ]
        then
                TCP_FILE=”/proc/net/tcp”
fi
cat $TCP_FILE6 $TCP_FILE > /tmp/tcpstat
awk -v TOTAL_W=”$W” -v TOTAL_C=”$C” ‘BEGIN{ ESTABLISHED=TIME_WAIT=SYN_RECV=TOTAL=0}
                {if($4 ~/01/) {ESTABLISHED++ ; TOTAL++} else if($4 ~/06/) {TIME_WAIT++; TOTAL++} else if($4 ~/03/) {SYN_RECV++; TOTA
L++} else TOTAL++ }
                END{
                if (TOTAL < TOTAL_W)
                        {printf “OK CONN %s ESTABLISHED  %s TIME_WAIT  %s SYN_RECV  %s  TOTAL|CONN,%s,%s,%s,%s;”,ESTABLISHED,TIME_WA
IT,SYN_RECV,TOTAL,ESTABLISHED,TIME_WAIT,SYN_RECV,TOTAL ; exit 0}
                else if (TOTAL < TOTAL_C)
                        {printf “WARNING CONN %s ESTABLISHED  %s TIME_WAIT  %s SYN_RECV  %s  TOTAL|CONN,%s,%s,%s,%s;”,ESTABLISHED,TI
ME_WAIT,SYN_RECV,TOTAL,ESTABLISHED,TIME_WAIT,SYN_RECV,TOTAL ; exit 0}
                else
                        {printf “CRITICAL CONN %s ESTABLISHED  %s TIME_WAIT  %s SYN_RECV  %s  TOTAL|CONN,%s,%s,%s,%s;”,ESTABLISHED,T
IME_WAIT,SYN_RECV,TOTAL,ESTABLISHED,TIME_WAIT,SYN_RECV,TOTAL ; exit 0}

                }’ /tmp/tcpstat

this script check  /proc/net/tcp , u can find tcp connect status  .

cat /proc/net/tcp
enum {
  TCPF_ESTABLISHED = (1 << 1),
  TCPF_SYN_SENT  = (1 << 2),
  TCPF_SYN_RECV  = (1 << 3),
  TCPF_FIN_WAIT1 = (1 << 4),
  TCPF_FIN_WAIT2 = (1 << 5),
  TCPF_TIME_WAIT = (1 << 6),
  TCPF_CLOSE     = (1 << 7),
  TCPF_CLOSE_WAIT = (1 << 8),
  TCPF_LAST_ACK  = (1 << 9),
  TCPF_LISTEN    = (1 << 10),A
  TCPF_CLOSING   = (1 << 11),B
};

分类: OpenSource 标签:

ffmpeg 安装常见问题的解决

2008年8月18日 评论已被关闭

网上广为流传的ffmpeg支持3gp解析的方法已经过时了,
amr-wb   amr-nb
比如下载26204-510.zip 和 26104-510.zip 文件到
libavcodec/amrwb_float/
libavcodec/amr_float/

现在升级后的正确安装方法是
到http://ftp.penguin.cz/pub/users/utx/amr/下载相关版本,来安装
或者到官网下载新版本
amr-wb
http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-700.zip
amr-nb
http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-610.zip
单独进行安装即可

其他支持比较简单,不容易出错,这样ffmpeg的一切准备就绪,./configure 正常

# make
gcc -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I. -I”/home/yujingtao/soft/ffmpeg” -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -fasm -std=c99 -fomit-frame-pointer -pthread -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wcast-qual -Wwrite-strings -O3 -fno-math-errno       -c -o libavdevice/v4l.o libavdevice/v4l.c
In file included from libavdevice/v4l.c:32:
/usr/include/linux/videodev.h:55: error: syntax error before “ulong”
/usr/include/linux/videodev.h:71: error: syntax error before ‘}’ token
libavdevice/v4l.c: In function `grab_read_header’:
libavdevice/v4l.c:77: error: storage size of ‘tuner’ isn’t known
libavdevice/v4l.c:141: error: invalid application of `sizeof’ to incomplete type `video_tuner’
libavdevice/v4l.c:148: error: invalid application of `sizeof’ to incomplete type `video_tuner’
libavdevice/v4l.c:77: warning: unused variable `tuner’
make: *** [libavdevice/v4l.o] 错误 1

试过了多种解决方法,比如添加
#include <sys/types.h>

但是还是有问题,经过不懈的努力终于找到问题所在:
vi /usr/include/linux/videodev.h

rangelow, rangehigh;      /* Tuner range */
把  ulong rangelow, rangehigh;      /* Tuner range */
改为:
     unsigned long rangelow, rangehigh;      /* Tuner range */

        

分类: OpenSource 标签:

二进制安装mysql的遇到的一些问题

2008年8月14日 评论已被关闭

据说使用Intel的CC编译器编译的mysql要比比gcc编译的性能高,所以可以下载这个版本的二进制mysql安装包

Linux (non RPM, Intel C/C++ compiled, glibc-2.3) downloads

MySQL is pleased to make available offerings of the MySQL Community Server
compiled with the Intel CC compiler. Internal tests show that editions of
the MySQL Community Server compiled with the Intel CC compiler exhibit
faster performance on Intel hardware than those compiled with the standard
gcc compiler. Feedback is welcome.

二进制方式安装mysql,默认安装目录为 /usr/local/mysql
所以需要修改相关配置。
如:mysql 安装在/home/mysql目录
可以编辑 /etc/my.cnf  增加:
basedir         = /home/mysql
datadir         = /home/mysql/data
启动mysql,这是如果提示:
/mysqld_safe: line 199: my_print_defaults: command not found
./mysqld_safe: line 204: my_print_defaults: command not found
The file /usr/local/mysql/bin/mysqld doesn’t exist or is not executable
Please do a cd to the mysql installation directory and restart
this script from there as follows:
./bin/mysqld_safe.
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more
information
[1]+  Exit 1                  ./mysqld_safe
提示/usr/local/mysql/bin/mysqld 找不到
可以使出杀手锏:
ln -s /home/mysql/ /usr/local/mysql
另外在安装的时候
要在修改完my.cnf之后再执行
scripts/mysql_install_db –user=mysql

配置主从服务器中的问题
遇到了:
080814 12:01:22 [ERROR] Error reading packet from server: Could not find first log file name in binary log index file ( server_errno=1236)
080814 12:01:22 [ERROR] Got fatal error 1236: ‘Could not find first log file name in binary log index file’ from master when reading data from binary log
080814 12:01:22 [Note] Slave I/O thread exiting, read up to log ‘mysql-bin.024’, position 79

说明没有指定二进制log文件
解决方式:
解决
change master to \
master_log_file=’mysql-bin.000021′,\
master_log_pos=882
指定log_file即可。

分类: OpenSource 标签:

编程语言搜索排名 Python第六

2008年8月13日 评论已被关闭

2008年8月。各大搜索引擎如google,msn,yahoo等统计计算出的结果,显示编程语言的关注程度,可见Python排名上升很快。

详细请见来源 tiobe

Position
Aug 2008
Position
Aug 2007
Delta in Position Programming
Language
Ratings
Aug 2008
Delta
Aug 2007
Status
1 1 Java 21.571% -0.20%   A
2 2 C 16.178% +0.48%   A
3 3 (Visual) Basic 10.857% +0.21%   A
4 4 C++ 10.057% -0.05%   A
5 5 PHP 9.349% -0.35%   A
6 8 Python 4.975% +2.23%   A
7 6 Perl 4.694% -0.63%   A
8 7 C# 3.697% -0.29%   A
9 10 Ruby 2.920% +1.01%   A
10 9 JavaScript 2.892% +0.32%   A
11 14 Delphi 2.732% +1.51%   A
12 13 D 1.357% +0.11%   A
13 11 PL/SQL 0.679% -1.15%   A-
14 12 SAS 0.549% -0.84%   B
15 PowerShell 0.440% +0.44%   B
16 24 Pascal 0.416% +0.00%   B
17 18 Lisp/Scheme 0.379% -0.21%   B
18 15 Lua 0.373% -0.27%   B
19 16 COBOL 0.358% -0.24%   B
20 23 ActionScript 0.355% -0.07%   B

Long term trends

The long term trends for the top 10 programming languages can be found in the
line diagram below.

分类: others 标签:

warning, got duplicate tcp line.

2008年8月11日 评论已被关闭

today When I run netstat -lnt in a my Server
I find this in my screen.

warning, got duplicate tcp line.
warning, got duplicate tcp line.
warning, got duplicate tcp line.

To fix this problem, open /etc/sysctl.conf and
# vi /etc/sysctl.conf
Append or modify text as follows:
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_tw_recycle = 0

#sysctl -p

or you can do this:
#echo 0 > /proc/sys/net/ipv4/net.ipv4.tcp_tw_reuse = 0
#echo 0 > /proc/sys/net/ipv4/net.ipv4.tcp_tw_recycle = 0

分类: OpenSource 标签:

tar 解压部分文件

2008年8月6日 评论已被关闭

tar命令大家都很熟悉了
这里整理一下部分解压,只解压出需要的文件,
这样就解决了tar包过大的情况下,解压速度太慢、解压后占用空间过大的问题
几个步骤:
查看tar包内包含的文件,如果已经知道这一步可免
tar -tzvf u2file.tar.gz
-rw-r–r– user/user 45489156 2008-08-04 23:59:46 foder/access.log.20080804
-rw-r–r– user/user 37469223 2008-08-05 23:59:46 foder/access.log.20080805

#解压单个文件
tar -zxvf u2file.tar.gz foder/access.log.0805

#解压多个文件
tar -zxvf u2file.tar.gz foder/access.log.*

#解压到指定目录
tar -xzvf u2file.tar.gz foder/access.log.0805 -C /new/dir/    # -C 指定解压到的目录.

分类: OpenSource 标签:

resin jsp auto-compile

2008年8月5日 评论已被关闭

因为resin的自动编译及热部署的特性颇受大家的欢喜,这里总结一下resin2.x下关于自动编译的问题

Resin中 “resin.conf” 自动编译的设置:

1.class-update-interval
  检测servlet更新的时间间隔,默认值2秒
  使用:在  <http-server>标签下:
  <class-update-interval>2s</class-update-interval>
 
2.config-update-interval
  检测配置文件configuration更新的时间间隔,默认值为class-update-interval指定的值 
  使用:在  <http-server>标签下:
  <config-update-interval>2s</config-update-interval> 
 
3.jsp-update-interval
  检测jsp文件的更新时间:默认值为class-update-interval指定的值 
  使用:
  <jsp jsp-update-interval=’300s’ precompile=’true’ static-encoding=’true’ recompile-on-error=’true’/>
  其中: precompile 预编译
         static-encoding  允许静态字符编码,默认为true

一般来讲生产环境还是要加大resin对class文件的变化检测的时间间隔,或者干脆不允许扫描。
如果以上方法都无效的话,只能使出俺的必杀技–在jsp标签中添加这句话 auto-compile=’false’ ,意为不允许编译!

具体请见resin的官网相关介绍!
http://caucho.com/resin-2.1/ref/app-config.xtp#config-update-interval
 
<class-update-interval>s</class-update-interval>

jsp-update-interval
auto-compile

<jsp auto-compile=’false’ jsp-update-interval=’300s’ precompile=’true’ static-encoding=’true’ recompile-on-error=’true’/>

class-update-interval
    Resin 1.1
Interval in seconds between checking for servlet updates. For development, this can be set to 0 or to a small number to pick up new servlet versions quickly. For deployment, class-update-interval can be large to avoid the overhead of checking for updates.
The default value is 2 seconds.

config-update-interval
    Resin 2.0

Interval in seconds between checking for configuration updates. For development, this can be set to 0 or to a small number to pick up new configuration file versions quickly. For deployment, config-update-interval can be large to avoid the overhead of checking for updates.

The default value is the value of class-update-interval.

分类: resin 标签:

压力测试工具–NeoLoad–Web Site Load Testing

2008年8月3日 评论已被关闭

谈及压力测试工具,一般人都会想到 HP LoadRunner 这个庞然大物,偶然间发现了这样一个web压力测试工具–NeoLoad
NeoLoad 作为一款商业压力测试软件,功能上确实很好、很强大!

NeoLoad的一些特点:

1.可以在高负载下预告性能
2.可以模拟各种环境进行web压力测试
3.能够在生产环境上线之间阻止由于软件、网络、代码甚至硬件的瑕疵带来的种种问题
4.没有像LoadRunner那样复杂的脚本
5.友好的用户界面
6.简单快捷的结果分析

官方站点: http://www.neotys.com/

下面是NeoLoad网站的一些介绍:

NeoLoad is a simple to use, cost-effective stress tool that measures the performance of your web application, identifying potentially damages issues before they occur.

EASY – POWERFUL – COST-EFFECTIVE
    *  No script language
    * A clear and user friendly interface
    * Simple and fast results analysis

Web Site Load Testing:

    * Predicts performance during high loads.
    * Identifies web site issues in a simulated environment.
    * Helps to prevent problems (any flawed software, network, code or even hardware)
     before they occur in real situations.

You can download Free NeoLoad evaluation from here.
http://www.neotys.com/load-testing-tool/download.html
The evaluation version of the NeoLoad software has the following limitations:

    * Evaluation limited to 30 days,
    * Maximal number of simulated Virtual Users: 10,
    * Minimal Thinktime value (time between page clicks): 3 seconds.

下面是一些截图:
指定压力测试的方式:持续线程数,递增,抖动
neo3.png

neo1.png

neo2.png

分类: OpenSource 标签: