- 下载
访问官方网站https://hive.apache.org/
点击downloads
点击Download a release now!
点击https://dlcdn.apache.org/hive/
选择最新的稳定版
复制最新的url
在linux执行下载命令
wget https://dlcdn.apache.org/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz
2.解压
tar -zxvf apache-hive-3.1.3-bin.tar.gz
重命名
sudo mv apache-hive-3.1.3-bin apache-hive-3.1.3
移动到/usr/local
sudo mv apache-hive-3.1.3 /usr/local/apache-hive-3.1.3
cd /usr/local/apache-hive-3.1.3
3.配置环境变量
在profile.d下新增配置文件hive_profile.sh
sudo vi /etc/profile.d/hive_profile.sh
内容如下
export HIVE_HOME=/usr/local/apache-hive-3.1.3
export PATH=PATH:HIVE_HOME/bin
刷新环境变量
source /etc/profile
4.搭建mysql并在mysql中创建hive数据库
5.Hive元数据配置到MySQL
5.1上传mysql驱动mysql-connector-java-8.0.21.jar并移动到/usr/local/apache-hive-3.1.3/lib/
sudo mv /home/hadoop/mysql-connector-java-8.0.21.jar /usr/local/apache-hive-3.1.3/lib/
5.2在/usr/local/apache-hive-3.1.3/conf下新增hive-site.xml文件
sudo vi /usr/local/apache-hive-3.1.3/conf/hive-site.xml
内容如下
<configuration>
<!-- 数据库连接的URL -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop-master:3306/hive?useSSL=false</value>
</property>
<!-- 数据库连接的Driver-->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<!-- 数据库连接的username-->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<!-- 数据库连接的password -->
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>1231233</value>
</property>
<!-- Hive元数据存储版本的验证 -->
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<!--元数据存储授权-->
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<!-- Hive默认在HDFS的工作目录 -->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
</configuration>
5.3初始化Hive
schematool -initSchema -dbType mysql -verbose
6.启动Hive并测试
hive
查看数据库
show databases;
查看表
show tables;