Large data platform often set up to design multiple nodes of the cluster needs to be unified deployment, this design to the daemon or deployment script at different nodes, if it can be on the master machine, unified execution script, one-time start of the entire Cluster service, feel very nice. Because, share the following content:
Prerequisites:
Configure SSH password-free login
for a simple command:
If you are executing several commands on the remote node:
SSH " cd/home; LS "
Note the point:
- Double quotes, must have. If you do not add double quotes, the second LS command executes locally
- Semicolon, separated by a semicolon between two commands
for ways to execute scripts remotely:
Some remote execution of the command content, a single command can not be completed, consider the scripting way to implement:
#!/bin/bashssh [email protected] >/dev/null 2> &1 < < Eeoo Cd/hometouch Abcdefg.txtexiteeooecho done!
- << Eeoo,ssh until the end of the Eeoo, Eeoo can be modified to other forms.
- Redirection is intended to not show the remote output.
- Before the end, add exit to exit the remote node
My sample code:
#!/Bin/Bashsource/home/config.sh/home/start-xxx.py Echonode LocalOK
#kill process no Neededps x|Grep' XXX' |Grep-V grep|Awk'{print $}'|Xargs-LKill -9SSH Root@XXX141 > /Dev/NULL 2>&1 <<Eeooffsource/home/config.sh/home/start-xxx.pyexitEeooffecho xxx141done!
SSH [email protected] >/dev/null 2>&1 << eeooffsource/home/config.sh/home/start-xxx.pyexit Eeooffecho xxx142 done!
Linux shell executes commands or scripts (SSH) on a remote computer