Hive 2.1 安裝
安裝Hive2.1
1. 準備工作:安裝JDK、Hadoop
2. 下載並解壓Hive,設定環境變數 HIVE_HOME、PATH
3. 設定Hadoop環境變數
./hadoop fs -mkdir /tmp
./hadoop fs -mkdir /usr/hive/warehouse
./hadoop fs -chmod g+w /tmp
./hadoop fs -chmod g+w /usr/hive/warehouse
4. 修改Hive的配置檔案
conf/hive-default.xml.template -> hive-site.xml conf/hive-log4j.properties.template -> hive-log4j.properties conf/hive-exec-log4j.properties.template -> hive-exec-log4j.properties
5. 修改 hive-site.xml
替換${system:java.io.tmpdir} 和 ${system:user.name}
:%[email protected]\${system:java.io.tmpdir}@/home/c3/[email protected]
:%[email protected]\${system:user.name}@/[email protected]
啟動Hive時報錯
Caused by: MetaException(message:Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, don't forget to include the option to auto-create the underlying database in your JDBC connection string (e.g. ?createDatabaseIfNotExist=true for mysql))
這是由於沒有初始化Hive元資料的資料庫,預設情況下,Hive的元資料儲存在了內嵌的derby資料庫裡
schematool -initSchema -dbType derby
元資料放入MySQL
1、將mysql-connector-java-5.1.30-bin.jar 放入 $HIVE_HOME/lib下
2、修改 $HIVE_HOME/conf/hive-site.xml裡的 資料庫連線串、驅動、使用者和密碼
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://10.1.195.50:3306/hivedb?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8</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>umobile</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>umobile</value> <description>password to use against metastore database</description> </property>
3、初始化Hive在mysql裡的指令碼 $HIVE_HOME/scripts
schematool -initSchema -dbType mysql
測試Hive
在Hive裡建立的表和資料,都儲存在了Hadoop裡的hdfs上面,hive-site.xml裡的 hive.user.install.directory 引數,定義了HDFS的路徑,預設/user
$ hadoop fs -ls /usr/hive Found 1 items drwxrwxr-x - c3 supergroup 0 2016-06-30 17:18 /usr/hive/warehouse
建立庫表並插入資料
create database test; use test; create table test_table (id int,name string,no int) row format delimited fields terminated by ',' stored as textfile select * from test_table; insert into test_table values (1, 'test', 1);
報如下錯誤:
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
我太激進了,不該用這麼新的Hive版本。。
將Hive的版本降到1.2再裝
schematool -initSchema -dbType mysql 報錯:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
解決方法:
將hive下的新版本jline的JAR包拷貝到hadoop下
hive/lib/jline-2.12.jar 拷貝到 hadoop/share/hadoop/yarn/lib/
hadoop下的jline-0.9.94.jar 重新命名為 jline-0.9.94.jar.bak
hive> CREATE TABLE student(id STRING, name String) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE; bash> echo 1,wang >> student.txt bash> echo 2,wang >> student.txt bash> echo 3,wang >> student.txt hive> load data local inpath '/home/c3/student.txt' into table student; 要用絕對路徑 hive> select * from student;
注意:不能使用insert into values 語句
以hiveserver方式啟動hive
bash> hive --service hiveserver
報錯:Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hadoop.hive.service.HiveServer
HiveServer本身存在很多問題(比如:安全性、併發性等),針對這些問題,Hive0.11.0版本提供了一個全新的服務:HiveServer2,這個很好的解決HiveServer存在的安全性、併發性等問題。這個服務啟動程式在${HIVE_HOME}/bin/hiveserver2裡面,你可以通過下面的方式來啟動HiveServer2服務。
bash> hive --service hiveserver2
bash> hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10001 #指定埠
啟動成功之後,就可以用DBVisualizer訪問Hive了,就像訪問MySQL
Tools > DriverManager... > 新建Hive
建立好Hive驅動,就可以建立Hive庫的連結了
Database Type: Generic
Driver:上面建立的驅動
userid/password:隨意輸入
資料準備,先在HDFS上準備文字檔案,逗號分割,並上傳到/1目錄,然後在Hive裡建立table,表名和檔名要相同,表的儲存路徑也是目錄/1
bash> vim table_test d1,user1,1000 d1,user2,2000 d1,user3,3000 d2,user4,4000 d2,user5,5000 bash> hadoop fs -mkdir /1 bash> hadoop fs -put table_test /1 hive> CREATE EXTERNAL TABLE table_test ( dept STRING, userid string, sal INT ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' stored as textfile location '/1'; hive> select * from table_test;
另外,SparkSQL也可以作為 JDBC Server,這種方式與上面的Hive作為server的區別在於,SparkSQL使用Spark引擎來執行SQL,而Hive使用MR來執行SQL。
1、hive-site.xml拷貝將hive-site.xml拷貝到¥SPARK_HOME/conf下
2、需要在$SPARK_HOME/conf/spark-env.sh中的SPARK_CLASSPATH新增jdbc驅動的jar包
export SPARK_CLASSPATH=.:/home/Hadoop/software/mysql-connector-java-5.1.27-bin.jar
3、啟動:./start-thriftserver.sh --hiveconf hive.server2.thrift.port=10001 --hiveconf hive.server2.thrift.bind.host=rti9
4、檢視日誌:tail -f /home/c3/apps/spark-1.6.1-bin-hadoop2.6/logs/spark-c3-org.apache.spark.sql.hive.thriftserver.HiveThriftServer2-1-rti9.out
相關推薦
Hive 2.1 安裝
安裝Hive2.1 1. 準備工作:安裝JDK、Hadoop 2. 下載並解壓Hive,設定環境變數 HIVE_HOME、PATH 3. 設定Hadoop環境變數 ./hadoop fs -mkdir /tmp ./hadoop fs -mkdir /usr/hive/w
Hive 2.1.0叢集安裝
Hive 2.1.0叢集安裝 1.配置伺服器 1個主節點:master(192.168.20.191),2個(從)子節點, node1(192.168.20.192), node2(192.168.20.193) 2.將jdbc的jar包放到$HIVE_HOME下 cd
CentOS6安裝hive-2.1.1
hive 這裡簡單說明一下,好對大家配置hive有點幫助。hive是建立在hadoop上的,當然,你如果只搭建hive也沒用什麼錯。說簡單一點,hadoop中的mapreduce呼叫如果面向DBA的時候,那麼問題也就顯現了,因為不是每個DBA都能明白mapreduce的工作原理,如果為了
hive-2.1.1安裝部署
hive介紹、理解相關,參考: http://www.aboutyun.com/thread-20461-1-1.html http://blog.csdn.net/lifuxiangcaohui/article/details/40145859 https://mp.we
win7配置安裝Hive-2.1.1
1 配置安裝hadoop ,版本: hadoop-2.7.6 3 解壓hive到目錄:D:\Soft\apache-hive-2.1.1-bin 4 下載mysql驅動放到:D:\Soft\apache-hive-2.1.1-bin\lib\mysql-connect
Ubuntu系統下安裝並配置hive-2.1.0
說在前面的話 預設情況下,Hive元資料儲存在內嵌的Derby資料庫中,只能允許一個會話連線,只適合簡單的測試。實際生產環境中不使用,為了支援多使用者會話, 則需要一個獨立的元資料庫,使用MySQL作為元資料庫,Hive內部對MySQL提供了很好的支援。 在Ubuntu系統下安裝並配置h
Hive 1.2.1安裝部署
java.sql.SQLException: Unable to open a test connection to the given database. J
hive 2.1.0安裝
前言: 本文主要是從如下blog中學習得來: http://blog.csdn.net/cuihaolong/article/details/52038543 http://fengshulin.iteye.com/blog/2320359 1.準備: java 1.7
Hive 1.2.1 安裝測試
1 安裝MySQL 安裝伺服器: sudo apt-get install mysql-server (注意:期間需要設定root使用者的密碼喲) 安裝客戶端: sudo apt-get install mysql-client sud
Hadoop-2.7.3環境下Hive-2.1.1安裝配置。
環境:ubuntu-16.0.4;jdk1.8.0_111;apache-hadoop-2.7.3;apache-hive-2.1.1。這裡只記錄Hive的安裝。Hive只需要安裝到一個節點上即可。我這裡是裝在Namenode上的。首先從官網上下載所需要的版本,本人下載的ap
【Hadoop】Hadoop2.7.3安裝Hive 2.1.0
第一步: 下載最新的hive,直接去apache 裡面找hive2.1.0下載就行。 第二步,解壓到伺服器 tar zxvf apache-hive-2.0.0-bin.tar.gz mv apache-hive-2.0.0-bin /hom
(轉) Hadoop1.2.1安裝
安裝目錄 文件復制 reduce mat 數據保存 jdk1.7 mapreduce tput cat 環境:ubuntu13 使用的用戶為普通用戶。如:用戶ru jdk安裝略 1、安裝ssh (1) Java代碼 sudo apt-get install op
nagios客戶端之nrpe3.2.1安裝
init nagios插件 源碼 load 啟動 files plugin ubunt tar.gz 1、刪除dpkg安裝的nrpedpkg -l | grep nrpedkpg -P nagios-nrpe-server 2、ubuntu下nrpe3.2.1安裝 下載nr
zabbix3.2.1安裝graphtrees插件
上下 官網 apach zabbix3.2 nload 直接 aik alt 下載 https://blog.csdn.net/liang_baikai/article/details/53542317 graphtree介紹 由於zabbix的圖像顯示一塊不太友好,圖像沒
在CDH上用外部Spark2.2.1安裝和配置 CarbonData
表示 相關 iyu top arch slaves path 中央倉庫 tar -zcvf 在CDH上用外部Spark2.2.1 (hadoop free版本)standalone 模式安裝和配置 CarbonData ===================
Android Studio 3.2.1安裝問題解決辦法
由於公司設定代理伺服器,導致安卓工程一直停留在gradle中迴圈,解決辦法如下: 修改兩個檔案,在目錄C:\Users\Administrator.20181015CSB\.gradle下: gradle.properties init.gradle 其中: 【gradle.
java jdbc 連線hive-2.1.1
package com.linewell.hivetest; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
elasticsearch 5.2.1安裝問題解答
1、啟動 elasticsearch 如出現異常 can not run elasticsearch as root 解決方法:建立ES 賬戶,修改資料夾 檔案 所屬使用者 組 2、啟動異常:ERROR: bootstrap checks failed syst
New in Cloudera Enterprise 6: Apache Hive 2.1
We recently released Cloudera Enterprise 6.0 featuring significant improvements across a number of core components. In this blog post, we’re going to
不安裝msyql的情況下為php7.2.1安裝mysqli擴充套件
環境為新的阿里雲ECS雲主機,沒有事先編譯安裝mysql,也沒有事先yum安裝mysql。 在編譯安裝php7.2.1完成後,發現mysqli擴充套件沒有安裝。 解決辦法為進入到php7.2.1原始碼包( 實際路徑可能不同): cd /mnt/soft/php-7.2.1/ext