1 Install MySQL
Steps to install mysql8.0 in ubuntu20.04_023's Xiao Chen's blog-CSDN blog
After installation:
First log in to mysql:
Create database hive
create database hive;
Create hive user:
create user 'hive'@'%' IDENTIFIED WITH mysql_native_password BY '123456789';
Authorization:
GRANT ALL PRIVILEGES ON *.* TO hive@'%' WITH GRANT OPTION;
#刷新权限
flush privileges;
Modify /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0 #原127.0.0.1 修改为0.0.0.0
mysqlx-bind-address = 127.0.0.1
Restart mysql service
sudo service mysql restart
2 Install hive
下载地址Index of /hivehttps://dlcdn.apache.org/hive/
1After decompression, rename it to hive
2Configure configuration environment variables
sudo vim ~/.bashrc
Add to
export HIVE_HOME=/usr/local/hive#自己的安装路径
export PATH=$PATH:${HIVE_HOME}/bin:${HIVE_HOME}/lib:
then
source ~/.bashrc
3 Enter ${HIVE_HOME}/conf:
Create hive-site.xml and add the following content:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<!-- jdbc 连接的 URL -->
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop200:3306/hive?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<!-- jdbc 连接的 Driver-->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<!-- jdbc 连接的 username-->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description>
</property>
<!-- jdbc 连接的 password -->
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456789</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>True</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>
Then continue to create hive-env.sh in ${HIVE_HOME}/conf and add the following content:
export HADOOP_HOME=/usr/local/hadoop #你自己的hadoop路径
export HIVE_CONF_DIR=/usr/local/hive/conf #你自己的hive路径
Finally, move the downloaded and unzipped mysql driver jar package to ${HIVE_HOME}/lib
Download address:MySQL :: Download Connector/J
4Execute the following command under ${HIVE_HOME}/bin (run hdfs in advance):
schematool -dbType mysql -initSchema
schematool -dbType mysql -info
hive
5 Verify whether hive is configured properly
Start hive:
Create the table to see if it succeeds:
create table test1(id int, name string);
Show database:
show databases;