This repository has been archived by the owner on Dec 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_hive.sh
69 lines (55 loc) · 2.51 KB
/
setup_hive.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
HIVE_TAR_FILE=$PWD/apache-hive-3.1.3-bin.tar.gz
DERBY_TAR_FILE=$PWD/db-derby-10.14.2.0-bin.tar.gz
HIVE_HOME=$PWD/apache-hive-3.1.3-bin
HADOOP_HOME=$PWD/hadoop-3.3.4
DERBY_HOME=$PWD/db-derby-10.14.2.0-bin
TASK_COMPLETION_MSG="+++++++++++++ DONE +++++++++++++\n"
echo "[+] Downloading Hive"
if ! test -f $HIVE_TAR_FILE; then
wget https://dlcdn.apache.org/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz
fi
printf $TASK_COMPLETION_MSG
echo "[+] Downloading Derby"
if ! test -f $DERBY_TAR_FILE; then
wget https://archive.apache.org/dist/db/derby/db-derby-10.14.2.0/db-derby-10.14.2.0-bin.tar.gz
fi
echo "[+] Extracting Hive"
if ! test -d $HIVE_HOME; then
tar -xvzf $HIVE_TAR_FILE
fi
echo "[+] Extracting Derby"
if ! test -d $DERBY_HOME; then
tar -xvzf $DERBY_TAR_FILE
fi
echo "[+] Setting up environment"
echo "PATH=$PATH:$HADOOP_HOME:$HIVE_HOME/bin:$HADOOP_HOME/bin" | tee -a $HOME/.bashrc
echo "HADOOP_HOME=$HADOOP_HOME" | tee -a $HOME/.bashrc
echo "DERBY_INSTALL=$DERBY_HOME" | sudo tee /etc/profile.d/derby.sh
echo "DERBY_HOME=$DERBY_HOME" | sudo tee -a /etc/profile.d/derby.sh
echo "export DERBY_INSTALL" | sudo tee -a /etc/profile.d/derby.sh
echo "export DERBY_HOME" | sudo tee -a /etc/profile.d/derby.sh
echo "HADOOP=$HADOOP_HOME/bin/hadoop" | sudo tee /etc/profile.d/hive.sh
echo "export HADOOP" | sudo tee -a /etc/profile.d/hive.sh
echo "export HADOOP_HOME=$HADOOP_HOME" | tee -a $HIVE_HOME/bin/hive-config.sh
echo "[+] Setting up Hive directories"
$HADOOP_HOME/bin/hadoop fs -mkdir /tmp
$HADOOP_HOME/bin/hadoop fs -mkdir /user
$HADOOP_HOME/bin/hadoop fs -mkdir /user/hive
$HADOOP_HOME/bin/hadoop fs -mkdir /user/hive/warehouse
$HADOOP_HOME/bin/hadoop fs -chmod g+w /tmp
$HADOOP_HOME/bin/hadoop fs -chmod g+w /user/hive/warehouse
echo "[+] Creating Derby data directory"
if ! test -d $DERBY_HOME/data; then
mkdir $DERBY_HOME/data
fi
echo "[+] Configure Hive to use Derby"
HIVE_SITE_CONFIG=$(cat $PWD/hive-site.xml)
JPOS_PROPERTIES=$(cat $PWD/jpos.properties)
IP_ADDRESS=$(ip addr | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
SUBSTITUTED_HIVE_CONFIG=${HIVE_SITE_CONFIG//hadoop1/$IP_ADDRESS}
SUBSTITUTED_JPOS_PROPERTIES=${JPOS_PROPERTIES//hadoop1/$IP_ADDRESS}
echo $SUBSTITUTED_HIVE_CONFIG > $HIVE_HOME/conf/hive-site.xml
echo $SUBSTITUTED_JPOS_PROPERTIES > $HIVE_HOME/conf/jpox.properties
echo "[+] Copy jar files from Derby to Hive"
cp $DERBY_HOME/lib/* $HIVE_HOME/lib/