0、安装前提
1、下载上传
scp apache-hive-3.1.2-bin.tar.gz root@Carlota1:/usr/local/apps
2、解压安装
tar -zxvf apache-hive-3.1.2-bin.tar.gz
mv apache-hive-3.1.2-bin hive-3.1.2
3、修改环境变量/etc/profile:
#hive
export HIVE_HOME=/usr/local/apps/hive-3.1.2
export PATH=$PATH:$HIVE_HOME/bin
export HIVE_CONF_DIR=/usr/local/apps/hive-3.1.2/conf
4、查看版本,验证安装成功
hive --version
5、配置
cd /usr/local/apps/hive-3.1.2/conf
vim hive-site.xml
添加以下内容<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://Carlota1:3306/hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456!</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
6、驱动拷贝
7、创建Mysql下的hive数据库
create database hive;
mysql> create database hive;
Query OK, 1 row affected (0.01 sec)
schematool -dbType mysql -initSchema
schemaTool completed
8、测试
hive
create database hive_1;
hive> create database hive_test;
OK
Time taken: 0.156 seconds
hive> show databases;
OK
default
hive_test
Time taken: 0.064 seconds, Fetched: 2 row(s)
9、观察Mysql下hive数据库的变化:
mysql> use hive;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from DBS;
+-------+-----------------------+-------------------------------------------------------+-----------+------------+------------+-----------+
| DB_ID | DESC | DB_LOCATION_URI | NAME | OWNER_NAME | OWNER_TYPE | CTLG_NAME |
+-------+-----------------------+-------------------------------------------------------+-----------+------------+------------+-----------+
| 1 | Default Hive database | hdfs://Carlota1:9000/user/hive/warehouse | default | public | ROLE | hive |
| 2 | NULL | hdfs://Carlota1:9000/user/hive/warehouse/hive_test.db | hive_test | root | USER | hive |
+-------+-----------------------+-------------------------------------------------------+-----------+------------+------------+-----------+
2 rows in set (0.00 sec)
mysql>