1PSSH Introduction
Pssh is a Python-written tool that can be executed in batches on multiple machines, and its usage can be comparable to Ansible's simple usage, which is faster than ansible. It supports file parallel replication, remote command execution, killing processes on remote hosts, and so on. The killer is the file parallel copy, when the remote host batch upload download, it is best to use it.
Use of 2pssh
Before using PSSH, you must ensure that both the management host and the local host have authenticated the key, or that there is no key authentication in bulk, but that the password of the multiple hosts being managed must be the same. about how to do key authentication, there is not much to say, you can own Baidu.
2.1 Installation
Website address: https://code.google.com/archive/p/parallel-ssh/downloads (need to be able to open Google)
or yum to install it.
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/parallel-ssh/ pssh-2.3.1.tar.gztar-zxvf pssh-2.3. 1 . TAR.GZCD pssh-2.3. 1 -y pssh
After installing with Yum, only pssh can be used, but other commands are also installed after compilation and installation (PSCP Prsync Pnuke pslurp)
PSSH: Running commands in parallel on remote multiple hosts
PSCP: Copying files to multiple remote hosts in parallel
Prsync: Use the Rsync protocol to synchronize local files to remote multiple hosts.
Pnuke: Killall a process in parallel on a remote multiple host
Pslurp: Copying files from multiple remote hosts to a local host
2.2 Pssh Common parameters
1Pssh-- Help2 3 usage:pssh [OPTIONS] command [...]4 5 Options:6--version Show Program'S version number and exit7--help Show ThisHelp message and exit8-H Host_file,--hosts=Host_file9Hosts file (each line"[email protected]]host[:p ORT]")Ten-H host_string,--host=host_string OneAdditional Host entries ("[email protected]]host[:p ORT]") A-L USER,--user=USER username (OPTIONAL) --P PAR,--par=PAR max number of parallel threads (OPTIONAL) --O OUTDIR,--outdir=OUTDIR theOutput Directory forstdout Files (OPTIONAL) --E Errdir,--errdir=Errdir -Output Directory forstderr files (OPTIONAL) --T TIMEOUT,--timeout=TIMEOUT +Timeout (secs) (0=no timeout) per host (OPTIONAL) --O OPTION,--option=OPTION + SSH option (OPTIONAL) A-V,--verbose turn on warning and diagnostic messages (OPTIONAL) at-A,--askpass Ask fora 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 in-I,--inline inline aggregated output and error forEach server ---inline-stdout Inline Standard Output forEach server to-I.,--send-input read fromStandard input and send asinput to SSH +-p,--print print output asWeGetit - theExample:pssh-h hosts.txt-l irb2-o/tmp/foo uptime
View Code
Specific Common introduction:
-h host_file behind with remote host list (IP)
-h host_string behind with remote hostname or IP address
-L user Specifies the username of the remote host
-P PAR Specifies the maximum number of parallel threads pssh.
-o redirects the output to a specified file
-o Specifies the specific configuration of the SSH parameter
-e redirects execution errors to a specified file
-T set command execution time-out
-X Pass some parameters of the SSH command
-I display standard output and standard errors after executing command completion on a remote host
-P output Execution results when remote command is executed
Usage examples:
Pssh-p-I- h sz_vpc.txt "w"
3PSCP copy files to remote host
PSCP- H ip.txt/etc/wenjian.txt /tmp/
4pnuke Kill a process
This command is similar to the Yu killall command
Pnuke- H iplist.txt httpd
Above means that the httpd service is closed in bulk on the remote host
Services that can be closed through Killall can be completed in bulk through Pnuke
5 pslurp remote host copy files to localhost
Pslurp-h iplist.txt-l/home//hose/wenjian/yuanc.conf open.conf
Above is, copy all remote host/hose/wenjian/yuanc.conf to the local host/home/directory, and rename to Open.conf-l to specify the local file path
Here's the copy directory.
Pslurp-h iplist.txt-r-l/home//hose/wenjian/open
PS: recommended to distribute files, execute commands, batch kill process, use Pssh,pscp,pnuke, fast
Maintenance Automation Lightweight Tool PSSH