hive 安装、知识点

  • hive 查询语句:
语句 含义
show database; 或 show schemas; 查看数据库
show tables; hive显示所有表
set; 查看hive配置信息
  • 问题:load data local 后,表中字段值全是NULL
    解决:创建表时,如果有如下语句:
FIELDS TERMINATED BY ‘	’
LINES TERMINATED BY ‘
’

将本地文件中的各字段用tab分割下,再导入后正常。

  • hive 启动命令:
命令 含义
schematool -initSchema -dbType derby 创建schema(运行hive命令之前,需要先创建schema,再启动Metastore)
hive --service metastore & 启动Hive的Metastore Server服务进程(运行hive命令之前,需要先创建schema,再启动Metastore)
  • 运行hive查询之前,需要先:
  1. 创建schema(命令:schematool -initSchema -dbType derby)
  2. 启动Hive的Metastore Server服务进程(命令:hive --service metastore &)
  • hive 安装
  1. 下载路径:http://mirrors.shuosc.org/apache/hive/
  • hive 安装报错:
    Exception in thread "main" java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
    解决:
    1.查看hive-site.xml配置,会看到配置值含有"system:java.io.tmpdir"的配置项
    2.新建文件夹/usr/local/hive/tmpdir
    3.将所有的字符串:${system:java.io.tmpdir},修改为如上地址
    启动hive,成功!
  • 报错:Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
    原因:因为没有正常启动Hive 的 Metastore Server服务进程。
    解决方法:启动Hive 的 Metastore Server服务进程,执行如下shell命令:
hive --service metastore &
  • 报错:MetaException(message:Version information not found in metastore. )
    解决:在hive-site.xml文件中,将hive.metastore.schema.verification设置成false就可以了。

  • 运行:schematool -initSchema -dbType derby,报错:Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000)
    原因:这可能是因为你的metastore_db文件夹已经存在;
    解决:将metastore_db更名为:metastore_db.tmp(命令:mv metastore_db metastore_db.tmp),再次执行上面的命令,成功。

  • Hive的架构:

  • Hive 和Hadoop之间的工作流程:

  • 报错:hive insert 插入数据报错:

    待解决。
    一个答案(不知是否正确,待研究):http://blog.csdn.net/sparkexpert/article/details/51158575

  • 出处:http://www.yiibai.com/hive/hive_installation.html#article-start

原文地址:https://www.cnblogs.com/cag2050/p/7967896.html