linux 学习-pssh 命令
最编程
2024-07-18 16:01:59
...
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 手动输入密码模式
-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
上一篇: pssh