IMPALA-2131: The metastore database name should be a global constant.

Previously, we tried to dynamically name the metastore db. With the introduction of
metatsore snapshots, this is no longer necessary and may cause naming ambiguity if the
Impala repository has a non-standard directory structure.

This patch use a constant name - impala_hive -  defined as an environment variable in
impala-config.

Change-Id: Iadc59db8c538113171c9c2b8cea3ef3f6b3bd4fc
Reviewed-on: http://gerrit.cloudera.org:8080/517
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Internal Jenkins
This commit is contained in:
ishaan
2015-07-08 17:16:17 -07:00
committed by Internal Jenkins
parent 1ac44df24b
commit db4bd623ed
5 changed files with 14 additions and 19 deletions

View File

@@ -53,10 +53,6 @@ if [ "${IMPALA_CONFIG_SOURCED}" != "1" ]; then
exit 1
fi
# If a specific metastore db is defined, use that. Otherwise create unique metastore
# DB name based on the current directory.
: ${METASTORE_DB=`basename ${IMPALA_HOME} | sed -e "s/\\./_/g" | sed -e "s/[.-]/_/g"`}
${CLUSTER_DIR}/admin create_cluster
if [ ! -z "${IMPALA_KERBERIZE}" ]; then
@@ -75,14 +71,12 @@ else
export HIVE_S2_AUTH=NONE
fi
# Convert Metastore DB name to be lowercase
export METASTORE_DB=`echo $METASTORE_DB | tr '[A-Z]' '[a-z]'`
export CURRENT_USER=`whoami`
CONFIG_DIR=${IMPALA_HOME}/fe/src/test/resources
echo "Config dir: ${CONFIG_DIR}"
echo "Current user: ${CURRENT_USER}"
echo "Metastore DB: hive_${METASTORE_DB}"
echo "Metastore DB: ${METASTORE_DB}"
pushd ${CONFIG_DIR}
# Cleanup any existing files
@@ -91,15 +85,15 @@ rm -f authz-provider.ini
if [ $CREATE_METASTORE -eq 1 ]; then
echo "Creating postgresql database for Hive metastore"
dropdb -U hiveuser hive_$METASTORE_DB 2> /dev/null || true
createdb -U hiveuser hive_$METASTORE_DB
dropdb -U hiveuser ${METASTORE_DB} 2> /dev/null || true
createdb -U hiveuser ${METASTORE_DB}
psql -q -U hiveuser -d hive_$METASTORE_DB \
psql -q -U hiveuser -d ${METASTORE_DB} \
-f ${HIVE_HOME}/scripts/metastore/upgrade/postgres/hive-schema-0.13.0.postgres.sql
# Increase the size limit of PARAM_VALUE from SERDE_PARAMS table to be able to create
# HBase tables with large number of columns.
echo "alter table \"SERDE_PARAMS\" alter column \"PARAM_VALUE\" type character varying" \
| psql -q -U hiveuser -d hive_$METASTORE_DB
| psql -q -U hiveuser -d ${METASTORE_DB}
fi
if [ $CREATE_SENTRY_POLICY_DB -eq 1 ]; then

View File

@@ -63,6 +63,7 @@ export ISILON_NAMENODE=${ISILON_NAMENODE-""}
export DEFAULT_FS=${DEFAULT_FS-"hdfs://localhost:20500"}
export WAREHOUSE_LOCATION_PREFIX=${WAREHOUSE_LOCATION_PREFIX-""}
export LOCAL_FS="file:${WAREHOUSE_LOCATION_PREFIX}"
export METASTORE_DB="hive_impala"
if [ "${TARGET_FILESYSTEM}" = "s3" ]; then
# Basic error checking

View File

@@ -30,7 +30,7 @@
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_${METASTORE_DB}?createDatabaseIfNotExist=true</value>
<value>jdbc:mysql://localhost:3306/${METASTORE_DB}?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
@@ -66,7 +66,7 @@
</property>
<property>
<name>hive.stats.dbconnectionstring</name>
<value>jdbc:mysql://localhost:3306/hive_${METASTORE_DB}_Stats?createDatabaseIfNotExist=true&amp;user=hiveuser&amp;password=password</value>
<value>jdbc:mysql://localhost:3306/${METASTORE_DB}_Stats?createDatabaseIfNotExist=true&amp;user=hiveuser&amp;password=password</value>
</property>
<property>
<name>hive.stats.jdbcdriver</name>

View File

@@ -30,7 +30,7 @@
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:postgresql://localhost:5432/hive_${METASTORE_DB}</value>
<value>jdbc:postgresql://localhost:5432/${METASTORE_DB}</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>

View File

@@ -65,15 +65,15 @@ elif [[ "${DEFAULT_FS}" != "hdfs://localhost:20500" ]]; then
fi
# Drop and re-create the hive metastore database
dropdb -U hiveuser hive_impala 2> /dev/null || true
createdb -U hiveuser hive_impala
dropdb -U hiveuser ${METASTORE_DB} 2> /dev/null || true
createdb -U hiveuser ${METASTORE_DB}
# Copy the contents of the SNAPSHOT_FILE
psql -q -U hiveuser hive_impala < ${TMP_SNAPSHOT_FILE}
psql -q -U hiveuser ${METASTORE_DB} < ${TMP_SNAPSHOT_FILE}
# Two tables (tpch.nation and functional.alltypestiny) have cache_directive_id set in
# their metadata. These directives are now stale, and will cause any query that attempts
# to cache the data in the tables to fail.
psql -q -U hiveuser -d hive_impala -c \
psql -q -U hiveuser -d ${METASTORE_DB} -c \
"delete from \"TABLE_PARAMS\" where \"PARAM_KEY\"='cache_directive_id'"
psql -q -U hiveuser -d hive_impala -c \
psql -q -U hiveuser -d ${METASTORE_DB} -c \
"delete from \"PARTITION_PARAMS\" where \"PARAM_KEY\"='cache_directive_id'"