I have an inch
Let the command line appear first:
Cat conf/slaves | xargs echo | sed-e "s //,/g" |
Sed-e "s/^ (. *) $/pdsh-f 200-w" 1 "" jps | grep JobShell | cut-f1-d | xargs kill-9 then /" |
/Bin/bash
The first line is mainly to combine the slave of a row into a single row, separated by commas (,). The sed of the first line can also be used by tr.
The purpose of the second line is to consolidate the pdsh command line. This is a tool that operates multiple machines at the same time. The pdsh-w is followed by the node list, that is, the file list of the row just now. A group of command lines are enclosed in quotation marks. These command lines are sent to each computer for execution. The preceding line actually kills the JobShell Java Process on each node. Finally, in the third line, the command line synthesized above is handed to shell for execution.
This command line looks long, but it is not actually complicated. There is also a variant version.
Cat conf/slaves | xargs echo | sed-e s //,/g |
Sed-e "s/^ (. *) $/pdsh-f 200-w" 1"
For I in 'seq 2001 2100 ';
Do/share/home/testhdp/hadoop-0.19.2/bin/hadoop fs-touchz 'uname-n'. $ I;
Done/"|
/Bin/bash
The middle line is broken into four lines, but the line should not be broken. The first part of this line is the same as the above. The key to the next step is how to put the back quotes out, instead of being replaced by direct variables in the local shell on the spot, the actual processing is very simple-put the command line in single quotes, of course, all kinds of quotation marks and the $ before I need a backslash, otherwise, it will be explained by the current shell before being sent to bash. After such processing, the reverse quotation marks will be sent to each machine, and the shell on that machine will open the reverse quotation marks and replace the variables will also be carried out remotely.
Well, this command is not very complicated. If you are interested, you can modify it and give feedback.