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的海域 閱讀(817) | 評論 (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的海域 閱讀(313) | 評論 (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的海域 閱讀(312) | 評論 (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的海域 閱讀(718) | 評論 (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的海域 閱讀(226) | 評論 (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的海域 閱讀(307) | 評論 (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的海域 閱讀(280) | 評論 (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的海域 閱讀(420) | 評論 (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的海域 閱讀(810) | 評論 (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的海域 閱讀(1115) | 評論 (1)編輯 收藏

          僅列出標題
          共9頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 
          主站蜘蛛池模板: 舟山市| 蒙城县| 百色市| 噶尔县| 大新县| 普兰店市| 新化县| 蓝田县| 临江市| 梁河县| 马边| 清徐县| 福建省| 昆山市| 武隆县| 伊通| 汪清县| 读书| 岫岩| 清河县| 兴安县| 石首市| 弋阳县| 南京市| 甘泉县| 阿瓦提县| 渝北区| 武陟县| 阿图什市| 禹州市| 台中市| 云梦县| 称多县| 怀远县| 梁平县| 定结县| 临夏市| 汉沽区| 左云县| 喀喇沁旗| 天长市|