赞
踩
1)把apache-hive-3.1.2-bin.tar.gz上传到linux的/opt/software目录下
2)解压apache-hive-3.1.2-bin.tar.gz到/opt/programs/目录下面
tar -zxvf /opt/software/apache-hive-3.1.2-bin.tar.gz -C /opt/programs/
3)修改apache-hive-3.1.2-bin.tar.gz的名称为hive
mv /opt/programs/apache-hive-3.1.2-bin/ /opt/programs/hive
4)修改/etc/profile.d/my_env.sh,添加环境变量
vim /etc/profile.d/my_env.sh
添加内容
- #HIVE_HOME
-
- export HIVE_HOME=/opt/programs/hive
-
- export PATH=$PATH:$HIVE_HOME/bin
重启Xshell对话框或者source一下 /etc/profile.d/my_env.sh文件,使环境变量生效
source /etc/profile.d/my_env.sh
5)解决日志Jar包冲突,进入/opt/programs/hive/lib目录
mv log4j-slf4j-impl-2.10.0.jar log4j-slf4j-impl-2.10.0.jar.bak
将MySQL的JDBC驱动拷贝到Hive的lib目录下
cp /opt/software/mysql-connector-java-5.1.27-bin.jar /opt/programs/hive/lib/
在$HIVE_HOME/conf目录下新建hive-site.xml文件
vim hive-site.xml
添加如下内容
- <?xml version="1.0"?>
-
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
- <configuration>
-
- <property>
-
- <name>javax.jdo.option.ConnectionURL</name>
-
- <value>jdbc:mysql://hadoop01:3306/metastore?useSSL=false&useUnicode=true&characterEncoding=UTF-8</value>
-
- </property>
-
-
-
- <property>
-
- <name>javax.jdo.option.ConnectionDriverName</name>
-
- <value>com.mysql.jdbc.Driver</value>
-
- </property>
-
-
-
- <property>
-
- <name>javax.jdo.option.ConnectionUserName</name>
-
- <value>root</value>
-
- </property>
-
-
-
- <property>
-
- <name>javax.jdo.option.ConnectionPassword</name>
-
- <value>root</value>
-
- </property>
-
-
-
- <property>
-
- <name>hive.metastore.warehouse.dir</name>
-
- <value>/user/hive/warehouse</value>
-
- </property>
-
-
-
- <property>
-
- <name>hive.metastore.schema.verification</name>
-
- <value>false</value>
-
- </property>
-
-
-
- <property>
-
- <name>hive.server2.thrift.port</name>
-
- <value>10000</value>
-
- </property>
-
-
-
- <property>
-
- <name>hive.server2.thrift.bind.host</name>
-
- <value>hadoop01</value>
-
- </property>
-
-
-
- <property>
-
- <name>hive.metastore.event.db.notification.api.auth</name>
-
- <value>false</value>
-
- </property>
-
-
-
- <property>
-
- <name>hive.cli.print.header</name>
-
- <value>true</value>
-
- </property>
-
-
-
- <property>
-
- <name>hive.cli.print.current.db</name>
-
- <value>true</value>
-
- </property>
-
- </configuration>
1)登陆MySQL
mysql -uroot -proot
2)新建Hive元数据库
mysql> create database metastore;
3)初始化Hive元数据库
$ schematool -initSchema -dbType mysql -verbose
4)修改元数据库字符集
Hive元数据库的字符集默认为Latin1,由于其不支持中文字符,故若建表语句中包含中文注释,会出现乱码现象。如需解决乱码问题,须做以下修改。
修改Hive元数据库中存储注释的字段的字符集为utf-8
(1)字段注释
mysql> alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8;
(2)表注释
mysql> alter table TABLE_PARAMS modify column PARAM_VALUE mediumtext character set utf8;
4)退出mysql
mysql> quit;
1)启动Hive客户端
bin/hive
2)查看一下数据库
hive (default)> show databases;
OK
database_name
default
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。