posts - 88, comments - 3, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          日歷

          <2012年5月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          搜索

          •  

          幾個ssh管道用法

          Posted on 2012-05-09 17:13 Milo的海域 閱讀(3199) 評論(0)  編輯  收藏 所屬分類: MySQLLinux
          原來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/
          主站蜘蛛池模板: 宁波市| 杭锦旗| 长垣县| 张家港市| 高州市| 邓州市| 乐清市| 米脂县| 涞源县| 枞阳县| 澄江县| 长岛县| 屏山县| 平安县| 巴林左旗| 清远市| 遵化市| 土默特右旗| 元朗区| 四子王旗| 神农架林区| 天水市| 遵化市| 阿图什市| 关岭| 江永县| 建阳市| 奉化市| 吉林省| 永靖县| 遂溪县| 乾安县| 治多县| 贺州市| 天镇县| 沙洋县| 新绛县| 铅山县| 白河县| 景宁| 盘锦市|