From ca500ad730667c5dddadbdc878ecd727af19cab3 Mon Sep 17 00:00:00 2001 From: rpoluri <38321430+rpoluri@users.noreply.github.com> Date: Thu, 14 Feb 2019 10:33:57 -0600 Subject: [PATCH] auto configure heapsize on ECS (#46) --- CHANGELOG.md | 5 ++++- files/startup.sh | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17fa048..72710eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +### Added +- Auto configure Hive metastore heapsize when running on ECS. + ### Changed -- Replace EMRFS with hadoop-aws S3A libraries +- Replace EMRFS with hadoop-aws S3A libraries. ## [1.0.0] - 2018-10-31 diff --git a/files/startup.sh b/files/startup.sh index 08955e9..4ff831f 100755 --- a/files/startup.sh +++ b/files/startup.sh @@ -96,5 +96,12 @@ export AUX_CLASSPATH="/usr/share/java/mariadb-connector-java.jar" [[ ! -z $RANGER_POLICY_MANAGER_URL ]] && export AUX_CLASSPATH="$AUX_CLASSPATH:/usr/lib/apiary/apiary-ranger-metastore-plugin-${APIARY_RANGER_PLUGIN_VERSION}-all.jar" [[ ! -z $ENABLE_METRICS ]] && export AUX_CLASSPATH="$AUX_CLASSPATH:/usr/lib/apiary/apiary-metastore-metrics-${APIARY_METASTORE_METRICS_VERSION}-all.jar" -export HADOOP_OPTS="-XshowSettings:vm" +#auto configure heapsize +if [ ! -z ${ECS_CONTAINER_METADATA_URI} ]; then + export MEM_LIMIT=$(wget -q -O - ${ECS_CONTAINER_METADATA_URI}/task|jq -r .Limits.Memory) + export HADOOP_HEAPSIZE=$(expr $MEM_LIMIT \* 90 / 100) +fi +[[ -z $HADOOP_HEAPSIZE ]] && export HADOOP_HEAPSIZE=1024 + +export HADOOP_OPTS="-XshowSettings:vm -Xms${HADOOP_HEAPSIZE}m" su hive -s/bin/bash -c "/usr/lib/hive/bin/hive --service metastore --hiveconf javax.jdo.option.ConnectionURL=jdbc:mysql://${MYSQL_DB_HOST}:3306/${MYSQL_DB_NAME} --hiveconf javax.jdo.option.ConnectionUserName='${MYSQL_DB_USERNAME}' --hiveconf javax.jdo.option.ConnectionPassword='${MYSQL_DB_PASSWORD}'"