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

          幾個ssh管道用法

          Posted on 2012-05-09 17:13 Milo的海域 閱讀(3197) 評論(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'

          拷貝文件時,如果文件很大,又不想影響網(wǎng)絡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

          這樣就不用把腳本拷貝到遠端去執(zhí)行了

          參考:
          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/
          主站蜘蛛池模板: 高邮市| 韶关市| 绥宁县| 文水县| 黄骅市| 镇原县| 昭觉县| 徐汇区| 成武县| 鄯善县| 阿鲁科尔沁旗| 基隆市| 天门市| 葵青区| 镇江市| 将乐县| 莱芜市| 昂仁县| 山西省| 柳林县| 当雄县| 丹棱县| 哈尔滨市| 阿拉善右旗| 肇庆市| 喀喇沁旗| 吉林省| 南充市| 临沂市| 林芝县| 忻州市| 子洲县| 抚州市| 久治县| 沁阳市| 玛曲县| 东安县| 日土县| 平利县| 伊通| 盐池县|