In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to use pssh for parallel batch operations", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use pssh for parallel batch operations.
If you execute a command to thousands of servers at the same time, copy a file, kill a process, etc., what tools are there to simplify operation and maintenance management? In small-scale use, I always use for loops, and there are a large number of loops. On the one hand, I am not sure whether the operation is successful; on the other hand, the performance of for loop statements is difficult to estimate and whether they are executed synchronously and in parallel. Such tools as pdsh,mussh,cssh,dsh and pssh mentioned here:
1 installation:
# wget http://peak.telecommunity.com/dist/ez_setup.py
Python ez_setup.py
# wget http://parallel-ssh.googlecode.com/files/pssh-2.2.2.tar.gz
# tar zxvf pssh-2.2.2.tar.gz
# cd pssh-2.2.2
# python setup.py install
2 pssh use (assuming ssh has done a good job of SSH trust, ssh trust, please see: research on ssh commands and detailed explanation of SSH trust)
The pssh toolkit has five main programs:
1 pssh multi-host running commands in parallel
[root@server pssh-2.2.2] # pssh- P-h test.txt uptime
192.168.9.102: 14:04:58 up 26 days, 17:05, 0 users, load average: 0.07, 0.02, 0.00
192.168.9.102: [1] 14:04:58 [SUCCESS] 192.168.9.102 9922
192.168.8.171: 14:04:59 up 35 days, 2:01, 6 users, load average: 0.00, 0.00, 0.00
192.168.8.171: [2] 14:04:59 [SUCCESS] 192.168.8.171 22
192.168.9.104: 14:04:59 up 7 days, 20:59, 0 users, load average: 0.10, 0.04, 0.01
192.168.9.104: [3] 14:04:59 [SUCCESS] 192.168.9.104 9922
[root@server pssh-2.2.2] # cat test.txt
192.168.9.102:9922
192.168.9.104:9922
192.168.8.171 22 / / Note that my port number is not only the default 22
If you want to redirect the output to a file with the-o file option
2 pscp copies files to multiple hosts in parallel
Note that the file is transferred from the server to the client:
[root@server pssh-2.2.2] # pscp-h test.txt / etc/sysconfig/network / tmp/network / / Mark the local / etc/sysconfig/network to the / tmp/network of the target server
3 prsync uses the rsync protocol to synchronize from the local computer to the remote host
[root@server] # pssh-h test.txt-P mkdir / tmp/etc
[root@server ~] # prsync-h test.txt-l dongwm-a-r / etc/sysconfig / tmp/etc / / Mark to recursively synchronize the local / etc/sysconfig directory to the target server's / tmp/etc directory, and keep the original timestamp, using the user dongwm
4 pslurp copies files from the remote host to the local, in the opposite direction to pscp:
[root@server ~] # pslurp-h test.txt-L / tmp/test-l root / tmp/network test / / Mark to copy the / tmp/network file of the target server to the local / tmp/test directory and rename it to test
[1] 14:53:54 [SUCCESS] 192.168.9.102 9922
[2] 14:53:54 [SUCCESS] 192.168.9.104 9922
[root@server ~] # ll / tmp/test/192.168.9.10
192.168.9.102/ 192.168.9.104/
[root@server ~] # ll / tmp/test/192.168.9.102/
Total 4.0K
-rw-r--r-- 1 root root 60 2011-04-22 14:53 test
[root@server ~] # ll / tmp/test/192.168.9.104/
Total 4.0K
-rw-r--r-- 1 root root 60 2011-04-22 14:53 test
5 pnuke parallel kills processes on remote hosts:
[root@server ~] # pnuke-h test.txt syslog / / Kills the syslog process of the target server, as long as the relevant words appear in the ps process.
[1] 15:05:14 [SUCCESS] 192.168.9.102 9922
[2] 15:05:14 [SUCCESS] 192.168.9.104 9922
At this point, I believe you have a deeper understanding of "how to use pssh for parallel batch operations". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.