CentOS7 Hive2.3.8 安裝
建議從頭用我的博客,如果用外教的文件到 一、9)步驟了,就用他的弄完,數據庫不一樣,在9步驟前還能繼續看我的
一、 安裝MySQL
0.0)查詢mariadb,有就去0.1),沒有就不管直接去1)
rpm -qa | grep mariadb
0.1)卸載mariadb
rpm -e --nodeps [查詢出來的內容]
1) 下載mysql:
sudo yum localinstall https://repo.mysql.com//mysql80-community-release-el7-5.noarch.rpm
2) 安裝Mysql:
sudo yum install mysql-community-server
3) 開啟Mysql服務:
systemctl start mysqld.service
A. 可能遇到的問題1:
輸這個解決:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
B. 可能遇到的問題2:
輸這個解決:
sudo yum install mysql-server --nogpgcheck
4) 檢查Mysql服務運行狀態
service mysqld status
5) 查詢Mysql臨時密碼以進入Mysql里面
grep "A temporary password" /var/log/mysqld.log
圖片臨時碼為f0155f&dA4Ne
6) 輸入以下命令,后面輸密碼的時候輸入你屏幕里出來的臨時密碼
輸密碼用手敲不要復制粘貼
mysql –u root -p
然后會彈出下面這個內容在:后面手敲密碼就好,輸密碼的時候看不見
‘
Enter password:f0155f&dA4Ne
7)更改Mysql密碼,最好和我一樣,涉及到后面Hive配置
ALTER user 'root'@'localhost' IDENTIFIED BY 'Root123!';
現在進入Mysql密碼是 Root123!
8)將表的所有操作權限賦予root用戶,并讓root用戶授權其他用戶。
GRANT all ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
9) Mysql數據庫配置
a. 創建一個hivedb數據庫:
create database hivedb;
b. 使用數據庫mysql:
use mysql;
c. 輸入命令看配置
select host, user, authentication_string, plugin from user;
我們需要一個 hiveuser 對應 % 的用戶,所以加一個
CREATE USER 'hiveuser'@'%' IDENTIFIED BY 'Root123!';
加好了,查看一下,就有% hiveuser 的用戶了
select host, user, authentication_string, plugin from user;
要是太長了串行了可以省略點查看
select host, user from user;
f. 給hiveuser授權一下
GRANT ALL ON *.* TO 'hiveuser'@'%';
g. 手動更新配置:
flush privileges;
二、安裝 Hive:
1)把apache-hive-2.3.8-bin.tar.gz 下載后 用mobaxterm放到 /tools文件夾
鏈接:https://pan.baidu.com/s/1NBplQ4GYGfsa25aSK7I8OQ?pwd=vzji
提取碼:vzji
–來自百度網盤超級會員V6的分享
2)解壓文件
tar -zvxf /tools/apache-hive-2.3.8-bin.tar.gz -C /training/
3)進入 /training 文件夾
cd /training
重命名移動文件夾為hive
mv apache-hive-2.3.8-bin hive
4) 設置環境變量
vi ~/.bash_profile
加進去
export HIVE_HOME=/training/hive
export PATH=$PATH:$HIVE_HOME/bin
:wq 保存退出后,更新環境變量文件
source ~/.bash_profile
======================================================================
5) Hive配置文件更改
進入配置文件夾
cd training/hive/conf
復制備份hive-env.sh.template并命名為hive-env.sh
cp hive-env.sh.template hive-env.sh
復制備份hive-default.xml.template并命名為hive-site.xml
cp hive-default.xml.template hive-site.xml
6) 配置 hive-site.xml,這個文件內容特別多,所以一次性刪光了再往里面加東西
進入文件
vi hive-site.xml
直接鍵盤敲6000dd,此命令意思是刪除6000行,不要復制
6000 dd
如果還沒刪空,就多來幾次6000dd
刪空后加入以下內容,注意復制進去的時候不要少了>符號之類的小錯誤,此文件涉及到之前設置的密碼Root123!,如果你不一樣,記得改
#Enter the insert mode by pressingi and then copy this code to the file and save and exit using- :wq.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<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>hive.default.fileformat</name>
<value>TextFile</value>
</property>
<property>
<!--The port is changed to your own port. Here is the onhive database in the connection database. If not, create it later -->
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<!--The latest version of the jar package to connect to MySQL All write com.mysql.cj.jdbc.Driver, if it is the old version with com.mysql.jdbc.Driver-->
<value>com.mysql.cj.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<!--Connect to MySQL username-->
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<!--Connect MySQL password -->
<name>javax.jdo.option.ConnectionPassword</name>
<value>Root123!</value>
<description>password to use against metastore database</description>
</property>
</configuration>
7)配置 hive-env.sh
進入文件
vi hive-env.sh
在文件最底下加,注意hadoop版本和java版本以及路徑是否和我一樣,不一樣記得換
export HADOOP_HOME=/training/hadoop-3.3.0
export HIVE_CONF_DIR=/training/hive/conf
export HIVE_AUX_JARS_PATH=/training/hive/lib
export JAVA_HOME=/training/jdk1.8.0_144
export HIVE_HOME=/training/hive
8)把 MySQL的 connected jar文件放到 hive/lib 文件夾下
鏈接:https://pan.baidu.com/s/1gD2M8Gr9IFOkOA4EghfWLg?pwd=32r8
提取碼:32r8
–來自百度網盤超級會員V6的分享
9)進入 /training/hadoop-3.3.0/share/hadoop/hdfs/lib/
找到這個瓜娃27,把它下載到桌面上留著
10)進入 /training/hive/lib
把瓜娃27放進去,并且刪除這個瓜娃14
11)啟動Hadoop
start-all.sh
12) 復制一個窗口進入這個路徑
cd /training/hive/scripts/metastore/upgrade/mysql/
輸入命令后輸密碼Root123!進入mysql
mysql -u root –p
輸命令創建數據庫metastore
create database metastore;
使用之前創建好的hivedb
use hivedb;
執行下面的代碼
source hive-schema-2.3.0.mysql.sql
12) 回到前面那個窗口初始化mysql
schematool -dbType mysql -initSchema
成功的話會有這個提示
Starting metastore schema initialization to 2.3.8 Initialization
script hive-schema-2.3.8.mysql.sql Initialization script completed
schemaTool completed
13)進入hive測試;
進hive命令行
hive
創建庫
Create database hive1;
顯示庫,可以看到hive1
Show databases;
退出
exit;
14)用hdfs看看剛剛的hive1
hdfs dfs -ls /user/hive/warehouse
關掉hadoop
stop-all.sh