日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Hive安装与配置详解

發布時間:2023/12/9 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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.xml

1.配置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.jar

3.在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;

1 [root@s100 bin]# pwd2 /usr/local/hive/bin3 [root@s100 bin]# schematool -dbType mysql -initSchema

4.執行hive命令

[root@localhost hive]# hive

成功進入hive界面,hive配置完成
5.查詢mysql(hive這個庫是在 schematool -dbType mysql -initSchema 之前創建的!)

1 [root@localhost ~]# mysql -uroot -p1234562 Welcome to the MySQL monitor. Commands end with ; or \g.3 Your MySQL connection id is 104 Server version: 5.1.73 Source distribution5 6 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.7 8 Oracle is a registered trademark of Oracle Corporation and/or its9 affiliates. Other names may be trademarks of their respective10 owners.11 12 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.13 14 mysql> use hive15 Reading table information for completion of table and column names16 You can turn off this feature to get a quicker startup with -A17 18 Database changed19 mysql> show tables;20 +---------------------------+21 | Tables_in_hive |22 +---------------------------+23 | AUX_TABLE |24 | BUCKETING_COLS |25 | CDS |26 | COLUMNS_V2 |27 | COMPACTION_QUEUE |28 | COMPLETED_COMPACTIONS |

備注 (這里不計入正文不要重復配置hive-site.xml)
配置文件hive-site.xml
這里不得不說一下,如果你的 schematool -dbType mysql -initSchema 并沒有執行成功怎么辦,小博主昨天在這卡了一天,最后根據偉大的百度和hive官方文檔,直接寫了一個hive-site.xml配置文本:
?

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://localhost:3306/hahive</value>(mysql地址localhost)</property><property><name>javax.jdo.option.ConnectionDriverName</name>(mysql的驅動)<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>

那我們做這些事干什么的呢,下面小段測試大家感受一下
hive測試:
備注:這里是第二個配置文件的演示:所以數據庫名稱是hahive數據庫!
1.需要知道現在的hadoop中的HDFS存了什么

[root@localhost conf]# hadoop fs -lsr /

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安装与配置详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。