
hive默認將元數據存儲到本地內嵌的Derby數據庫中,但是Derby不支持多會話鏈接,因此我們使用mysql數據庫來存儲hive的元數據。配置完成hiveSQL的元數據庫之后再開始安裝、配置hive。
安裝命令為
sudo apt-get install mysql-server
當出現(xiàn)下面提示選擇的時候輸入y 同意繼續(xù)安裝
hduser@master:~$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.13.0-36 linux-headers-4.13.0-36-generic
linux-headers-4.13.0-41 linux-headers-4.13.0-41-generic
linux-image-4.13.0-36-generic linux-image-4.13.0-41-generic
linux-image-extra-4.13.0-36-generic linux-image-extra-4.13.0-41-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
libipc-sharedcache-perl mailx tinyca
The following NEW packages will be installed:
libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7
mysql-server-core-5.7
0 upgraded, 9 newly installed, 0 to remove and 101 not upgraded.
Need to get 18.1 MB of archives.
After this operation, 161 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
然后安裝繼續(xù)執(zhí)行,輸出如下內容,完成安裝。中間會有讓設置root密碼提示,輸入密碼按向下的方向鍵確認,然后再輸入一次確認密碼
Get:1 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-common all 5.7.22-0ubuntu0.16.04.1 [15.4 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libaio1 amd64 0.3.110-2 [6,356 B]
Get:3 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-client-core-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [6,425 kB]
Get:4 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-client-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [1,673 kB]
Get:5 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-server-core-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [7,268 kB]
Get:6 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libevent-core-2.0-5 amd64 2.0.21-stable-2ubuntu0.16.04.1 [70.6 kB]
Get:7 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-server-5.7 amd64 5.7.22-0ubuntu0.16.04.1 [2,583 kB]
Get:8 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libhtml-template-perl all 2.95-2 [60.4 kB]
Get:9 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 mysql-server all 5.7.22-0ubuntu0.16.04.1 [10.8 kB]
Fetched 18.1 MB in 1min 56s (155 kB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 285825 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.7.22-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-common (5.7.22-0ubuntu0.16.04.1) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../libaio1_0.3.110-2_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-2) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.22-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.22-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.22-0ubuntu0.16.04.1) ...
Selecting previously unselected package libevent-core-2.0-5:amd64.
Preparing to unpack .../libevent-core-2.0-5_2.0.21-stable-2ubuntu0.16.04.1_amd64.deb ...
Unpacking libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-common (5.7.22-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 285993 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.22-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.22-0ubuntu0.16.04.1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../libhtml-template-perl_2.95-2_all.deb ...
Unpacking libhtml-template-perl (2.95-2) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.22-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.22-0ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu21.1) ...
Setting up libaio1:amd64 (0.3.110-2) ...
Setting up mysql-client-core-5.7 (5.7.22-0ubuntu0.16.04.1) ...
Setting up mysql-client-5.7 (5.7.22-0ubuntu0.16.04.1) ...
Setting up mysql-server-core-5.7 (5.7.22-0ubuntu0.16.04.1) ...
Setting up libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.22-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Setting up libhtml-template-perl (2.95-2) ...
Setting up mysql-server (5.7.22-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
使用如下命令登錄MySQL服務器。在提示輸入密碼的地方輸入剛才設置的root密碼
hduser@master:/etc/network$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> create database hive;
mysql> create user 'hive'@'%' identified by 'hive';
mysql> grant all privileges on *.* to 'hive'@'%' with grant option;
mysql>flush privileges;
mysql> use hive;
mysql> select user,host,password from mysql.user;
注:在ubuntu中,默認情況下MySQL只允許本底登陸,所以需要修改配置文件將地址綁定注釋掉
sudo vim /etc/mysql/my.cnf
#bind-address = 127.0.0.1 #注釋掉
下載最新穩(wěn)定版hive
https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-2.3.3/apache-hive-2.3.3-bin.tar.gz
上傳到master節(jié)點的/home/hduser/Downloads目錄下
解壓
tar -zxvf Downloads/apache-hive-2.3.3-bin.tar.gz
更改安裝文件名稱
hduser@master:~$ mv apache-hive-2.3.3-bin/ ./hive
hduser@master:~$
配置用戶環(huán)境變量
vim ~/.bashrc
在文件末尾添加如下內容
#HIVE
export HIVE_HOME=/home/hduser/hive
export PATH=$PATH:$HIVE_HOME/bin
最后重新導入環(huán)境變量
source ~/.bashrc
配置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://master:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<!--指定元數據庫連接驅動程序主類-->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<!--指定元數據庫用戶名-->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description>
</property>
<!--指定元數據庫用戶密碼-->
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</description>
</property>
</configuration>
我們也可指定某個文件夾來存放元數據
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/home/hduser/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
下載mysql-connector-java-5.1.46.tar.gz,下載鏈接為
https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
將其解壓后在文件夾中選擇mysql-connector-java-5.1.46-bin.jar上傳到master節(jié)點的/home/hduser/Downloads目錄下。最后將JDBC文件放到hive的lib文件夾內即可。
start-all.sh
格式化hive
schematool -dbType mysql -initSchema
啟動hive命令行
hive
HiveSQL的優(yōu)點是學習成本低,可以通過類似SQL語句實現(xiàn)快速MapReduce統(tǒng)計,使MapReduce變得更加簡單,而不必開發(fā)專門的MapReduce應用程序。hive是十分適合數據倉庫的統(tǒng)計分析和Windows注冊表文件。
數據分析咨詢請掃描二維碼
若不方便掃碼,搜微信號:CDAshujufenxi
LSTM 模型輸入長度選擇技巧:提升序列建模效能的關鍵? 在循環(huán)神經網絡(RNN)家族中,長短期記憶網絡(LSTM)憑借其解決長序列 ...
2025-07-11CDA 數據分析師報考條件詳解與準備指南? ? 在數據驅動決策的時代浪潮下,CDA 數據分析師認證愈發(fā)受到矚目,成為眾多有志投身數 ...
2025-07-11數據透視表中兩列相乘合計的實用指南? 在數據分析的日常工作中,數據透視表憑借其強大的數據匯總和分析功能,成為了 Excel 用戶 ...
2025-07-11尊敬的考生: 您好! 我們誠摯通知您,CDA Level I和 Level II考試大綱將于 2025年7月25日 實施重大更新。 此次更新旨在確保認 ...
2025-07-10BI 大數據分析師:連接數據與業(yè)務的價值轉化者? ? 在大數據與商業(yè)智能(Business Intelligence,簡稱 BI)深度融合的時代,BI ...
2025-07-10SQL 在預測分析中的應用:從數據查詢到趨勢預判? ? 在數據驅動決策的時代,預測分析作為挖掘數據潛在價值的核心手段,正被廣泛 ...
2025-07-10數據查詢結束后:分析師的收尾工作與價值深化? ? 在數據分析的全流程中,“query end”(查詢結束)并非工作的終點,而是將數 ...
2025-07-10CDA 數據分析師考試:從報考到取證的全攻略? 在數字經濟蓬勃發(fā)展的今天,數據分析師已成為各行業(yè)爭搶的核心人才,而 CDA(Certi ...
2025-07-09【CDA干貨】單樣本趨勢性檢驗:捕捉數據背后的時間軌跡? 在數據分析的版圖中,單樣本趨勢性檢驗如同一位耐心的偵探,專注于從單 ...
2025-07-09year_month數據類型:時間維度的精準切片? ? 在數據的世界里,時間是最不可或缺的維度之一,而year_month數據類型就像一把精準 ...
2025-07-09CDA 備考干貨:Python 在數據分析中的核心應用與實戰(zhàn)技巧? ? 在 CDA 數據分析師認證考試中,Python 作為數據處理與分析的核心 ...
2025-07-08SPSS 中的 Mann-Kendall 檢驗:數據趨勢與突變分析的有力工具? ? ? 在數據分析的廣袤領域中,準確捕捉數據的趨勢變化以及識別 ...
2025-07-08備戰(zhàn) CDA 數據分析師考試:需要多久?如何規(guī)劃? CDA(Certified Data Analyst)數據分析師認證作為國內權威的數據分析能力認證 ...
2025-07-08LSTM 輸出不確定的成因、影響與應對策略? 長短期記憶網絡(LSTM)作為循環(huán)神經網絡(RNN)的一種變體,憑借獨特的門控機制,在 ...
2025-07-07統(tǒng)計學方法在市場調研數據中的深度應用? 市場調研是企業(yè)洞察市場動態(tài)、了解消費者需求的重要途徑,而統(tǒng)計學方法則是市場調研數 ...
2025-07-07CDA數據分析師證書考試全攻略? 在數字化浪潮席卷全球的當下,數據已成為企業(yè)決策、行業(yè)發(fā)展的核心驅動力,數據分析師也因此成為 ...
2025-07-07剖析 CDA 數據分析師考試題型:解鎖高效備考與答題策略? CDA(Certified Data Analyst)數據分析師考試作為衡量數據專業(yè)能力的 ...
2025-07-04SQL Server 字符串截取轉日期:解鎖數據處理的關鍵技能? 在數據處理與分析工作中,數據格式的規(guī)范性是保證后續(xù)分析準確性的基礎 ...
2025-07-04CDA 數據分析師視角:從數據迷霧中探尋商業(yè)真相? 在數字化浪潮席卷全球的今天,數據已成為企業(yè)決策的核心驅動力,CDA(Certifie ...
2025-07-04CDA 數據分析師:開啟數據職業(yè)發(fā)展新征程? ? 在數據成為核心生產要素的今天,數據分析師的職業(yè)價值愈發(fā)凸顯。CDA(Certified D ...
2025-07-03