歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 並行管理工具pssh

並行管理工具pssh

日期:2017/3/1 14:44:22   编辑:關於Linux
並行管理工具pssh pssh是一個簡單的字符界面並發向多個服務器發送指令進行執行的工具。適合一次性向集群大量服務器發送相同指令(並觀察輸出) 1. 安裝 a. 到google code找到最新的安裝包 http://code.google.com/p/parallel-ssh/downloads/list Bash代碼 $ wget http://code.google.com/p/parallel-ssh/downloads/detail?name=pssh-2.3.1.tar.gz&can=2&q= pssh是python寫的,因此下載之後解壓,安裝python安裝模塊的方式安裝 Bash代碼 $ tar -xf pssh-2.3.1.tar.gz $ cd pssh-2.3.1 # python setup.py install 2. 准備 為了方便使用,免去pssh時輸入密碼,需要生成rsa的key,然後拷貝到需要遠程管理的機器上。 Bash代碼 # key-gen 一直回車,會生成/root/.ssh/id_rsa.pub 拷貝並添加到授權的文件 Bash代碼 # ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] 3. 使用 創建一個hosts.txt文件,將要遠程管理的機器加入 Bash代碼 [root@localhost script]# cat hosts.txt 127.0.0.1 192.168.0.8 192.168.0.51 192.168.1.114 192.168.1.115 運行管理命令: Java代碼 [root@localhost script]# pssh -i -h hosts.txt "uptime" [1] 10:49:19 [FAILURE] 127.0.0.1 22 Received error code of 255 [2] 10:49:19 [SUCCESS] 192.168.1.115 22 10:49:40 up 14 days, 17:50, 8 users, load average: 0.00, 0.00, 0.00 [3] 10:49:19 [SUCCESS] 192.168.1.114 22 02:49:35 up 14 days, 17:52, 9 users, load average: 0.11, 0.04, 0.01 [4] 10:49:19 [SUCCESS] 192.168.0.8 22 02:39:21 up 4 days, 29 min, 6 users, load average: 0.00, 0.02, 0.03 [5] 10:49:19 [SUCCESS] 192.168.0.51 22 10:50:14 up 8 days, 38 min, 20 users, load average: 0.03, 0.06, 0.06
Copyright © Linux教程網 All Rights Reserved