pdsh 使用


pdsh 使用教程

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
available rcmd modules: ssh,exec (default: ssh)

使用举例: 单个主机: [trafodion@bj232 ~]$ pdsh -w bj232 -l trafodion uptime bj232: 17:06:22 up 1 day, 2:48, 3 users, load average: 2.20, 1.64, 1.02

多个主机: [trafodion@bj232 ~]$ pdsh -w 10.12.40.[232-234] -l trafodion uptime 10.12.40.232: 17:07:45 up 1 day, 2:50, 3 users, load average: 1.43, 1.55, 1.04 10.12.40.233: 17:07:45 up 1 day, 6:05, 3 users, load average: 0.15, 0.20, 0.54 10.12.40.234: 17:07:45 up 1 day, 5:31, 4 users, load average: 0.91, 0.43, 0.26

逗号分隔主机 [trafodion@bj232 ~]$ pdsh -w 10.12.40.232,10.12.40.233,10.12.40.234 -l trafodion uptime 10.12.40.232: 17:10:01 up 1 day, 2:52, 3 users, load average: 1.31, 1.48, 1.09 10.12.40.234: 17:10:01 up 1 day, 5:33, 4 users, load average: 1.30, 0.79, 0.41 10.12.40.233: 17:10:01 up 1 day, 6:08, 3 users, load average: 0.14, 0.17, 0.48

-x 排除主机 [trafodion@bj232 ~]$ pdsh -w 10.12.40.[232-234] -x 10.12.40.232 -l trafodion uptime 10.12.40.234: 17:10:50 up 1 day, 5:34, 4 users, load average: 1.11, 0.80, 0.43 10.12.40.233: 17:10:50 up 1 day, 6:08, 3 users, load average: 0.06, 0.14, 0.46

主机组 对于-g组,把对应的主机写入到/etc/dsh/group/或~/.dsh/group/目录下的文件中即可,文件名就是对应组名

引用: Pdsh使用方法