Usage: /usr/bin/polysh [OPTIONS] HOSTS...
Control commands are prefixed by ":". Use :help for the list
Options:
--version show program's version number and exit
-h, --help show this help message and exit
--hosts-file=FILE read hostnames from given file, one per line
--command=CMD command to execute on the remote shells
--ssh=SSH ssh command to use [exec ssh -oLogLevel=Quiet -t
%(host)s exec bash --noprofile]
--user=USER remote user to log in as
--no-color disable colored hostnames [enabled]
--password-file=FILE read a password from the specified file. - is the tty.
--log-file=LOG_FILE file to log each machine conversation [none]
--abort-errors abort if some shell fails to initialize [ignore]
--debug print debugging information
建立一個host清單檔案host.list,每一行為一個hostname或IP:
localhost
localhost.localdomain
localhost4
localhost4.localdomain4
node0003.nemongo.com
執行:polysh --user=root --hosts-file=host.list,當全部連接配接OK的時候,會提示一個ready (5)> ,這裡的數字是host的個數。
<a href="http://s3.51cto.com/wyfs02/M01/6C/D1/wKiom1VSs-7A8mIBAAEFndCCUPk231.jpg" target="_blank"></a>
注意:登入的之前如果不想輸入密碼,可以預先配置好SSH無密碼登入。
為了可以友善的使用shell腳本自動批量運作指令,可以加上參數--command,指定需要執行的指令:
<a href="http://s3.51cto.com/wyfs02/M02/6C/D1/wKiom1VSs_DjyGkxAAECsbgba0Y282.jpg" target="_blank"></a>
本文轉自 Tenderrain 51CTO部落格,原文連結:http://blog.51cto.com/tenderrain/1961083