-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy-hbase-tarball.sh
executable file
·47 lines (38 loc) · 1.96 KB
/
deploy-hbase-tarball.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
source ./env.sh
if [ "$#" -eq "0" ] ; then
echo "usage: $0 <tarball_path> "
exit
fi
TARBALL=$1
echo "***********************************"
echo "deploy hbase from tarball $TARBALL";
echo "***********************************"
extractTarball() {
echo "Extracting tarball $TARBALL"
tar zxf $TARBALL
TARBALL=`tar tvf $TARBALL | head -n 1 | cut -d ":" -f 2 | cut -d " " -f 2 | cut -d "/" -f 1 `
}
deploy() {
echo "deploying $TARBALL"
local HOSTS_FILE=$1
local TARGET_DIR=$2
local TARBALL=$3
pdsh -R exec -w ^$HOSTS_FILE ssh $SSH_ARGS -l %u %h "rm -rf $TARGET_DIR/lib/*";
pdsh -R exec -w ^$HOSTS_FILE scp $SSH_ARGS -r $TARBALL/lib/* %h:$TARGET_DIR/lib/
pdsh -R exec -w ^$HOSTS_FILE ssh $SSH_ARGS -l %u %h "cp $TARGET_DIR/bin/hbase $TARGET_DIR/bin/hbase.hdp" #backup bin/hbase script specific to hdp
pdsh -R exec -w ^$HOSTS_FILE scp $SSH_ARGS -r $TARBALL/bin/* %h:$TARGET_DIR/bin/
pdsh -R exec -w ^$HOSTS_FILE ssh $SSH_ARGS -l %u %h "cp $TARGET_DIR/bin/hbase $TARGET_DIR/bin/hbase.distro" #copy bin/hbase script to bin/hbase.dist
pdsh -R exec -w ^$HOSTS_FILE ssh $SSH_ARGS -l %u %h "cp $TARGET_DIR/bin/hbase.hdp $TARGET_DIR/bin/hbase" #restore bin/hbase script specific to hdp
pdsh -R exec -w ^$HOSTS_FILE scp $SSH_ARGS -r $TARBALL/hbase-webapps/* %h:$TARGET_DIR/hbase-webapps/
pdsh -R exec -w ^$HOSTS_FILE ssh $SSH_ARGS -l %u %h "rm -rf $TARGET_DIR/lib/hadoop-*.jar";
pdsh -R exec -w ^$HOSTS_FILE ssh $SSH_ARGS -l %u %h "chmod 744 $TARGET_DIR/lib/*; chmod 755 $TARGET_DIR/bin/*; chmod 755 $TARGET_DIR/hbase-webapps/*; chmod -R 755 $TARGET_DIR/lib/ruby/";
# link Phoenix if it is there
pdsh -R exec -w ^$HOSTS_FILE ssh $SSH_ARGS -l %u %h "cd /usr/hdp/current/hbase-regionserver/lib/ && ln -s /usr/hdp/current/phoenix-server/phoenix-server.jar phoenix-server.jar"
}
case $TARBALL in
*.tar.gz) extractTarball;;
*) ;;
esac
deploy $HBASE_CONF_DIR/masters $HDP/hbase-master/ $TARBALL
deploy $HBASE_CONF_DIR/regionservers $HDP/hbase-regionserver/ $TARBALL