Hive安装与配置详解
Hive安裝與配置詳解
hive安裝和配置
hive的測試
hive安裝和配置
安裝
一:下載hive——地址:http://mirror.bit.edu.cn/apache/hive/
這里以hive-2.1.1為例子,如圖:
將hive解壓到/usr/local下:
[root@s100 local]# tar -zxvf apache-hive-2.1.1-bin.tar.gz -C /usr/local/將文件重命名為hive文件:
mv apache-hive-2.1.1-bin hive?修改環境變量/etc/profile:
#hiveexport HIVE_HOME=/usr/local/hiveexport PATH=$PATH:$HIVE_HOME/bin執行source /etc.profile:
source /etc.profile:執行hive --version? 可能會報?
Cannot find hadoop installation: $HADOOP_HOME or $HADOOP_PREFIX must be set or hadoop must be in the path解決方案??
修改? ? hive/conf/hive-env.sh文件里加下面的內容:
Export HADOOP_HOME=/home/local/hadoop?source hive-env.sh
?source hive-env.sh現在可以執行這個??hive --version 就ok了
修改hive-site.xml:
這里沒有,我們就以模板復制一個:??
cp hive-default.xml.template hive-site.xml vim hive-site.xml1.配置hive-site.xml(第5點的后面有一個單獨的hive-site.xml配置文件,這個如果有疑問可以用后面的配置文件,更容易明白)
主要是mysql的連接信息(在文本的最開始位置)
這里有個坑:
? ?需要把hive-site.xml中的其他配置信息刪除掉,只保留,我們復制的這些信息。
光標 放在??<!-- 到此結束代碼 -->? 的下一行??
鍵盤輸入? ?700dd? 就會把光標一下的刪除掉,??
補齊 多刪除掉的??
</configuration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. --><configuration><!-- WARNING!!! This file is auto generated for documentation purposes ONLY! --><!-- WARNING!!! Any changes you make to this file will be ignored by Hive. --><!-- WARNING!!! You must make your changes in hive-site.xml instead. --><!-- Hive Execution Parameters --><!-- 插入一下代碼 --><property><name>javax.jdo.option.ConnectionUserName</name>用戶名(這4是新添加的,記住刪除配置文件原有的哦!)<value>root</value></property><property><name>javax.jdo.option.ConnectionPassword</name>密碼<value>123456</value></property><property><name>javax.jdo.option.ConnectionURL</name>mysql<value>jdbc:mysql://192.168.1.68:3306/hive</value></property><property><name>javax.jdo.option.ConnectionDriverName</name>mysql驅動程序<value>com.mysql.jdbc.Driver</value><!--這個驅動有變化,這個已經作廢提示,請使用 com.mysql.cj.jdbc.Driver--></property><!-- 到此結束代碼 --><property><name>hive.exec.script.wrapper</name><value/><description/></property>MySQL :: Download MySQL Connector/J (Archived Versions)
2.復制mysql的驅動程序到hive/lib下面(這里已經拷貝好了)
[root@s100 lib]# ll mysql-connector-java-5.1.18-bin.jar -rw-r--r-- 1 root root 789885 1月 4 01:43 mysql-connector-java-5.1.18-bin.jar3.在mysql中hive的schema(在此之前需要創建mysql下的hive數據庫)初始化schema信息
需要確保你的mysql 放開遠程連接的權限。
# 使用mysql數據庫
use mysql;
# 查看系統表
show tables;
# 查看系統用戶表
select * from user;
# 設置允許任意遠程訪問
update user set host = '%' where user = 'root';
# 刷新內存中的權限,就不用重啟mysql服務了
flush PRIVILEGES;
4.執行hive命令
[root@localhost hive]# hive成功進入hive界面,hive配置完成
5.查詢mysql(hive這個庫是在 schematool -dbType mysql -initSchema 之前創建的!)
備注 (這里不計入正文不要重復配置hive-site.xml)
配置文件hive-site.xml
這里不得不說一下,如果你的 schematool -dbType mysql -initSchema 并沒有執行成功怎么辦,小博主昨天在這卡了一天,最后根據偉大的百度和hive官方文檔,直接寫了一個hive-site.xml配置文本:
?
那我們做這些事干什么的呢,下面小段測試大家感受一下
hive測試:
備注:這里是第二個配置文件的演示:所以數據庫名稱是hahive數據庫!
1.需要知道現在的hadoop中的HDFS存了什么
2.進入hive并創建一個測試庫和測試表
[root@localhost conf]# hive創建庫:
1 hive> create database hive_1; 2 OK 3 Time taken: 1.432 seconds顯示庫: 1 hive> show databases; 2 OK 3 default 4 hive_1 5 Time taken: 1.25 seconds, Fetched: 2 row(s)創建庫成功!
3.查詢一下HDFS有什么變化
?多了一個庫hive_1
1 mysql> use hahive;4.在hive_1下創建一個表hive_01
HDFS下的情況:
?Mysql截圖如下:
總結
以上是生活随笔為你收集整理的Hive安装与配置详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: visio对象放入word显示不全_办公
- 下一篇: Express框架开发知识点总结