forked from D-Net/dnet-hadoop
Merge pull request 'Update copyDataToImpalaCluster.sh' (#291) from antonis.lempesis/dnet-hadoop:beta into beta
Reviewed-on: D-Net/dnet-hadoop#291
This commit is contained in:
commit
12cd179d2d
|
@ -11,14 +11,15 @@ export HADOOP_USER_NAME=$5
|
||||||
|
|
||||||
function copydb() {
|
function copydb() {
|
||||||
db=$1
|
db=$1
|
||||||
|
FILE=("hive_wf_tmp_"$RANDOM)
|
||||||
|
hdfs dfs -mkdir hdfs://impala-cluster-mn1.openaire.eu:8020/tmp/$FILE/
|
||||||
# copy the databases from ocean to impala
|
# copy the databases from ocean to impala
|
||||||
|
|
||||||
echo "copying $db"
|
echo "copying $db"
|
||||||
hadoop distcp -Dmapreduce.map.memory.mb=6144 -pb hdfs://nameservice1/user/hive/warehouse/${db}.db hdfs://impala-cluster-mn1.openaire.eu:8020/tmp
|
hadoop distcp -Dmapreduce.map.memory.mb=6144 -pb hdfs://nameservice1/user/hive/warehouse/${db}.db hdfs://impala-cluster-mn1.openaire.eu:8020/tmp/$FILE/
|
||||||
|
|
||||||
# change ownership to impala
|
# change ownership to impala
|
||||||
hdfs dfs -conf /etc/impala_cluster/hdfs-site.xml -chmod -R 777 /tmp/${db}.db
|
hdfs dfs -conf /etc/impala_cluster/hdfs-site.xml -chmod -R 777 /tmp/$FILE/${db}.db
|
||||||
|
|
||||||
# create the databases
|
# create the databases
|
||||||
impala-shell -i impala-cluster-dn1.openaire.eu -q "drop database if exists ${db} cascade";
|
impala-shell -i impala-cluster-dn1.openaire.eu -q "drop database if exists ${db} cascade";
|
||||||
|
@ -41,12 +42,12 @@ function copydb() {
|
||||||
echo "copying data in tables and computing stats"
|
echo "copying data in tables and computing stats"
|
||||||
for i in `impala-shell -i impala-cluster-dn1.openaire.eu -d ${db} --delimited -q "show tables"`;
|
for i in `impala-shell -i impala-cluster-dn1.openaire.eu -d ${db} --delimited -q "show tables"`;
|
||||||
do
|
do
|
||||||
impala-shell -i impala-cluster-dn1.openaire.eu -d ${db} -q "load data inpath '/tmp/${db}.db/$i' into table $i";
|
impala-shell -i impala-cluster-dn1.openaire.eu -d ${db} -q "load data inpath '/tmp/$FILE/${db}.db/$i' into table $i";
|
||||||
impala-shell -i impala-cluster-dn1.openaire.eu -d ${db} -q "compute stats $i";
|
impala-shell -i impala-cluster-dn1.openaire.eu -d ${db} -q "compute stats $i";
|
||||||
done
|
done
|
||||||
|
|
||||||
# deleting the remaining directory from hdfs
|
# deleting the remaining directory from hdfs
|
||||||
hdfs dfs -conf /etc/impala_cluster/hdfs-site.xml -rm -R /tmp/${db}.db
|
hdfs dfs -conf /etc/impala_cluster/hdfs-site.xml -rm -R /tmp/$FILE/${db}.db
|
||||||
}
|
}
|
||||||
|
|
||||||
STATS_DB=$1
|
STATS_DB=$1
|
||||||
|
|
Loading…
Reference in New Issue