# 大数据之Hive安装配置

参考:https://blog.csdn.net/qq_29983883/article/details/108798233

在安装hive之前需要安装hadoop,hadoop安装地址传送门

安装包准备

下载的是hive-3.1.3,传送门
下载mysql-connector-java-5.1.46.jar,传送门

hive默认将元数据存储到本地内嵌的Derby数据库中,但是Derby不支持多会话链接,因此我们使用mysql数据库来存储hive的元数据。配置完成hiveSQL的元数据库之后再开始安装、配置hive。

img

一、安装mysql

rpm -qa | grep mariadb | xargs rpm -e --nodeps
yum install mariadb mariadb-server
不在阐述更多的mysql相关安装教程,请参考网络文章

二、在Mysql中创建hive元数据数据库

创建hive数据库

mysql> create database hive;

将hive数据库的所有权限赋给hive用户

mysql>create user 'hive'@'%' identified by 'hive123456';

mysql>grant all privileges on *.* to 'hive'@'%' with grant option;

mysql>flush privileges;

mysql>use hive;

mysql>select user,host from mysql.user;

三、安装hive

下载最新稳定版hive

wget https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz --no-check-certificate

解压缩

/export/servers/tar -zxvf apache-hive-3.1.3-bin.tar.gz -C /export/servers/ && mv /export/servers/apache-hive-3.1.3-bin/ /export/servers/apache-hive

1、环境添加
将hive的文件路径加入到/etc/profile

export HIVE_HOME=/export/servers/apache-hive
export HIVE_CONF_DIR=/export/servers/apache-hive/conf

添加完毕后,执行source /etc/profile

2、添加新的包
将mysql-connector-java-5.1.46.jar文件发送到/export/servers/apache-hive/lib

3、修改hive-env.sh

将hive-env.sh.template修改为hive-env.sh,使用mv hive-env.sh.template hive-env.sh,在hive-env.sh添加下面内容

export JAVA_HOME=/java/jdk1.8.0_161
export HADOOP_HOME=/export/servers/hadoop
export HIVE_HOME=/export/servers/apache-hive
export HIVE_CONF_DIR=/export/servers/apache-hive/conf

4、添加hive-site.xml

在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://192.168.48.139:3306/hive?createDatabaseIfNotExist=true</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>root</value>
    <description>username to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>Mysql@1234</value>
    <description>password to use against metastore database</description>
  </property>
</configuration>

测试数据库

执行../bin/schematool -dbType mysql -initSchema命令,会以下错误

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
    at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
    at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
    at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:536)
    at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:554)
    at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:448)
    at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141)
    at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5099)
    at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:97)
    at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:81)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:699)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:236)

这主要是因为hadoop/share/hadoop/common/lib目录下的guava和/apache-hive-3.1.2-bin/lib目录下的guava版本不同。需要将版本将hadoop高版本的guava拷贝到hive的目录下,删除hive低的版本。

重新执行../bin/schematool -dbType mysql -initSchema,就可以初始化成功

解决hive启动出现WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+,问题

Initialization script completed
Mon Jul 04 01:03:13 PDT 2022 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.
schemaTool completed

hive-site.xml中的

jdbc:mysql://192.168.48.139:3306/hive?createDatabaseIfNotExist=true

改为

jdbc:mysql://192.168.48.139:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false

重新启动后,那么长的就消失了。

补知识
Unexpected character ‘=’ (code 61); expected a semi-colon after the reference for entity 'useUnicode
Xml文件中不能使用&,要使用他的转义&来代替。

hive3.1.2在进行初始化的时候出现Error: Table ‘CTLGS‘ already exists (state=42S01,code=1050)的错误提示。

以上说明在前两次执行的时候已经初始化过数据库,表都已经存在

解决方案:

删掉hive数据库

mysql> drop database hive;
mysql> create database hive;

重新初始化hive

bin/schematool -dbType mysql -initSchema
posted @   Jerry·  阅读(207)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!

阅读目录(Content)

此页目录为空

点击右上角即可分享
微信分享提示