INFO-Hive客户端访问
更新时间: 2024-12-10 10:47:44
阅读 4172
Hive客户端访问
适用模块
hive
具体说明
通过beeline访问Hive:
可将以下语句创装为shell脚本,通过有数离线开发script节点进行调度;
如需在用户自定义客户端执行,需添加kerberos认证,配置详见
https://study.sf.163.com/documents/read/service_support/dsc-p-a-0006
使用示例
## kerberos认证,其中keytab_dir提替换为具体keytab路径,keytab_principal需根据klist -kt xxx.keytab结果获取
## kinit -kt keytab_dir/xxx.keytab keytab_principal
## -u参数后接Hiveserver2链接串,有数已实现通过ZK保障Hiveserver2服务高可用,链接信息可咨询运维人员或网易技术支持;
## -e 参数后接要执行的SQL语句
$HIVE_HOME/bin/beeline
-u "jdbc:hive2://demo1.jd.163.org:2181,demo2.jd.163.org:2181,demo3.jd.163.org:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hive-cluster10;principal=hive/_HOST@HADOOP2.HZ.NETEASE.COM"
-e "set mapreduce.job.queuename=root.xxx.default;select a.employee_id,a.employee_name,18,null,null,a.ds from ods_employee_info;"
连spark
./current/bin/beeline -u "jdbc:hive2://demo01.jdlt.163.org:2182,demo02.jdlt.163.org:2182,demo03.jdlt.163.org:2182/;spark.yarn.queue=root.bdms.sla;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi-cluster;principal=hive/_HOST@BDMS.COM" -e "use bdms;show table extended like 'xh';"
或
./current/bin/beeline -u "jdbc:hive2://dsc-demo19.jdlt.163.org:2182,dsc-demo17.jdlt.163.org:2182,dsc-demo18.jdlt.163.org:2182/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi-cluster;principal=hive/_HOST@BDMS_DEMO.COM;#spark.yarn.queue=root.support.default" -e "show databases;"
java 连spark
"jdbc:hive2://dsc-demoxx.jdlt.163.org:2182,dsc-demoxx.jdlt.163.org:2182,dsc-demoxx.jdlt.163.org:2182/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi-cluster;principal=hive/_HOST@BDMS_DEMO.COM;#spark.yarn.queue=root.support.default"
作者:林帅
文档反馈
以上内容对您是否有帮助?