自动化运维工具-pdsh工具安装配置及简单使用讲解
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动化运维工具-pdsh工具安装配置及简单使用讲解相关的知识,希望对你有一定的参考价值。
1、先决条件:
安装pssh工具的主机针对远程主机需要配置免秘钥认证:
ssh-keygen -t rsa
ssh-copy-id [remotehost]
2、下载pssh工具安装介质:
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pdsh/pdsh-2.29.tar.bz2
3、安装pdsh:
tar -jxvf pdsh-2.29.tar.bz2
cd pdsh-2.29
./configure --with-ssh --with-rsh --with-mrsh --with-mqshell \
--with-dshgroups --with-machines=/etc/pdsh/machines
make && make install
安装成功后OS会多出pdsh和pdcp两个命令:
3、pdsh工具使用详解:
查看帮助:
pdsh --help
pdsh: invalid option -- ‘-‘
Usage: pdsh [-options] command ...
-S return largest of remote command return values
-h output usage menu and quit
-V output version information and quit
-q list the option settings and quit
-b disable ^C status feature (batch mode)
-d enable extra debug information from ^C status
-l user execute remote commands as user
-t seconds set connect timeout (default is 10 sec)
-u seconds set command timeout (no default)
-f n use fanout of n nodes
-w host,host,... set target node list on command line
-x host,host,... set node exclusion list on command line
-R name set rcmd module to name
-M name,... select one or more misc modules to initialize first
-N disable hostname: labels on output lines
-L list info on all loaded modules and exit
-g groupname target hosts in dsh group "groupname"
-X groupname exclude hosts in dsh group "groupname"
-a target all nodes
available rcmd modules: ssh,rsh,exec (default: rsh)
1)pdsh使用案例:
pdsh -w ssh:192.168.0.18[1-4] "uname -n"
pdsh -w ssh:192.168.0.18[1-4] -x db01 "uptime"
pdsh -w ssh:192.168.0.18[1-4],/[234]$/ "uptime"
$ cat /etc/pdsh/machines
db01
db02
db03
db04
$ pdsh -R ssh -a "uptime"
cat /etc/dsh/group/bdgroup
db01
db02
db03
db04
pdsh -R ssh -g bdgroup "uptime"
pdsh -R ssh -a -X bdgroup uptime
pdsh -R ssh -a "sudo touch /mnt/aaa"
pdsh交互式命令窗口:
$ pdsh -R ssh -w db02
pdsh> ls -l
db02: total 139040
db02: drwxr-xr-x 8 hadoop hadoop 233 Jul 26 2014 jdk1.7.0_67
db02: -rwxrwxr-x 1 hadoop hadoop 142376665 Oct 2 07:51 jdk-7u67-linux-x64.tar.gz
pdsh> pwd
db02: /home/hadoop
pdsh> rm -rf jdk1.7.0_67
pdsh> ls -l
db02: total 139040
db02: -rwxrwxr-x 1 hadoop hadoop 142376665 Oct 2 07:51 jdk-7u67-linux-x64.tar.gz
pdsh> sudo tar -zxf jdk-7u67-linux-x64.tar.gz -C /mnt/
pdsh> ls -l /mnt
db02: total 9424
db02: drwxr-xr-x 8 10 143 233 Jul 26 2014 jdk1.7.0_67
pdsh> quit
2)pdcp使用案例:
使用pdcp命令要求本地主机和远程主机必须安装pdsh工具,这也是唯一一点麻烦的地方。
pdcp -R ssh -w db02 /mnt/pssh-2.3.1.tar.gz /home/hadoop/
以上是关于自动化运维工具-pdsh工具安装配置及简单使用讲解的主要内容,如果未能解决你的问题,请参考以下文章
高性能 HTTP 负载测试工具 Vegeta及并行分布式运维工具pdsh