CentOS下Hive2.0.0單機模式安裝詳解

來源:互聯網
上載者:User

標籤:

本文環境如下:
作業系統:CentOS 6 32位
Hive版本:2.0.0
JDK版本:1.8.0_77 32位
Hadoop版本:2.6.4

1. 所需要的環境

Hive 2.0需要以下運行環境:
Java 1.7以上(強烈建議使用Java 1.8)
Hadoop 2.X

2. 下載、解壓Hive安裝包

Hive官網地址: http://hive.apache.org/
例如:

wget "http://mirrors.cnnic.cn/apache/hive/hive-2.0.0/apache-hive-2.0.0-bin.tar.gz"tar -xzvf apache-hive-2.0.0-bin.tar.gzmv apache-hive-2.0.0-bin /opt/hive-2.0.0
3. 配置環境變數(可選)

將hive-2.0.0/bin添加到path,以方便訪問

vi /etc/profile

在末尾添加:

HIVE_HOME=/opt/hive-2.0.0PATH=$PATH:$HIVE_HOME/bin
4. 啟動單機模式

Hive和Hadoop一樣,有3種啟動模式,分別是單機模式,偽分布模式,分布模式。這裡先來說一下單機模式的啟動方式。

4.1 修改設定檔
cd /opt/hive-2.0.0/confvi hive-site.xml //也可以用hive-default.xml.template去改,不過這個檔案中的配置項太多了

輸入以下內容後儲存:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><configuration><property>    <name>hive.metastore.warehouse.dir</name>    <value>/opt/hive-2.0.0/warehouse</value>    <description>location of default database for the warehouse</description></property><property>   <name>javax.jdo.option.ConnectionURL</name>   <value>jdbc:derby:/opt/hive-2.0.0/metastore_db;create=true</value>   <description>JDBC connect string for a JDBC metastore</description></property></configuration>
4.2 初始化資料庫
schematool -initSchema -dbType derby

出現以下幾行說明初始化成功:

Starting metastore schema initialization to 2.0.0Initialization script hive-schema-2.0.0.derby.sqlInitialization script completedschemaTool completed
4.3 啟動程式
mkdir -p /opt/hive-2.0.0/warehouse       // 建立中繼資料存放區檔案夾chmod a+rwx /opt/hive-2.0.0/warehouse    // 修改檔案許可權hive

如果出現hive>提示符則說明啟動成功

5. 常見錯誤5.1 運行hive時出現
Exception in thread "main" java.lang.RuntimeException: 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)

錯誤原因:
資料庫沒有初始化,請參照4.2

5.2 使用schematool初始化資料庫時出現
Initialization script hive-schema-2.0.0.derby.sqlError: FUNCTION ‘NUCLEUS_ASCII‘ already exists. (state=X0Y68,code=30000)org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!*** schemaTool failed ***

錯誤原因:資料庫檔案夾中已經存在一些檔案,解決方案就是清空資料庫檔案夾(也就是前面配置的/opt/hive-2.0.0/metastore_db檔案夾)

CentOS下Hive2.0.0單機模式安裝詳解

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.