Hive是一個數據倉庫基礎工具在Hadoop中用來處理結構化數據。它架構在Hadoop之上,總歸爲大數據,並使得查詢和分析方便。並提供簡單的sql查詢功能,能夠將sql語句轉換爲MapReduce任務進行運行。
環境介紹:html
hadoop:3.2.0java
jdk:1.8mysql
Linux:centos7sql
mysql:5.6數據庫
1.mysql安裝配置apache
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysql-community-release-el7-5.noarch.rpm
執行yum install -y mysql -server Systemctl start mysql 完成
2.配置建立hive須要的數據庫以及帳戶vim
create database hive;
create user 'hadoop1'@'localhost' identified by '12345678'; grant all privileges on *.* to 'hadoop1'@'localhost' with grant option;
3.下載hivecentos
wget http://mirror.bit.edu.cn/apache/hive/hive-3.1.1/apache-hive-3.1.1-bin.tar.gz
tar xzvf apache-hive-3.1.1-bin.tar.gz
cd hive-3.1.1
4.配置hive以及hadoop的變量記得source 讓bianl生效。架構
vim /etc/profile export HIVE_HOME=/home/apache-hive-3.1.1-bin export HADDOP_HOME=/home//home/hadoop-3.2.0 export PATH=.:${JAVA_HOME}/bin/:$HIVE_HOME/bin:$HADOOP_HOME/bin:$PATH
5.編輯hive-site.xml 和hive-env.sh文件maven
此文件是經過hive-default.xml.template 複製出來的,須要刪除原文件全部內容後新增以下配置,由於hive在啓動的時候會加載兩個文件,default.xml和Hive-site.xml,因此若是直接新增一下內容是無效的。 [root@localhost conf]# cat hive-site.xml <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hadoop</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> [root@localhost conf]#
hive-env.sh
6.在初始化前查看是否有mysql的connectorjar包若是沒有請下載
[root@localhost apache-hive-3.1.1-bin]# ll lib/mysql-
mysql-connector-java-5.1.47.jar
下載地址:http://central.maven.org/maven2/mysql/mysql-connector-java/找對應的下載便可。
wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.47/mysql-connector-java-5.1.47.jar
7.初始化hive
[root@localhost apache-hive-3.1.1-bin]# bin/schematool -dbType mysql -initSchema SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/apache-hive-3.1.1-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop-3.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true Metastore Connection Driver : com.mysql.jdbc.Driver Metastore connection User: hadoop Starting metastore schema initialization to 3.1.0 Initialization script hive-schema-3.1.0.mysql.sql ······································此處省略 太多log了---------- Initialization script completed schemaTool completed
8.出現初始化完成以後能夠去mysql數據庫中查看hive下的表
會出現74張表。到此hive的配置和部署完成。