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的海域 閱讀(3194) 評論(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/
          主站蜘蛛池模板: 四平市| 察雅县| 岳普湖县| 申扎县| 柳林县| 宁城县| 洞头县| 稷山县| 颍上县| 林芝县| 南城县| 韶关市| 开平市| 蓬溪县| 班戈县| 资溪县| 绍兴县| 山阴县| 蓝山县| 武城县| 龙江县| 晋城| 图木舒克市| 广丰县| 子长县| 盐亭县| 五原县| 德庆县| 台中市| 黄平县| 东城区| 肇州县| 桐柏县| 印江| 如皋市| 奉贤区| 宁远县| 井冈山市| 凤凰县| 齐河县| 通州市|