Skip to content

Instantly share code, notes, and snippets.

@futeng
Last active January 14, 2021 00:46
Show Gist options
  • Save futeng/467ee58a60bed048fb59e7e200d65072 to your computer and use it in GitHub Desktop.
Save futeng/467ee58a60bed048fb59e7e200d65072 to your computer and use it in GitHub Desktop.
[basic hive status test] using beeline to connect hive when doubt the status #hive #test #status
#!/usr/bin/env bash
#
# Copyright futeng@tydic.com
# Jul 24, 2020
#
# NAME: testHive.sh
# FUNC: 测试 Hive 安装的正确性
# EXEC: 任意目录 sh testHive.sh
# 配置 beeline 连接串
HIVESERVER2_JDBC_URL="jdbc:hive2://bigdata102195:2181,bigdata102196:2181,bigdata102197:2181,bigdata102198:2181,bigdata102199:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"
alias beeline="/usr/hdp/current/hive-client/bin/beeline -u \"$HIVESERVER2_JDBC_URL\" -n hive -p hive"
# 检查 hive
echo "################ hive test start ################"
beeline <<sql
show tables;
create table if not exists test(id int);
insert into test values(1);
select * from test;
drop table test;
sql
# 状态报告
echo
status=$?
echo "The status was " $status
if [ $status == 0 ]; then
echo "################ test success ################"
else
echo "################ test failure ################"
fi
echo "################ hive test end ################"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment