pssh是SA的利器,非常好用,适合批量在多台服务器上执行命令及脚本等,以前用过一段时间的tentakel,目前已经不再更新。Linux下一般源码编译即可,MAC下安装软件就靠brew了,下面是具体过程:
brew install pssh ==> Downloading https://parallel-ssh.googlecode.com/files/pssh-2.3.1.tar.gz ==> python setup.py install --prefix=/usr/local/Cellar/pssh/2.3.1 --install-data=/usr/local/Cellar/pssh/2.3.1/share ==> Caveats If you need Python to find the installed site-packages: mkdir -p ~/Library/Python/2.7/lib/python/site-packages echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth ==> Summary /usr/local/Cellar/pssh/2.3.1: 40 files, 228K, built in 7 seconds
$ pssh –help
Usage: pssh [OPTIONS] command [...] Options: --version show program's version number and exit --help show this help message and exit -h HOST_FILE, --hosts=HOST_FILE hosts file (each line "[user@]host[:port]") -H HOST_STRING, --host=HOST_STRING additional host entries ("[user@]host[:port]") -l USER, --user=USER username (OPTIONAL) -p PAR, --par=PAR max number of parallel threads (OPTIONAL) -o OUTDIR, --outdir=OUTDIR output directory for stdout files (OPTIONAL) -e ERRDIR, --errdir=ERRDIR output directory for stderr files (OPTIONAL) -t TIMEOUT, --timeout=TIMEOUT timeout (secs) (0 = no timeout) per host (OPTIONAL) -O OPTION, --option=OPTION SSH option (OPTIONAL) -v, --verbose turn on warning and diagnostic messages (OPTIONAL) -A, --askpass Ask for a password (OPTIONAL) -x ARGS, --extra-args=ARGS Extra command-line arguments, with processing for spaces, quotes, and backslashes -X ARG, --extra-arg=ARG Extra command-line argument -i, --inline inline aggregated output and error for each server --inline-stdout inline standard output for each server -I, --send-input read from standard input and send as input to ssh -P, --print print output as we get it Example: pssh -h hosts.txt -l irb2 -o /tmp/foo uptime
另外pssh安装好后,还有pscp,prsync,pslurp命令可以使用哦,非常方便。