Posted on 2012-05-09 17:13
Milo的海域 閱讀(3187)
評論(0) 編輯 收藏 所屬分類:
MySQL 、
Linux
原來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/