Hive1.2.1安裝

  1. 下載Hive1.2.1   java

wget http://mirrors.cnnic.cn/apache/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz
或者瀏覽器中打開

  2.  解壓安裝
mysql

cd ~/Developer 
cp /path/apache-hive-1.2.1-bin.tar.gz .
解壓
tar -zxvf apache-hive-1.2.1-bin.tar.gz

  3.  配置Hive環境變量 sql

export PATH=$PATH:/Users/Sabo/Developer/apache-hive-1.2.1-bin/bin

  4.  修改配置文件 hive-env.shshell

cd conf
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
export HADOOP_HEAPSIZE=1024

HADOOP_HOME=/Users/Sabo/Developer/hadoop-2.6.0
export HIVE_CONF_DIR=/Users/Sabo/Developer/apache-hive-1.2.1-bin/conf
export HIVE_AUX_JARS_PATH=/Users/Sabo/Developer/apache-hive-1.2.1-bin/lib

  5.  修改配置文件 hive-site.shapache

配置元數據(MySQL)
<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>

注意修改日誌等目錄指向,以下:
<property>
  <name>hive.querylog.location</name>
  <value>/data/hive/iotmp</value>
  <description>Location of Hive run time structured log file</description>
</property>
  
<property>
  <name>hive.exec.local.scratchdir</name>
  <value>/data/hive/iotmp</value>
  <description>Local scratch space for Hive jobs</description>
</property>
  
<property>
  <name>hive.downloaded.resources.dir</name>
  <value>/data/hive/iotmp</value>
  <description>Temporary local directory for added resources in the remote file system.</description>
</property>

該項必須修改,否則hive啓動時候將報錯

  6.  錯誤處理vim

[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected

遇到以下錯誤時候
a. 覆蓋Hadoop下低版本的jline 
$ cp jline-2.12.jar /Users/Sabo/Developer/hadoop-2.6.0/share/hadoop/yarn/lib/ 
b. 或查看:
http://stackoverflow.com/questions/28997441/hive-startup-error-terminal-initialization-failed-falling-back-to-unsupporte

  7.  修改字符集  瀏覽器

$ alter database hive character set latin1;
注意,貌似如今hive不支持其它字符編碼,否則建表等操做時將包以下錯誤:

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:javax.jdo.JDODataStoreException: An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 767 bytes

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes

  8. 測試oop

a. 首先啓動了個人hadoop,單機環境下。安裝文檔可查看:http://www.powerxing.com/install-hadoop/
$ cd /path/hadoop/sbin/
$ start-dfs.sh

b. 啓動hive
$ /Users/Sabo/Developer/apache-hive-1.2.1-bin/bin/hive 
$ create database dw_db;
$ use dw_db;
$ create table dual(dummy string);
$ hadoop fs -put dual.txt /user/hive/warehouse/dw_db.db/dual/
$ select * from dual;
OK
x
Time taken: 0.086 seconds, Fetched: 1 row(s)
相關文章
相關標籤/搜索