Hive1.2.1安装

  1. 下载Hive1.2.1   

wget http://mirrors.cnnic.cn/apache/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz
或者浏览器中打开

  2.  解压安装

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

  3.  配置Hive环境变量 

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

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

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.sh

配置元数据(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.  错误处理

[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. 测试

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)



你可能感兴趣的:(hadoop,hive安装,hive1.1.1)