Polysh命令實(shí)現(xiàn)多日志查詢的方法示例
一、Polysh簡(jiǎn)介
Polysh 是一個(gè)交互式命令,可以在一臺(tái)服務(wù)器上批量的對(duì)一批服務(wù)器進(jìn)行處理,運(yùn)行交互式命令。Polysh可以同時(shí)登錄多個(gè)遠(yuǎn)程主機(jī),而不需要通過(guò)relay一臺(tái)一臺(tái)的登錄,并執(zhí)行相同的指令,方便了問(wèn)題的排查和定位,大大減少了我們的工作量。
Polysh is a tool to aggregate several remote shells into one. It is used to launch an interactive remote shell on many machines at once. It is written in Python and requires Python ≥ 2.4.
注: 官方解釋:Polysh 是一個(gè)由幾個(gè)遠(yuǎn)程腳本集合而成的工具,它被用于在許多服務(wù)器上運(yùn)行一個(gè)交互式的遠(yuǎn)程腳本,由 Python 編寫(xiě),最低要求為 Python 2.4 。
二、polysh安裝
通過(guò)relay登錄staging機(jī)器,執(zhí)行如下命令安裝polysh。安裝目錄為用戶目錄: /opt/hl/。
1.已安裝python的安裝
wget wget http://guichaz.free.fr/polysh/files/polysh-0.4.tar.gz tar -zxvf polysh-0.4.tar.gz vim prod-polysh.sh
腳本內(nèi)容如下:
#10.252.176.33,10.252.176.35是你要鏈接的機(jī)器ip python /opt/hl/polysh-0.4/polysh.py {10.252.176.33,10.252.176.35}
開(kāi)放給其他用戶可執(zhí)行的權(quán)限
chmod 777 prod-polysh.sh
2.未安裝python的安裝
wget wget http://guichaz.free.fr/polysh/files/polysh-0.4.tar.gz tar -zxvf polysh-0.4.tar.gz cd polysh-0.4 su python setup.py install vim prod-polysh.sh
腳本內(nèi)容如下:
#10.252.176.33,10.252.176.35是你要鏈接的機(jī)器ip python /opt/hl/polysh-0.4/polysh.py {10.252.176.33,10.252.176.35}
開(kāi)放給其他用戶可執(zhí)行的權(quán)限
chmod 777 prod-polysh.sh
三、Xshell配置Xagent(mac可跳過(guò)這一步)
打開(kāi)文件-屬性,選擇SSH選項(xiàng),選擇”使用密碼處理的Xagent(SSH代理)”。然后將Xshell重啟。
四、polysh使用
4.1.使用方法一
polysh 10.252.176.33 10.252.176.35
4.2.使用方法二
./prod-polysh.sh
則會(huì)出現(xiàn)如下提示信息
[---hl-----]$ ./prod-polysh.sh ready (8)
ready (8) 表示 8臺(tái)機(jī)器已經(jīng)連接完畢,可以執(zhí)行查詢命令。exit或Crtl+z都可以退出。
4.3.執(zhí)行命令
ready (8)>cd /opt/hl ready (8)>pwd
顯示如下:
10.252.176.33: /opt/hl 10.252.176.35 : /opt/hl
五、源碼
可以通過(guò)git獲取polysh的源碼
git clone git://repo.or.cz/polysh.git
六、其他
以冒號(hào)開(kāi)頭的指令不會(huì)發(fā)送到遠(yuǎn)程主機(jī),polysh會(huì)執(zhí)行以冒號(hào)開(kāi)頭的指令,例如:
ready (2)> :help :add Add one or many remote shells. :chdir Change the current directory of polysh (not the remote shells). :disable Disable sending commands to remote shells. :enable Enable sending commands to remote shells. :export_vars Export some environment variables on enabled remote shells. :help List control commands or show their documentations. :hide_password Do not echo the next typed line. :list List remote shells and their states. :purge Delete disabled remote shells. :quit Quit polysh. :reconnect Try to reconnect to disconnected remote shells. :rename Rename all enabled remote shells with the argument. :replicate Copy a path from one remote shell to all others :reset_prompt Change the prompt to be recognized by polysh. :send_ctrl Send a control character to remote shells. :set_debug Enable or disable debugging output for remote shells. :set_log Duplicate every console I/O into the given local file. :show_read_buffer Print the data read by remote shells. :upload Upload the specified local path to enabled remote shells.
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)腳本之家的支持。
相關(guān)文章
Centos7升級(jí)glibc導(dǎo)致系統(tǒng)異常(無(wú)法開(kāi)機(jī))解決方法
大家好,本篇文章主要講的是Centos7升級(jí)glibc導(dǎo)致系統(tǒng)異常(無(wú)法開(kāi)機(jī))解決方法,感興趣的同學(xué)趕快來(lái)看看吧,希望對(duì)你有幫助2021-11-11Java使用Apache.POI中HSSFWorkbook導(dǎo)出到Excel的實(shí)現(xiàn)方法
這篇文章主要介紹了Java使用Apache.POI中HSSFWorkbook導(dǎo)出到Excel的實(shí)現(xiàn)方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-04-04詳解Linux下crontab的使用與注意事項(xiàng)
這篇文章主要介紹了詳解Linux下crontab的使用與注意事項(xiàng),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01linux中g(shù)rep命令數(shù)據(jù)過(guò)濾和篩選方式
這篇文章主要介紹了linux中g(shù)rep命令數(shù)據(jù)過(guò)濾和篩選方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09linux通過(guò)掛載系統(tǒng)光盤(pán)搭建本地yum倉(cāng)庫(kù)的方法
linux通過(guò)掛載系統(tǒng)光盤(pán)搭建本地yum倉(cāng)庫(kù),使用yum命令加上 list 參數(shù)就可以查看倉(cāng)庫(kù)了。本文介紹的非常詳細(xì),具有參考借鑒價(jià)值,感興趣的朋友一起看看吧2016-10-10服務(wù)器端如何開(kāi)啟GZIP壓縮功能(Apache、IIS、Nginx)
在負(fù)載均衡中有一個(gè)必須要做的事情就是給服務(wù)器開(kāi)啟GZIP壓縮功能,本文主要介紹了服務(wù)器端如何開(kāi)啟GZIP壓縮功能,具有一定的參考價(jià)值,感興趣的可以了解下2022-04-04