posts - 88, comments - 3, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理


steps:
1. download maven project src code
2. cd project root dir & run "mvn eclipse:eclipse"
3. import it as eclipse java prject    

step2 will generate .classpath & .project file

posted @ 2012-06-27 15:56 Milo的海域 阅读(797) | 评论 (0)编辑 收藏

1. 配置

2. 命令行选项

选项-d 用来打开debug模式
选项-v 用来打开verbose模式
选项-f 用来打开强制选项,会强制发生log rotate即使不满足条件

debug模式跟verbose的区别就是: debug模式是dry-run版本的verbose模式,一般用来调试新加的logroate配置文件, 比如:

 /usr/sbin/logrotate /etc/logrotate.d/NEWCONFIG -df
 /usr/sbin/logrotate /etc/logrotate.d/NEWCONFIG -vf

posted @ 2012-06-26 16:07 Milo的海域 阅读(299) | 评论 (0)编辑 收藏


Perl里面的predefined vars
perlvar


用perldoc perlvar 可以结合实例来了解更详细的信息。

下面针对$@写了个perl alarm的例子
#!/usr/bin/perl

my $timeout = 5;

$SIG{ALRM} = sub {
    
die "alarm\n";
};

eval {
    
alarm $timeout;
    
sleep(6);
    
alarm 0;
};

if ($@) {
    
print "timeout\n";
}
else {
    
print "not timeout\n";
}



posted @ 2012-06-21 17:10 Milo的海域 阅读(296) | 评论 (0)编辑 收藏

zane昨天推荐个项目依赖分析的工具: http://www.jboss.org/tattletale

JBoss Tattletale is a tool that can help you get an overview of the project you are working on
or a product that you depend on.

The tool will provide you with reports that can help you

* Identify dependencies between JAR files
* Find missing classes from the classpath
* Spot if a class/package is located in multiple JAR files
* Spot if the same JAR file is located in multiple locations
* With a list of what each JAR file requires and provides
* Verify the SerialVersionUID of a class
* Find similar JAR files that have different version numbers
* Find JAR files without a version number
* Find unused JAR files
* Identify sealed / signed JAR archives
* Locate a class in a JAR file
* Get the OSGi status of your project

使用方法
java -Xmx512m -jar tattletale.jar [-exclude=<excludes>] <scan-directory> [output-directory]

注意事项
tattletale只分析jar包之间的依赖,需要自己把所有的class文件打包放入scan-directory,然后把依赖的lib也放入同个目录

posted @ 2012-06-13 16:13 Milo的海域 阅读(696) | 评论 (0)编辑 收藏


[abc]     A single character: a, b or c
[^abc]     Any single character but a, b, or c
[a-z]     Any single character in the range a-z
[a-zA-Z]     Any single character in the range a-z or A-Z
^     Start of line
$     End of line
\A     Start of string
\z     End of string
.     Any single character
\s     Any whitespace character
\S     Any non-whitespace character
\d     Any digit
\D     Any non-digit
\w     Any word character (letter
, number, underscore)
\W     Any non-word character
\b     Any word boundary character
()     Capture everything enclosed
(a|b)     a or b
a?     Zero or one of a
a*     Zero or more of a
a+     One or more of a
a{
3}     Exactly 3 of a
a{
3,}     3 or more of a
a{
3,6}     Between 3 and 6 of a

posted @ 2012-06-13 16:06 Milo的海域 阅读(208) | 评论 (0)编辑 收藏

A tool cloc which wrote by perl could help u do that:
http://cloc.sourceforge.net/

prompt> cloc perl-5.10.0.tar.gz
    
4076 text files.
    
3883 unique files.                                          
    
1521 files ignored.

http://cloc.sourceforge.net v 
1.50  T=12.0 s (209.2 files/s, 70472.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Perl                          
2052         110356         130018         292281
C                              
135          18718          22862         140483
C/C++ Header                   
147           7650          12093          44042
Bourne Shell                   
116           3402           5789          36882
Lisp                             
1            684           2242           7515
make                             
7            498            473           2044
C++                             
10            312            277           2000
XML                             
26            231              0           1972
yacc                             
2            128             97           1549
YAML                             
2              2              0            489
DOS Batch                       
11             85             50            322
HTML                             
1             19              2             98
-------------------------------------------------------------------------------
SUM:                          
2510         142085         173903         529677
-------------------------------------------------------------------------------

Here is command line example:
Usage: cloc-1.56.pl [options] <file(s)/dir(s)> | <set 1> <set 2> | <report files>

posted @ 2012-05-31 15:32 Milo的海域 阅读(286) | 评论 (0)编辑 收藏

Sometime mailbox disallows u upload file exceed some limitation. you can split it before upload. here is one example:

create test file
touch file1 file2;
echo 1 > file1;
echo 2 > file2;
tar zvcf old.tar.gz file1 file2;

split file to segment with size as u wished
split -b 50 old.tar.gz;

restore file from segments
cat xa* > new.tar.gz;

verify the restore
md5sum old.tar.gz new.tar.gz

Generally, the check result should be same.


posted @ 2012-05-30 17:38 Milo的海域 阅读(261) | 评论 (0)编辑 收藏

In many cases, binaries can no longer dump core after calling setuid(). 
Under Linux it is possible to re-enable this with a system call.

e.g.

+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
 #ifdef HAVE_purify
 
#define IF_PURIFY(A,B) (A)
 
#else
@@ 
-1362,6 +1366,10 @@
     sql_perror(
"setuid");
     unireg_abort(
1);
   }
+#ifdef __linux__
+  /* inform kernel that process is dumpable */
+  prctl(PR_SET_DUMPABLE,1,0,0,0);
+#endif /* __linux__ */
 
#endif
Manual of prctl
       PR_SET_DUMPABLE
              (Since Linux 
2.4) Set the state of the flag determining whether core dumps are produced for this process  upon  delivery  of  a
              signal  whose  default  behaviour  is  to  produce a core dump.  (Normally this flag is set for a process by default
, but it is
              cleared when a set-user-ID or set-group-ID program is executed and also by various system calls that  manipulate  process  UIDs
              and  GIDs).  In kernels up to and including 
2.6.12, arg2 must be either 0 (process is not dumpable) or 1 (process is dumpable).
              Since kernel 
2.6.13, the value 2 is also permitted; this causes any binary which normally would not  be  dumped  to  be  dumped
              readable by root only.  (See also the description of /proc/sys/fs/suid_dumpable in proc(5).)


Ref: http://bugs.mysql.com/bug.php?id=21723
Some files about linux core dump:
/proc/sys/fs/suid_dumpable
/etc/profile
/etc/security/limits.conf
/proc/sys/kernel/core_pattern

posted @ 2012-05-30 15:32 Milo的海域 阅读(400) | 评论 (0)编辑 收藏

0.5版本的sysbench已经支持multi-table

Download src code
bzr branch lp:sysbench

make后就可以执行了

Percona对这个版本的sysbench的参数有个不错的wiki page:
http://www.percona.com/docs/wiki/benchmark:sysbench:olpt.lua

下面这个文章对0.5的sysbench有个比较全面的介绍:
./sysbench --mysql-host=$host1 --mysql-port=3306 --mysql-user=*** --mysql-password=*** --test=/path/to/sysbench/tests/db/oltp.lua --oltp-tables-count=$oltp_table_num --num-threads=$num_thread --max-requests=0 --max-time=$max_time prepare

./sysbench --mysql-host
=$host1 --mysql-port=3306 --mysql-user=*** --mysql-password=*** --test=/path/to/sysbench/tests/db/oltp.lua --oltp-tables-count=$oltp_table_num --num-threads=$num_thread --max-requests=0 --max-time=$max_time run


补充下,如果要使用 --max-time这个参数, 需要配合--max-requests=0。
  --max-requests=N            limit for total number of requests [10000]
如果N=0将取消max-requests的限制

posted @ 2012-05-14 16:10 Milo的海域 阅读(791) | 评论 (0)编辑 收藏

MySQL 5.5多出了两个新数据库 information_schema performance_schema

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
| performance_schema | 
| test               | 
+--------------------+
   

但是用mysqldump去备份这两个数据库的时候都会报错

mysqldump: Got error: 1044: Access denied for user 'root'@'localhost' to database 'information_schema' when using LOCK TABLES

mysqldump: Got error: 
1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES

用--all-databases备份时也不会备份这两个数据库
官方文档里解释到:
http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html

总结一下,如果一定要用mysqldump去备份这两个数据库不是不可以,但是得disable lock tables。 我用的是:
--database information_schema --lock-tables=0


posted @ 2012-05-11 14:01 Milo的海域 阅读(1094) | 评论 (1)编辑 收藏

仅列出标题
共9页: 上一页 1 2 3 4 5 6 7 8 9 下一页