Mac安装Hive
恶作剧 hodoop
# 下载地址
官网:🔗 https://archive.apache.org/dist/hive/
安装版本:3.1.3-bin.tar.gz

# 配置Hive
我的Hive安装目录放在了 /Users/xu/Documents/module/apache-hive-3.1.3/下
# 添加环境变量
打开配置文件
vim ~/.zshrc1追加Hive环境变量
export HIVE_HOME=/Users/xu/Documents/module/apache-hive-3.1.3 export PATH=$HIVE_HOME/bin:$PATH1
2刷新环境变量
source ~/.zshrc1查看hive版本
hive --version #出现报错信息后是因为hive和hadoop中的SLF4J的jar包重复了,删除一个就好,我删除了hive中的jar SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Users/xu/Documents/module/apache-hive-3.1.3/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/Users/xu/Documents/module/hadoop-3.4.1/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Hive 3.1.3 Git git://MacBook-Pro.fios-router.home/Users/ngangam/commit/hive -r 4df4d75bf1e16fe0af75aad0b4179c34c07fc975 Compiled by ngangam on Sun Apr 3 16:58:16 EDT 2022 From source with checksum 5da234766db5dfbe3e92926c9bbab2af1
2
3
4
5
6
7
8
9
10
11
12
# 更改hive配置文件
重命名conf文件夹下
hive-default.xml.templatecd /Users/xu/Documents/module/apache-hive-3.1.3/conf mv hive-default.xml.template hive-default.xml1
2conf目录下新建
hive-site.xml文件, 添加内容指定MySQL配置
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true</value> <description>JDBC连接</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>用户名</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>12345678</value> <description>密码</description> </property> </configuration>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 配置Hive数据库
新建数据库
create database hive; CREATE USER 'hive'@'localhost' IDENTIFIED BY '12345678'; GRANT ALL ON *.* TO 'hive'@'localhost'; #刷新mysql系统权限关系表 flush privileges;1
2
3
4
5
6
7
8
9使用Hive的bin目录下
schematool自带工具初始化数据库schematool -dbType mysql -initSchema1
初始化数据库报错,需要在/Users/xu/Documents/module/apache-hive-3.1.3/lib目录下加入MySQL驱动jar包
驱动下载地址:🔗 https://downloads.mysql.com/archives/c-j/


# 启动Hive并访问
进入
bin目录,启动服务cd /Users/xu/Documents/module/apache-hive-3.1.3/bin #后台启动HiveServer2,允许客户端执行Hive查询,默认端口10000 hive --service hiveserver2 & #停止hive hive --service hiveserver2 stop1
2
3
4
5
6
7
8浏览器访问
http://localhost:10002进入Hive的Web界面客户端连接
beeline -u jdbc:hive2://localhost:10000/ -n hive -p hive1