1. 用brew安装
brew install hive
2. mysql中创建元数据库
安装mysql,执行下面命令
create database metastore;
create user 'hive'@'localhost' identified by '123456';
grant select,insert,update,delete,alter,create,index,references on metastore.* to 'hive'@'localhost';
flush privileges;
3. 创建修改配置
在libexec/conf 中,把hive-default.xml.template 复制一份重新命名为hive-site.xml
javax.jdo.option.ConnectionURL
jdbc:mysql://localhost/metastore
javax.jdo.option.ConnectionDriverName
com.mysql.cj.jdbc.Driver
javax.jdo.option.ConnectionUserName
hive(填上述mysql中创建的用户名)
javax.jdo.option.ConnectionPassword
123456(填上述mysql中创建的用户密码)
hive.exec.local.scratchdir
/tmp/hive
hive.querylog.location
/tmp/hive
hive.downloaded.resources.dir
/tmp/hive
hive.server2.logging.operation.log.location
/tmp/hive
4. 去网站下载mysql的connect jar 复制到lib中
https://dev.mysql.com/downloads/connector/j/
mac 的选择这个independent,解压后把jar复制到libexec/lib 中
5. 环境变量设置
export ANDROID_HOME=~/Library/Android/sdk
# added by Anaconda3 5.1.0 installer
export PATH="/Users/walle/anaconda3/bin:$PATH"
#sqoop
export SQOOP_HOME=/usr/local/Cellar/sqoop/1.4.6/libexec
export PATH=$PATH:$SQOOP_HOME/bin
# hadoop
export HADOOP_HOME=/usr/local/Cellar/hadoop/3.1.0/libexec
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
#hive
export HIVE_HOME=/usr/local/Cellar/hive/hive/2.3.1/libexec
export PATH=$PATH:$HIVE_HOME/bin
export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin
for f in $HADOOP_HOME/share/hadoop/common/hadoop-*.jar;do
export CLASSPATH=$CLASSPATH:$f
done
for f in $HADOOP_HOME/share/hadoop/hdfs/hadoop-*.jar;do
export CLASSPATH=$CLASSPATH:$f
done
for f in $HADOOP_HOME/share/hadoop/mapreduce/hadoop-*.jar;do
export CLASSPATH=$CLASSPATH:$f
done
for f in $HADOOP_HOME/share/hadoop/yarn/hadoop-*.jar;do
export CLASSPATH=$CLASSPATH:$f
done
export CLASSPATH=$CLASSPATH:$HADOOP_HOME/share/common/lib:$HADOOP_HOME/share/hdfs/lib:$HADOOP_HOME/share/mapreduce/lib:$HADOOP_HOME/share/tools/lib:$HADOOP_HOME/share/yarn/lib
6. 初始化库
在bin目录下执行下面的初始化
schematool -initSchema -dbType mysql
7. 运行hive
hive