Parallel distributed O & M tool pdsh

Source: Internet
Author: User

The full name of pdsh is parallel distributed shell. Similar to Pssh, pdsh can perform operations on remote target hosts in parallel. When you need to perform commands or distribute tasks in batches, use this command to get twice the result with half the effort. In addition, pdsh supports interactive mode. When the command to be executed is uncertain, you can directly access the pdsh command line, which is very convenient.


I. pdsh application scenarios

The application scenarios of pdsh are basically the same as those of Pssh, and are used for O & M operations such as configuration, deployment, and file replication for large batches of servers. When using pdsh, you still need to configure one-way SSH trust between the local host and the remote host. In addition, pdsh also comes with the PDCP command, which can copy local files to multiple remote hosts in batches, which is very useful in large-scale file distribution environments.

Pdsh can run commands on remote hosts in multiple ways. The default mode is RSH. It also supports multiple RCMD modules, such as SSH, MRSH, qsh, mqsh, krb4, and xcpu, you can specify this parameter when running the command.


Ii. pdsh installation and syntax


1. pdsh Installation Process


The installation of pdsh is very simple. There are two methods: rpm package and source code package. You can choose the appropriate installation method based on your preferences. You can renew in http://code.google.com/p/pdsh. The compilation and installation process is as follows:

[[Email protected] ~] # Tar jxvf pdsh-2.29.tar.bz2

[[Email protected] ~] # Cd pdsh-2.29

[[Email protected] pdsh-2.29] #./configure -- With-ssh -- With-RSH -- With-MRSH -- With-mqshell \

> -- With-qshell -- With-dshgroups -- With-machines =/etc/pdsh/machines

[[Email protected] pdsh-2.29] # Make

[[Email protected] pdsh-2.29] # make install

In the configure stage, the "-- with-ssh" parameter indicates that the SSH module is enabled. Other parameters have similar meanings, while "-- with-dshgroups" indicates that host group support is enabled, after this parameter is enabled, you can write a group of hosts into a file and place it in ~ /. Dsh/group or/etc/dsh/group directory, and then call it through the "-G" parameter of pdsh. The final parameter "-- with-machines" is an extension of the "-- with-dshgroups" parameter, by writing the list of all hosts to be managed into the specified/etc/pdsh/machines file, and then calling the "-a" parameter of pdsh, the convenient management of all hosts is completed.

After the installation is complete, you can view the pdsh version number and available module information through "pdsh-V". The operations are as follows:

[[Email protected] ~] $ Pdsh-V

Pdsh-2.29

RCMD modules: SSH, RSH, exec (default: rsh)

Misc modules: machines, dshgroup

In addition, you can use "pdsh-L" to display information about all currently loaded modules. After the pdsh installation is complete, there is also an available tool PDCP. The usage of the pdsh and PDCP commands will be detailed later.


2. pdsh syntax Introduction


After pdsh is installed, Run "pdsh-h" and "PDCP-h" to obtain the complete usage of the two commands. Because the parameters of the two commands are similar, therefore, the pdsh command is used to introduce some common parameters and meanings. The following table lists common pdsh parameters and their meanings.


-W host: Specifies the remote host. Multiple hosts can be specified. Each host is separated by commas (,). The host can be either a host name or an IP address. This parameter is very flexible and is commonly used in the following forms:

Pdsh-w ssh: user001, SSH: user002, SSH: user003 "date"

This command is used to view the time on the host user001, user002, and user003. Ssh indicates that commands are executed on the remote host. The default value is RSH.

Pdsh-w ssh: user00 [1-10] "date"

This command is used to execute the date command from user001 to user0010.

Pdsh-w ssh: user0 [10-31],/1 $/"uptime"

This command uses a regular expression when selecting a remote host, indicating that the host name ending with 1 is selected from user010 to user031, that is, the uptime command is executed on user011, user021, and user031.


-R specifies the module name using RCMD. The default value is RSH. If you want to select SSH, you can specify it as follows:

Pdsh-r ssh-W user00 [1-10] "date"


-L user name used on the remote host. For example:

Pdsh-r ssh-l opsuser-W user00 [1-9] "date"


-X this parameter is used to exclude some or a host, for example:

Pdsh-r ssh-l opsuser-W user00 [1-9]-x user005, user007 "date"


-T specifies the timeout time for connecting to the remote host, in seconds. The default value is 10 seconds. You can use this parameter to modify the default value. For example: pdsh-r ssh-W slave000 [1-9]-T 15 "date"


-U: Set the timeout time for remote command execution. In seconds, the default time is unlimited when you connect using SSH.


-F sets the number of concurrent connections to the remote host.

-N this parameter is used to disable the host name display in the result returned by the remote host.

-A can use this parameter to specify all remote hosts. After this parameter is set, pdsh will view the host list in the/etc/machines file by default. To change this path, when compiling pdsh, use the "-- with-machines" parameter to specify

-G: this parameter is used to specify a group of remote hosts. When compiling pdsh, you can use the "-- with-dshgroups" parameter to activate this option, by default, a group of hosts can be written to a file and put into the local host ~ The/. dsh/group or/etc/dsh/group directory can be called through the "-G" parameter. For example, pdsh-r ssh-G userhosts "date", where "userhosts" is a host list file, which can be placed in ~ /. Dsh/group or/etc/dsh/group directory

-X: this parameter is used to exclude all hosts in the specified group. It is often used with the-a parameter. For example:

Pdsh-r ssh-a-x userhosts "date"

-Q: this parameter can be used to list some configurations of pdsh execution.

-V this parameter allows you to view the software version and available module information.


This article from the "Technical Achievement dream" blog, please be sure to keep this source http://ixdba.blog.51cto.com/2895551/1550184

Parallel distributed O & M tool pdsh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.