Getting Hadoop Big Data technologies - xsync cluster distribution script

Learning hdaoop, when the host set up a cluster, you need to change the configuration of each machine, this time you need to use a cluster distribution script, used to circulate copy the file to the same directory for all nodes.

Original copies of rsync command:

rsync  -rvl     /opt/module            root@hadoop103:/opt/

 

We will xsync script is created in the / home / zhou / bin directory. Note: / home / zhou / bin script stored in the directory, zhou user can execute directly anywhere in the system.

1. There are three machines, ip is 192.168.93.102-104

2. Create a directory

3. xsync:

#!/bin/bash 

# 1 Gets the number of input parameters, without parameters, exit

pcount=$#          

if((pcount==0)); then

echo no args;

exit;

be

 

# 2 Get File Name

p1=$1

fname=`basename $p1`

echo fname=$fname

 

# 3 to get the absolute path of the parent directory

pdir=`cd -P $(dirname $p1); pwd`  

Echo pdir = $ pdir

 

# 4 Get Current User Name

user=`whoami`

 

# 5 cycles

for((host=103; host<105; host++)); do

        echo ------------------- hadoop$host --------------

        rsync -rvl $pdir/$fname $user@hadoop$host:$pdir

done

4.  If xsync into / home / zhou / bin directory still can not achieve global use, the xsync moved to the / usr / local / bin directory.

5.

6. home directory under the Executive xsync

7. cluster distribution success

 

QQ:2248745948

WeChat: HHgood

 

Published 13 original articles · won praise 3 · Views 315

Guess you like

Origin blog.csdn.net/zhouth94/article/details/104750994