hive 2.3.4安装

下载地址

  • https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.3.4/
  • 下载apache-hive-2.3.4-bin.tar.gz

解压文件

tar -zxvf apache-hive-2.3.4-bin.tar.gz -C ../module/

安装和配置mariadb

  • 安装 yum install mariadb-server mariadb

  • 配置

systemctl start mariadb  #启动MariaDB
systemctl stop mariadb  #停止MariaDB
systemctl restart mariadb  #重启MariaDB
systemctl enable mariadb  #设置开机启动
  • 登录root账户(默认无密码)
    mysql -u root -p
  • 创建新账户用户hive
CREATE USER 'hive'@'%' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO  'hive'@'%' IDENTIFIED BY 'hive';
FLUSH PRIVILEGES;

开始hive配置

  • 配置环境变量
#hive
HIVE_HOME=/opt/module/hive
PATH=$HIVE_HOME/bin:$PATH
PATH=$HIVE_HOME/sbin:$PATH
  • conf目录下新建hive-site.xml文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
    <description>JDBC connect string for a JDBC metastore</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>hive</value>
    <description>username to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>hive</value>
    <description>password to use against metastore database</description>
  </property>
  <property>
   <name>datanucleus.autoStartMechanism</name>
   <value>SchemaTable</value>
 </property>

   <property>
    <name>datanucleus.schema.autoCreateAll</name>
    <value>true</value>
  </property>
  
</configuration>
  • 初始化hive元数据表
    schematool -dbType mysql -initSchema

测试

  • 输入hive,创建表create table test (id int,name string);,查看表show tables;

遇到的坑

  • MySQL遇到的坑
[heasy@spark001 conf]$ mysql -u hive -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'hive'@'localhost' (using password: YES)

可能存在用户名相同,但是权限不同的用户,查看user表,看下创建的用户的Host字段是不是%.如果是,可以使用

GRANT ALL PRIVILEGES ON *.* TO  'hive'@'%' IDENTIFIED BY 'hive';
FLUSH PRIVILEGES;
```重新授权试下,然后使用`mysql -uhvie -p`登录测试下,是否可以登录成功。

- hive中遇到的坑

create table test (id int,name string);
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

这个提示就大概意思是和元数据表没有连通,修改修复mysql中遇到的坑,就可以正常使用了


- hive启动时提示sl4j包冲突

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]


原因是hive启动时会从多处进行jar包加载,sl4j这个jar在其他中间已经加载了。先从一出一个jar


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值