Hive补充
1.认知
1.Mapreduce的客户端,避免写繁琐的MapReduce程序;
2.metastore:原本的数据集和字段名称以及数据信息之间双射关系;
3.Server-Hadoop;在操作Hive同时,需要将Hadoop的HDFS,YARN开启,MAPRED配置好.
2.本地避免使用MapReduce
设置:
hive.fetch.task.conversion
more
Some select queries can be converted to single FETCH task minimizing latency.
Currently the query should be single sourced not having any subquery and should not have
any aggregations or distincts (which incurs RS), lateral views and joins.
1. minimal : SELECT STAR, FILTER on partition columns, LIMIT only
2. more : SELECT, FILTER, LIMIT only (TABLESAMPLE, virtual columns)
3.Hive元数据
常见错误:启动Hive时,无法初始化metastore数据库,无法创建连接,无法创建会话。
1、hive的metastore数据库丢失了,比如drop,比如文件损坏
2、metasotre版本号不对。
3、远程表服务
备份的基本语法:
$ mysqldump -uroot -p metastore > metastore.sql
还原的基本语法:
$ mysql -uroot -p metastore < metastore.sql
find命令,查找metastore.sql默认存放位置
4.Hive任务调度
oozie/azakban/crontab
hive -e "" ;
hive -f 文件名.hql ;
#举例
bin/hive hive -e "SELECT * FROM emp";
bin/hive hive -f "emp.hql";
5.查看历史命令存放地
cat ~/.hivehistory;
6.临时生效
set hive.cli.print.header = false;
7.HiveServer2
* HiveServer2
配置:hive-site.xml
hive.server2.thrift.port --> 10000
hive.server2.thrift.bind.host --> jdf.node1.com
hive.server2.long.polling.timeout -- > 5000(去掉L)
hive.server2.enable.doAs --> false
检查端口:
$ sudo netstat -antp | grep 10000
启动服务:
$ bin/hive --service hiveserver2
连接服务:
$ bin/beeline
beeline> !connect jdbc:hive2://jdf.node1.com:10000
尖叫提示:注意此时不能够执行MR任务调度,报错:
Job Submission failed with exception 'org.apache.hadoop.security.AccessControlException(Permission denied: user=anonymous, access&