盒子
盒子
文章目录
  1. 1. Hive 安装
  2. 2. MySQL 安装
  3. 3. Hive 使用 MySQL 数据库
  4. 4. Hive 使用

Hive 安装及使用

1. Hive 安装

  • 官网下载安装包
  • 解压到指定文件夹

    tar -zxvf apache-hive-2.3.6-bin.tar.gz -C /opt/modules/

  • 在 HDFS 上创建相关目录

    bin/hdfs dfs -mkdir -p /tmp
    bin/hdfs dfs -mkdir -p /user/hive/warehouse
    bin/hdfs dfs -chmod g+w /tmp
    bin/hdfs dfs -chmod g+w /user/hive/warehouse

  • 在 conf/hive-env.sh 中配置 HADOOP_HOME 和 HIVE_CONF_DIR

2. MySQL 安装

参考:https://www.cnblogs.com/huangxinyuan650/p/6360464.html

  • 创建用户名,密码

    mysqladmin -u root password 123456

  • 登录

    mysql -uroot -p123456

  • 设置远程登陆权限

    grant all privileges on . to ‘root’@’%’ identified by ‘123456’;

  • 修改 user 表,删除用户信息,防止分布式环境下登录失败

    delete from user where host=’127.0.0.1’;

  • 刷新信息并退出

    flush privileges;
    quit;

  • 重启

    service mysqld restart;

3. Hive 使用 MySQL 数据库

  • 修改 Hive 设置

    cd conf/
    cp hive-default.xml.template hive-site.xml
    vim hive-site.xml

  • Shell 操作

    :,$d // 删除当前行至文档末尾

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<configuration>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://CentOS01:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
</configuration>

4. Hive 使用

  • 启动 Hive

    bin/hive
    show databases;

报错

1
WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

解决
修改 hive-site.xml

1
2
3
4
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://CentOS01:3306/hive?useSSL=false&amp;createDatabaseIfNotExist=true</value>
</property>

报错

1
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

解决

bin/schematool -dbType mysql -initSchema

支持一下
扫一扫,支持forsigner
  • 微信扫一扫
  • 支付宝扫一扫