Hive-0.14.0版本,本地獨立模式,MySQL作為後設資料庫
系統 |
Red hat linux 6.4 |
Hadoop版本 |
2.5.2 |
Hive版本 |
0.14.0 |
Mysql資料庫版本 |
5.6.15 |
1.安裝JDK,這個步驟在部署hadoop分散式叢集時候已經操作過了,可以略過。
2.安裝Mysql 資料庫
資料庫的安裝順序
(1)Mysql-server
(2)mysql-client
(3)啟動mysql服務
(4)用root使用者登入,以授權方式建立hive後設資料庫,和hive使用者
grant all on hive.* to 'hive'@'%' identified by 'hive'; 這個hive資料庫,及其 使用者和密碼,是後面配置hive要用到的 !!!
備註:Red Hat linux 下的mysql 安裝 可參考 http://blog.itpub.net/28929558/viewspace-1192693/
3.部署Hive
(1)到官網下載hive http://mirror.bit.edu.cn/apache/hive/
(2)解壓到自己需要的安裝路徑
(3)配置hive環境變數
點選(此處)摺疊或開啟
- #set hive_env
- export HIVE_HOME=/home/zhang/hive
- export PATH=$PATH:/home/zhang/hive/bin
- export CLASS_PATH=$CLASS_PATH:/home/zhang/hive/lib
(4)修改$HIVE_HOME/conf 下面配置檔案(將需要配置的兩個模板,拷貝重新命名)
點選(此處)摺疊或開啟
- cp hive-env.sh.template hive-env.sh
- cp hive-default.xml.template hive-site.xml
點選(此處)摺疊或開啟
- # Set HADOOP_HOME to point to a specific hadoop install directory
- HADOOP_HOME=/home/zhang/hadoop-2.5.2
修改的內容如下所示:
點選(此處)摺疊或開啟
-
<property>
-
<name>javax.jdo.option.ConnectionURL</name>
-
<value>jdbc:mysql://localhost: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>
-
-
<property>
-
<name>hive.metastore.local</name>
-
<value>true</value>
-
<description></description>
- </property>
在hive下建立臨時IO的tmp資料夾。然後將路徑配置到下列引數中
點選(此處)摺疊或開啟
-
<property>
-
<name>hive.querylog.location</name>
-
<value>/home/zhang/hive/iotmp</value>
-
<description>Location of Hive run time structured log file</description>
-
</property>
-
-
<property>
-
<name>hive.exec.local.scratchdir</name>
-
<value>/home/zhang/hive/iotmp</value>
-
<description>Local scratch space for Hive jobs</description>
-
</property>
-
-
<property>
-
<name>hive.downloaded.resources.dir</name>
-
<value>/home/zhang/hive/iotmp</value>
-
<description>Temporary local directory for added resources in the remote file system.</description>
- </property>
點選(此處)摺疊或開啟
- [zhang@namenode ~]$ hive
- 14/12/17 03:04:45 WARN conf.HiveConf: DEPRECATED: Configuration property hive.metastore.local no longer has any effect. Make sure to provide a valid value for hive.metastore.uris if you are connecting to a remote metastore.
- 14/12/17 03:04:45 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
- Logging initialized using configuration in jar:file:/home/zhang/hive/lib/hive-common-0.14.0.jar!/hive-log4j.properties
- SLF4J: Class path contains multiple SLF4J bindings.
- SLF4J: Found binding in [jar:file:/home/zhang/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
- SLF4J: Found binding in [jar:file:/home/zhang/hive/lib/hive-jdbc-0.14.0-standalone.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.slf4j.impl.Log4jLoggerFactory]
- Exception in thread \"main\" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)
- at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:672)
- at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:616)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:483)
- at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
- Caused by: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
- at org.apache.hadoop.fs.Path.initialize(Path.java:206)
-
at org.apache.hadoop.fs.Path.
(Path.java:172) - at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:487)
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:430)
- ... 7 more
- Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
- at java.net.URI.checkPath(URI.java:1823)
-
at java.net.URI.
(URI.java:745) - at org.apache.hadoop.fs.Path.initialize(Path.java:203)
- ... 10 more
(7)下載 mysql-connector-java-5.1.34-bin.jar 檔案,並放到$HIVE_HOME/lib目錄下 (到官網自行下載即可)
如果沒有此jar包,啟動hive會報如下錯誤:
點選(此處)摺疊或開啟
- Caused by: org.datanucleus.store.rdbms.connectionpool.DatastoreDriverNotFoundException: The specified datastore driver (\"com.mysql.jdbc.Driver\") was not found in the CLASSPATH. Please check your CLASSPATH specification, and the name of the driver.
- at org.datanucleus.store.rdbms.connectionpool.AbstractConnectionPoolFactory.loadDriver(AbstractConnectionPoolFactory.java:58)
- at org.datanucleus.store.rdbms.connectionpool.BoneCPConnectionPoolFactory.createConnectionPool(BoneCPConnectionPoolFactory.java:54)
- at org.datanucleus.store.rdbms.ConnectionFactoryImpl.generateDataSources(ConnectionFactoryImpl.java:238)
- ... 66 more
至此,部署完畢,可以啟動,測試下:
看到如下結果,說明啟動成功
點選(此處)摺疊或開啟
- [zhang@namenode ~]$ hive
- 14/12/17 18:48:22 WARN conf.HiveConf: DEPRECATED: Configuration property hive.metastore.local no longer has any effect. Make sure to provide a valid value for hive.metastore.uris if you are connecting to a remote metastore.
- 14/12/17 18:48:22 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
- Logging initialized using configuration in jar:file:/home/zhang/hive/lib/hive-common-0.14.0.jar!/hive-log4j.properties
- SLF4J: Class path contains multiple SLF4J bindings.
- SLF4J: Found binding in [jar:file:/home/zhang/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
- SLF4J: Found binding in [jar:file:/home/zhang/hive/lib/hive-jdbc-0.14.0-standalone.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.slf4j.impl.Log4jLoggerFactory]
- hive> show tables;
- OK
- Time taken: 0.924 seconds
- hive> show databases;
- OK
- default
- Time taken: 0.051 seconds, Fetched: 1 row(s)
建立表測試:如果這部分沒有報錯,那麼去檢查HDFS下面是否生成了相關檔案
點選(此處)摺疊或開啟
- hive> create table test(t_id int,t_name string) row format delimited fields terminated by \'|\' stored as textfile;
- OK
- Time taken: 1.586 seconds
- hive> show tables;
- OK
- test
- Time taken: 0.078 seconds, Fetched: 1 row(s)
- hive> select * from test;
- OK
- Time taken: 0.599 seconds
點選(此處)摺疊或開啟
- [zhang@datanode01 ~]$ hdfs dfs -ls /
- 14/12/17 18:55:05 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 3 items
- drwxr-xr-x - zhang supergroup 0 2014-12-16 02:21 /input
- drwx-wx-wx - zhang supergroup 0 2014-12-17 01:25 /tmp
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user
- [zhang@datanode01 ~]$ hdfs dfs -ls /user/
- 14/12/17 18:55:20 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 1 items
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user/hive
- [zhang@datanode01 ~]$ hdfs dfs -ls /user/hive/
- 14/12/17 18:55:27 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 1 items
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user/hive/warehouse
- [zhang@datanode01 ~]$ hdfs dfs -ls /user/hive/warehouse/
- 14/12/17 18:55:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Found 1 items
- drwxr-xr-x - zhang supergroup 0 2014-12-17 18:54 /user/hive/warehouse/test
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29439655/viewspace-1378888/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Hive安裝(本地獨立模式,MySql為後設資料庫)Hive模式MySql資料庫
- 關於資料庫的資料獨立性及三層模式資料庫模式
- 全球電商獨立站商品資料庫資料庫
- 又一巨頭為資料庫業務註冊獨立公司資料庫
- 大資料元件-Hive部署基於MySQL作為後設資料儲存大資料元件HiveMySql
- ORACLE/MySQL資料庫模式設計~~OracleMySql資料庫模式
- Windows 9可能將是最後獨立Windows版本Windows
- [提問交流]獨立模型設定好後,資料怎麼不顯示模型
- 資料安全綜治平臺新版本釋出,資料安全從獨立作戰走向聯防聯動
- 為Zabbix MySQL設定獨立表空間innodb_file_per_tableMySql
- MySQL資料庫本地事務原理MySql資料庫
- MySQL設定資料庫為只讀MySql資料庫
- 最新資訊:macOS的Safari 將14作為獨立更新Mac
- 乾貨 | 作為前端開發者如何邁向獨立開發者前端
- hive的安裝(後設資料庫: MySQL)Hive資料庫MySql
- 搭建獨立大資料實驗室的設想大資料
- 重磅!flink-table-store 將作為獨立資料湖專案重新加入 ApacheApache
- 如何設定資料庫為歸檔模式資料庫模式
- 後續版本要是目錄能邦定獨立模型就好了!模型
- Django中更改預設資料庫為mysqlDjango資料庫MySql
- 機器學習 # 為什麼機器學習要求資料是獨立同分布的?機器學習
- 將高版本mysql資料庫的資料匯入低版本mysql中MySql資料庫
- 從本地MySQL遷移到雲資料庫,為什麼是Amazon Aurora?MySql資料庫
- 作為獨立開發者 別人不會告訴你的事
- MySQL預設資料庫之mysql庫MySql資料庫
- Apple推出適用於macOS的Safari 14作為獨立更新APPMac
- MySQL入門--後設資料MySql
- JAVA 2目前的3個獨立的版本Java
- 【VMware VCF】獨立更新 SDDC Manager 元件的版本。元件
- 成為MySQL DBA後,再看ORACLE資料庫(十三、物理備份)MySqlOracle資料庫
- 更改資料庫為歸檔模式資料庫模式
- SQL Server資料庫設為單一使用者模式SQLServer資料庫模式
- 獨立開啟Oracle的Standby庫Oracle
- 資料共享(淺複製)與資料獨立(深複製)
- MySQL InnoDB獨立表空間模式的優點和缺點介紹MySql模式
- honor榮耀獨立後發展方向解析
- Hadoop之Hive本地與遠端mysql資料庫管理模式安裝手冊HadoopHiveMySql資料庫模式
- Wordpress獨立站資料庫連線錯誤的三種解決方式資料庫