赞
踩
目录
第五步:Hive的配置文件(hive-site.xml 和hive-env.sh)
问题一:Hive 执行数据初始化(hive --service metastore),总是报错。
问题二:%HIVE_HOME%/bin启动hive --service hiveserver2报错
Hadoop:3.3.0
Hive:3.1.2.bin.tar.gz 版本
官网下载地址:https://dlcdn.apache.org/hive/,嫌慢可以在CSDN上找我的资源https://download.csdn.net/download/xieedeni/24882711,官方地址下载真的慢!
解压Hive.tar.gz 至指定文件夹目录,HIVE_HOME和修改path增加hive的bin路径
注意:Hive 的Hive_x.x.x_bin.tar.gz 版本在windows 环境中缺少 Hive的执行文件和运行程序。
解决版本:下载低版本Hive(apache-hive-1.0.0-src),下载地址http://archive.apache.org/dist/hive/hive-1.0.0/,将bin 目录替换目标对象(D:\work\soft\apache-hive-3.1.2-bin)原有的bin目录。
截图如下:apache-hive-1.0.0-src\bin 目录 结构
下载和拷贝一个mysql-connector-java-8.0.x.jar
到$HIVE_HOME/lib
目录下:
mysql-connector-java-8.0.21.jar 下载地址:https://dev.mysql.com/downloads/file/?id=496589
配置文件目录%HIVE_HOME%\conf有4个默认的配置文件模板拷贝成新的文件名
hive-default.xml.template -----> hive-site.xml
hive-env.sh.template -----> hive-env.sh
hive-exec-log4j.properties.template -----> hive-exec-log4j2.properties
hive-log4j.properties.template -----> hive-log4j2.properties
后面配置文件用到,my_hive文件夹,在这个文件夹下建scratch_dir,resources_dir,querylog_dir,operation_logs_dir
编辑conf\hive-site.xml 文件
- <!--hive的临时数据目录,指定的位置在hdfs上的目录-->
- <property>
- <name>hive.metastore.warehouse.dir</name>
- <value>/user/hive/warehouse</value>
- <description>location of default database for the warehouse</description>
- </property>
-
-
-
- <!--hive的临时数据目录,指定的位置在hdfs上的目录-->
- <property>
- <name>hive.exec.scratchdir</name>
- <value>/tmp/hive</value>
- <description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, with ${hive.scratch.dir.permission}.</description>
- </property>
-
-
-
- <!-- scratchdir 本地目录 -->
- <property>
- <name>hive.exec.local.scratchdir</name>
- <value>D:/work/soft/apache-hive-3.1.2-bin/my_hive/scratch_dir</value>
- <description>Local scratch space for Hive jobs</description>
- </property>
-
- <!-- resources_dir 本地目录 -->
- <property>
- <name>hive.downloaded.resources.dir</name>
- <value>D:/work/soft/apache-hive-3.1.2-bin/my_hive/resources_dir/${hive.session.id}_resources</value>
- <description>Temporary local directory for added resources in the remote file system.</description>
- </property>
-
- <!-- querylog 本地目录 -->
- <property>
- <name>hive.querylog.location</name>
- <value>D:/work/soft/apache-hive-3.1.2-bin/my_hive/querylog_dir</value>
- <description>Location of Hive run time structured log file</description>
- </property>
-
- <!-- operation_logs 本地目录 -->
- <property>
- <name>hive.server2.logging.operation.log.location</name>
- <value>D:/work/soft/apache-hive-3.1.2-bin/my_hive/operation_logs_dir</value>
- <description>Top level directory where operation logs are stored if logging functionality is enabled</description>
- </property>
-
- <!-- 数据库连接地址配置 -->
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://127.0.0.1:3306/hive?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true</value>
- <description>
- JDBC connect string for a JDBC metastore.
- </description>
- </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>123456</value>
- <description>password to use against metastore database</description>
- </property>
-
- <!-- 解决 Caused by: MetaException(message:Version information not found in metastore. ) -->
- <property>
- <name>hive.metastore.schema.verification</name>
- <value>false</value>
- <description>
- Enforce metastore schema version consistency.
- True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
- schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
- proper metastore schema migration. (Default)
- False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
- </description>
- </property>
-
- <!-- 自动创建全部 -->
- <!-- hive Required table missing : "DBS" in Catalog""Schema" 错误 -->
- <property>
- <name>datanucleus.schema.autoCreateAll</name>
- <value>true</value>
- <description>Auto creates necessary schema on a startup if one doesn't exist. Set this to false, after creating it once.To enable auto create also set hive.metastore.schema.verification=false. Auto creation is not recommended for production use cases, run schematool command instead.</description>
- </property>
编辑(hive-env.sh 文件)
- # Set HADOOP_HOME to point to a specific hadoop install directory
- export HADOOP_HOME=D:\work\soft\apache-hive-3.1.2-bin
-
- # Hive Configuration Directory can be controlled by:
- export HIVE_CONF_DIR=D:\work\soft\apache-hive-3.1.2-bin\conf
-
- # Folder containing extra libraries required for hive compilation/execution can be controlled by:
- export HIVE_AUX_JARS_PATH=D:\work\soft\apache-hive-3.1.2-bin\lib
- hadoop fs -mkdir /tmp
- hadoop fs -mkdir /user/
- hadoop fs -mkdir /user/hive/
- hadoop fs -mkdir /user/hive/warehouse
- hadoop fs -chmod g+w /tmp
- hadoop fs -chmod g+w /user/hive/warehouse
或者使用命令:
- hdfs dfs -mkdir /tmp
-
- hdfs dfs -chmod -R 777 /tmp
注意编码格式:latin1
上面的准备工作做完之后,可以进行Hive
的元数据库初始化,在%HIVE_HOME%/bin
目录下执行下面的脚本:
hive --service metastore
失败了
提示配置文件3215行错误
成功后应该是这样的
再执行语句
hive
或者调出CMD输入命令hive.cmd
执行一个语句测试一下吧:
create table stu(id int,name string);
在http://localhost:50070/explorer.html#/user/hive/warehouse 查看一下
说明安装成功了。
到此,安装HIVE成功!!
解决思路:通过Hive 自身携带的脚本,完成Hive 数据库的初始化。
Hive 携带脚本的文件位置(%HIVE_HOME%\scripts\metastore\upgrade),选择执行SQL的版本,如下截图:
选择需要执行的Hive版本(Hive_x.x.x)所对应的sql 版本(hive-schema-x.x.x.mysql.sql)
说明:我选择Hive版本时3.1.2,所以我选项的对应sql 版本hive-schema-3.1.0.mysql.sql 脚本。
拿到mysql里执行即可。
org.apache.thrift.transport.TTransportException: Could not create ServerSocket on address 0.0.0.0/0.0.0.0:10000.
所以对hive-site.xml做以配置:
- <property>
- <name>hive.server2.thrift.http.port</name>
- <value>10001</value>
- </property>
- <property>
- <name>hive.server2.thrift.port</name>
- <value>10005</value>
- </property>
又报错
hive-site.xml搜索:<name>hive.server2.active.passive.ha.enable</name>
成功了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。