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

ssh-copy-id 避免ssh输入密码的用法:

[root@hengtiandesk118 .ssh]# ssh-copy-id -i id_rsa.pub 10.1.186.51
10
Warning: Permanently added '
10.1.186.51' (RSA) to the list of known hosts.
root@
10.1.186.51's password: 
Now try logging into the machine
, with "ssh '10.1.186.51'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

[root@hengtiandesk118 .ssh]# ssh 10.1.186.51
Last login: Thu May 
10 18:33:55 2012 from 10.5.4.201
[root@xen186v01 ~]#

这个脚本只要装了openssh-clients就可以用了。

以前都是手动复制粘贴的...

posted @ 2012-05-11 09:58 Milo的海域 阅读(310) | 评论 (0)编辑 收藏

原来ssh可以这样用

1. remote file copy
[root@xen74v01 ~]# cat test.pl
#!/usr/bin/perl
print 
"eth0.74"=~/(\w+)/;
print "\n";
[root@xen74v01 ~]# cat test.pl | ssh 10.1.74.76 'cat - > /tmp/test.pl'

拷贝文件时,如果文件很大,又不想影响网络IO可以用pv工具进行流量控制
pv -L10m test.pl | ssh 10.1.74.76 'cat - > /tmp/test.pl'
这里pv的行为跟cat比较类似,但是支持IO流量控制,这里设置10M/s.

2. local script remote execute
[root@xen74v01 ~]# cat test.pl
#!/usr/bin/perl
print 
"eth0.74"=~/(\w+)/;
print "\n";
[root@xen74v01 ~]# perl test.pl
eth0
[root@xen74v01 ~]# cat test.pl | ssh 10.1.74.76 'perl'
eth0
[root@xen74v01 ~]# ssh 10.1.74.76 'perl' < test.pl
eth0

这样就不用把脚本拷贝到远端去执行了

参考:
http://linux.icydog.net/ssh/piping.php
http://www.ivarch.com/programs/quickref/pv.shtml
http://www.mysqlperformanceblog.com/2009/05/20/hint-throttling-xtrabackup/

posted @ 2012-05-09 17:13 Milo的海域 阅读(3168) | 评论 (0)编辑 收藏

1. Tutorial
http://net-snmp.sourceforge.net/wiki/index.php/Tutorials

2. Config & start agent
 snmpconf

3. snmpwalk example
 snmpwalk -v2c -c public 10.1.74.51

4. check MIB modules
 snmptranslate -Dinit_mib .1.3 2>&1 |grep MIBDIR

5. extending MIB Module
http://net-snmp.sourceforge.net/wiki/index.php/TUT:Writing_a_MIB_Module
    a. download net-snmp src code
    b. MIB definition
    c. mib2c (in net-snmp-perl)
    d. make & make install
    e. edit snmpd conf & restart agent
    f. snmpwalk to verify

posted @ 2012-05-07 16:57 Milo的海域 阅读(263) | 评论 (0)编辑 收藏

Graphviz: a Text to Graph tool

Download:
 http://www.graphviz.org/Download..php
Install:
http://www.graphviz.org/Download_linux_rhel.php

Document:
http://www.graphviz.org/Documentation.php

Example:
$ cat cluster.dot
digraph G {

        subgraph cluster_0 {
                style
=filled;
                color
=lightgrey;
                node [style
=filled,color=white];
                a0 
-> a1 -> a2 -> a3;
                label 
= "process #1";
        }

        subgraph cluster_1 {
                node [style
=filled];
                b0 
-> b1 -> b2 -> b3;
                label 
= "process #2";
                color
=blue
        }
        start 
-> a0;
        start 
-> b0;
        a1 
-> b3;
        b2 
-> a3;
        a3 
-> a0;
        a3 
-> end;
        b3 
-> end;

        start [shape
=Mdiamond];
        
end [shape=Msquare];
}

$ dot 
-Tpng cluster.dot -o cluster.png
$ gnome
-open cluster.png



More examples:
http://www.graphviz.org/Gallery.php

posted @ 2012-05-07 14:47 Milo的海域 阅读(508) | 评论 (0)编辑 收藏

iozone 是一个开源的文件系统benchmark 测试工具。可用来检测当前或者指定磁盘的读写性能。
http://www.iozone.org/

安装
先确保rpmforge repository源已经安装。具体参考:
http://www.blogjava.net/miaoyachun/archive/
2012/02/03/369319.html

然后直接yum安装

 yum install iozone

测试
iozone  -i 0 -r 32 -s 2097152
        Iozone: Performance Test of File I/O
                Version $Revision: 
3.394 $
                Compiled for 
64 bit mode.
                Build: linux 

        Contributors:William Norcott
, Don Capps, Isom Crawford, Kirby Collins
                     Al Slater
, Scott Rhine, Mike Wisner, Ken Goss
                     Steve Landherr
, Brad Smith, Mark Kelly, Dr. Alain CYR,
                     Randy Dunlap
, Mark Montague, Dan Million, Gavin Brebner,
                     Jean-Marc Zucconi
, Jeff Blomberg, Benny Halevy, Dave Boone,
                     Erik Habbinga
, Kris Strecker, Walter Wong, Joshua Root,
                     Fabrice Bacchella
, Zhenghua Xue, Qin Li, Darren Sawyer.
                     Ben England.

        Run began: Wed Apr 
25 19:36:55 2012

        Record Size 
32 KB
        File size set to 
2097152 KB
        Command line used: iozone -i 
0 -r 32 -s 2097152
        Output is in Kbytes/sec
        Time Resolution 
= 0.000001 seconds.
        Processor cache size set to 
1024 Kbytes.
        Processor cache line size set to 
32 bytes.
        File stride size set to 
17 * record size.
                                                            random  random    bkwd   record   stride                                   
              KB  reclen   write rewrite    read    reread    read   write    read  rewrite     read   fwrite frewrite   fread  freread
         
2097152      32  844758 2001670                                                                                            

iozone test complete.

posted @ 2012-04-26 10:49 Milo的海域 阅读(466) | 评论 (0)编辑 收藏

http://www.owengriffin.com/posts/2010/04/22/Writing_PHP_applications_with_Maven_and_Jetty.html
实验了下,是可以的。不过用的maven3

posted @ 2012-04-11 14:32 Milo的海域 阅读(326) | 评论 (0)编辑 收藏

当innobackupex 做全备的时候(my version 1.6.5), 当备份到MyISAM数据时, innobackupex 会flush tables with read lock, 来禁止MyISAM的写操作. (假设没有--no-lock选项)

sub backup {

    
if (!$option_incremental && !$option_no_lock) {
        
# make a prep copy before locking tables, if using rsync
        backup_files(1);

        
# flush tables with read lock
        mysql_lockall();
    }

    
if ($option_slave_info) {
        write_slave_info();
    }

}

sub mysql_lockall {

    
if (compare_versions($mysql_server_version, '4.0.22'== 0
        
|| compare_versions($mysql_server_version, '4.1.7'== 0) {
        
# MySQL server version is 4.0.22 or 4.1.7
        mysql_send "COMMIT;";
        mysql_send 
"FLUSH TABLES WITH READ LOCK;";
    } 
else {
        
# MySQL server version is other than 4.0.22 or 4.1.7
        mysql_send "FLUSH TABLES WITH READ LOCK;";
        mysql_send 
"COMMIT;";
    }
    write_binlog_info;


}

但是如果备份的时候还有很重的workload, "flush tables with read lock" 可能会比较耗时. 这里参考了:

http://www.mysqlperformanceblog.com/2010/04/24/how-fast-is-flush-tables-with-read-lock/

看了下--no-lock的选项说明:

    --no-lock
        Use this option to disable table lock with 
"FLUSH TABLES WITH READ
        LOCK
". Use it only if ALL your tables are InnoDB and you DO NOT CARE
        about the binary log position of the backup.

如果我们能保证workload仅仅是innodb相关的,我们可以使用这个选项。

记得在1.5版本的时候,使用--no-lock选项会导致xtrabackup_slave_info没有保存备份时的logfile & pos. 这个问题在1.6.5被解决了

    if ($option_slave_info) {
        write_slave_info();
    }

xtrabackup_slave_info & xtrabackup_binlog_info文件在1.5版本是在mysql_lockall函数里更新的。但是新版本已经把write_slave_info提到mysql_lockall外面了。

posted @ 2012-04-10 17:19 Milo的海域 阅读(655) | 评论 (0)编辑 收藏

Some time we may not want export complex hash to console but file, we can do like this to dump to file by var_export
<?php

$a = array('abc'=>"123");

# var dump
var_dump($a);

# var_export
echo var_export($a);

# export to file
$b = var_export($a, true);
error_log($b."\n", 3, "/tmp/ymiao.log");  

Result:
cat /tmp/ymiao.log
array (
  'abc' 
=> '123',
)

posted @ 2012-04-10 10:54 Milo的海域 阅读(358) | 评论 (0)编辑 收藏

When restore by xtrabackup '--copy-back' with version 1.6.4, you may get error:
IMPORTANT: Please check that the copy-back run completes successfully.
           At the end of a successful copy-back run innobackupex-
1.6.4
           prints 
"completed OK!".

Original data directory is not empty! at innobackupex-
1.6.4 line 544.

when read those lines we found that:
    # check that original data directories exist and they are empty
    if_directory_exists_and_empty($orig_datadir
, "Original data");
    if_directory_exists_and_empty($orig_ibdata_dir, "Original InnoDB data");
    if_directory_exists_and_empty($orig_iblog_dir, "Original InnoDB log");

Google for reason for this check and find it mentioned in:
http://www.mysqlperformanceblog.com/2011/12/19/percona-xtrabackup-1-6-4/

innobackupex did not check that MySQL datadir was empty before –copy-back was run. With this bug fix,
innobackupex will now error out of the –copy-back operation if the destination is not empty
, avoiding
potential data loss or a strang combination of a restored backup and previous data. Bug Fixed: #
737569 (Valentine Gostev)

posted @ 2012-04-03 13:01 Milo的海域 阅读(675) | 评论 (0)编辑 收藏

1. install bzr tool, ref http://dev.mysql.com/doc/refman/5.1/en/installing-development-tree.html
2. download mysql 5.1 code from trunk
3. autoreconf --force --install
4. ./configure --with-debug --without-libedit --with-plugins=innobase
5. make & sudo make install
6. setup eclipse cdt env
    a. startup eclipse by sudo cmd or root user
    b. build project
    c. set debug diag, ref http://forge.mysql.com/wiki/Eclipse/CDT_on_Linux_and_Mac_OS_X, here is my "program parameters" when startup mysqld instance:
    --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --port=3306 --socket=/tmp/mysql.sock --default-storage-engine=innodb

posted @ 2012-03-23 17:49 Milo的海域 阅读(269) | 评论 (0)编辑 收藏

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