Hive安装

1.依赖(需要提前安装hadoop)

https://blog.csdn.net/weixin_43291055/article/details/106480902

2.下载Hive

hive和hadoop版本:https://blog.csdn.net/weixin_40803329/article/details/80801216

https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.3.7/

3.安装

(1)修改环境变量 vi /etc/profile

export JAVA_HOME=/opt/jdk1.8.0_251
export HADOOP_HOME=/opt/hadoop-2.9.2
export HIVE_HOME=/opt/apache-hive-2.3.7-bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin
(2)配置hive  cd /opt/apache-hive-2.3.7-bin/conf

cp hive-env.sh.template hive-env.sh
cp hive-default.xml.template hive-default.xml
cp hive-log4j2.properties.template hive-log4j2.properties
cp hive-exec-log4j2.properties.template hive-exec-log4j2.properties

(3) 创建hdfs目录  开启hadoop:start-all.sh

hdfs dfs -mkdir -p /usr/hive/warehouse
(此处的-p指直接创建多级目录,一次创建成功)
hdfs dfs -mkdir -p /usr/hive/tmp
hdfs dfs -mkdir -p /usr/hive/log
hdfs dfs -chmod g+w /usr/hive/warehouse
(设置权限)
hdfs dfs -chmod g+w /usr/hive/tmp
hdfs dfs -chmod g+w /usr/hive/log

(4)修改hive-env.sh(conf 目录下)

export JAVA_HOME=/opt/jdk1.8.0_251
export HIVE_HOME=/opt/apache-hive-2.3.7-bin
export HADOOP_HOME=/opt/hadoop-2.9.2
export HIVE_CONF_DIR=/opt/apache-hive-2.3.7-bin/conf

(5)修改hive-site.xml



javax.jdo.option.ConnectionURL
jdbc:mysql://localhost:3306/hive
JDBC connect string for a JDBC metastore

 

javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore

 

javax.jdo.option.ConnectionUserName
root
Username to use against metastore database

 

javax.jdo.option.ConnectionPassword
123
password to use against metastore database


hive.exec.local.scratchdir
/usr/local/hive
Local scratch space for Hive jobs

 

hive.downloaded.resources.dir
/usr/local/hive/hive-downloaded-addDir/
Temporary local directory for added resources in the remote file system.

 

hive.querylog.location
/usr/local/hive/querylog-location-addDir/
Location of Hive run time structured log file

 

hive.server2.logging.operation.log.location
/usr/local/hive/hive-logging-operation-log-addDir/
Top level directory where operation logs are stored if logging functionality is enabled

(6)修改hive-log4j.properties

hive.log.dir=/usr/local/tmp

(7)mysql配置  安装参照:https://blog.csdn.net/weixin_43291055/article/details/100009777

mysql -u root -p

mysql> create database hive;
mysql> show databases;
mysql> grant all on hive.* to 'hive'@'%' identified by 'hive';(将所有数据库的所有表的所有权限赋给hive用户,后面的hive是配置hive-site.xml中配置的连接密码)
mysql> flush privileges;(刷新mysql系统权限关系表)
mysql> exit;

(8)下载连接 https://dev.mysql.com/downloads/connector/j/

Hive安装_第1张图片

将 mysql-connector-java-8.0.20.jar 拷贝到lib目录下

(9)数据库初始化

schematool -initSchema -dbType mysql

(10)启动

hive --service metastore
hive

Hive安装_第2张图片

 

参考:

https://www.cnblogs.com/xiaolan-Lin/p/11358901.html

https://mp.weixin.qq.com/s?src=11×tamp=1591580470&ver=2387&signature=2ebm9Unlmxs2YsECJIvudFyTDZjXKo2hnWpRn1N7E3OKt2A0ejSM313Wo8TTnQIZC2FtL*eEyqbWXJgyXkddx-nmD2W-o5GEghXKQFam3uAI5cbBAbbohjqYoAtdUaXq&new=1

你可能感兴趣的:(Hive)