0、安裝前提
- 安裝配置jdk與hadoop
- 安裝配置好mysql
1、下載上傳
- 下載hive,地址:http://mirror.bit.edu.cn/apache/hive/
- 上傳到指定位置
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:
- vi /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
- sources /etc/profile
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、驅動拷貝
- 在官網下載mysql-connector-java-5.1.49.jar
- 復制Mysql的程序驅動mysql-connector-java-5.1.49.jar到hive/lib下
7、創建Mysql下的hive數據庫
create database hive;
mysql> create database hive;
Query OK, 1 row affected (0.01 sec)
- 在Mysql中hive的schema創建
schematool -dbType mysql -initSchema
schemaTool completed
- 這里會出現guava jar包的版本問題,解決方法參考這里
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 -ADatabase 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>