环境:

hadoop 3.1.1

hive 3.1.0

mysql 8.0.11

安装前准备:

准备好mysql-connector-java-8.0.12.jar驱动包

上传hive的tar包并解压

第一步:

进入hive/conf,拷贝hive-env.sh.template 为hive-env.sh,修改部分为第48,51,54行

 # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. # Set Hive and Hadoop environment variables here. These variables can be used
# to control the execution of Hive. It should be used by admins to configure
# the Hive installation (so that users do not have to set environment variables
# or set command line parameters to get correct behavior).
#
# The hive service being invoked (CLI etc.) is available via the environment
# variable SERVICE # Hive Client memory usage can be an issue if a large number of clients
# are running at the same time. The flags below have been useful in
# reducing memory usage:
#
# if [ "$SERVICE" = "cli" ]; then
# if [ -z "$DEBUG" ]; then
# export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit"
# else
# export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit"
# fi
# fi # The heap size of the jvm stared by hive shell script can be controlled via:
#
# export HADOOP_HEAPSIZE=
#
# Larger heap size may be required when running queries over large number of files or partitions.
# By default hive shell scripts use a heap size of (MB). Larger heap size would also be
# appropriate for hive server. # Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/opt/module/hadoop-3.1. # Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/opt/module/hive/conf # Folder containing extra libraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/opt/module/hive/lib

第二步,拷贝hive-default.xml.template为hive-site.xml,主要是一些连接数据库的信息,包括用户名,密码,注意把hive.metastore.schema.verification设置为false

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1:3306/hive?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false&amp;serverTimezone=GMT</value>
<description>JDBC connect string for a JDBC metastore</description>
</property> <property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.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></value>
<description>password to use against metastore database</description>
</property>
<property>
<name>datanucleus.schema.autoCreateAll</name>
<value>true</value>
</property>
</configuration>

第三步:上传mysql驱动包到hive/lib目录下

第四步:在mysql中创建hive数据库

create database hive;

第五步:进入bin目录执行(指定元数据库并进行初始化)

./schematool -dbType mysql -initSchema

第六步:启动hive(要先启动hadoop)

./hive

启动完成后show databases;

注意事项:

1.hive-site.xml中 mysql的驱动名称为com.mysql.cj.jdbc.Driver

2.xml文档中javax.jdo.option.ConnectionURL中&要用&amp;替代,一定要指定字符集,时区

3.我已经提前对数据库的root用户进行授权

4.如果测试hive插入数据,要在hdfs上创建/user/hive/warehouse路径

常见问题:

1../schematool -dbType mysql -initSchema提示server code 255之类的是连接数据库的字符集没指定,failed的话删除hive数据库,重新创建,再次执行此命令即可

2.The server time zone value 'PDT' is unrecognized or represents more than one

时区问题.写成jdbc:mysql://127.0.0.1:3306/hive?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false&amp;serverTimezone=GMT即可

参考https://blog.csdn.net/m0_37520980/article/details/80364884

最新文章

  1. 常见input输入框 点击 发光白色外阴影 focus
  2. ios10新特性-UserNotification
  3. 学习iOS前我们需要知道的事情
  4. Python之异常追踪模块:traceback
  5. TStringList中AddObject使用
  6. Android studio NDK 编译 &quot;$USE_DEPRECATED_NDK=true&quot; 异常问题解决
  7. C#中File类的文件操作方法详解
  8. BZOJ 1856 字符串(组合)
  9. 【重要】ASCII码表
  10. nginx日志分析手机使用频次
  11. axure rp pro 6.5
  12. 基于Geoserver配置多图层地图以及利用uDig来进行样式配置
  13. 【Python】iiacm_filemaker ——简易的.cpp文件创建即初始化脚本,ACMer专用
  14. Xcode旧项目引入CocoaPod遇到的问题与解决
  15. 【移动端web】软键盘兼容问题
  16. java生成32的md5签名串
  17. day05数据类型,数字类型,字符串类型,字符串的操作方法,列表类型的操作方法,可变类型与不可变类型
  18. DB2 的代理 (agent)
  19. Python3学习之路~8.1 socket概念及参数介绍
  20. 20145122《敏捷开发与XP实践 》实验三实验报告

热门文章

  1. 【习题 6-3 UVA - 536】 Tree Recovery
  2. [D3] Reuse Transitions in D3 v4
  3. js进阶 13-7 如何实现滑动面板效果
  4. DIV+CSS学习笔记
  5. Windows下合并tar分卷
  6. Android 最火的高速开发框架AndroidAnnotations使用具体解释
  7. es6三点运算符的用法
  8. swift开发网络篇—利用NSURLSession 发送GET和POST请求
  9. 【b702】字符串的展开
  10. 建立简单的服务器端程序 分类: B1_JAVA 2013-10-08 21:53 503人阅读 评论(0) 收藏