linux學習-pssh命令__linux

來源:互聯網
上載者:User
                                                     linux學習-pssh命令

pssh是一個python編寫可以在多台伺服器上執行命令的工具,同時支援拷貝檔案,是同類工具中很出色的,類似pdsh,個人認為相對pdsh更為簡便,使用必須在各個伺服器上配置好密鑰認證訪問。
項目地址:https://code.google.com/p/parallel-ssh/


安裝

在CentOS系統內容下,介紹yum的安裝和源碼安裝的方式:


yum方法

yum install pssh


源碼安裝

wget http://parallel-ssh.googlecode.com/files/pssh-2.3.1.tar.gz 
tar xf pssh-2.3.1.tar.gz cd pssh-2.3.1/ 
python setup.py install



命令參數

–version 查看版本
–help 查看協助,即此資訊
-h –hosts 主機檔案清單,內容格式”[user@]host[:port]”
-H –host 主機字串,內容格式”[user@]host[:port]”
-l –user 登入使用的使用者名稱
-p –par 並發的線程數【可選】
-o –outdir 輸出的檔案目錄【可選】
-e –errdir 錯誤輸入檔案【可選】
-t –timeout TIMEOUT 逾時時間設定,0無限制【可選】
-O  –option SSH的選項
-v –verbose 詳細模式
-A –askpass 手動輸入Cipher 模式
-x –extra-args 額外的命令列參數使用空白符號,引號,反斜線處理
-X –extra-arg 額外的命令列參數,單個參數模式,同-x
-i –inline 每個伺服器內部處理資訊輸出
–inline-stdout 每個伺服器的內服輸出
-P, –print 列印出伺服器返回資訊


執行個體


1.擷取每台伺服器的uptime

# pssh -h ip.txt -i uptime 
[1] 11:15:03 [SUCCESS] Mar.mars.he
11:15:11 up 4 days, 16:25, 1 user, load average: 0.00, 0.00, 0.00 
[2] 11:15:03 [SUCCESS] Jan.mars.he 
11:15:12 up 3 days, 23:26, 0 users, load average: 0.00, 0.00, 0.00 
[3] 11:15:03 [SUCCESS] Feb.mars.he 
11:15:12 up 4 days, 16:26, 2 users, load average: 0.08, 0.02, 0.01


2.查看每台伺服器上mysql複製IO/SQL線程運行狀態資訊:

# pssh -h IP.txt -i "/usr/local/mysql/bin/mysql -e 'show slave status \G'"|grep Running: 
Slave_IO_Running: yes 
Slave_SQL_Running: Yes 
Slave_IO_Running: Yes 
Slave_SQL_Running: Yes 
Slave_IO_Running: Yes 
Slave_SQL_Running: Yes

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.