CentOS下Hive2.0.0单机模式安装详解

本文环境如下: 
操作系统: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.gz
mv apache-hive-2.0.0-bin /opt/hive-2.0.0
  • 1
  • 2
  • 3

3. 配置环境变量(可选)

将hive-2.0.0/bin添加到path,以方便访问

vi /etc/profile
  • 1

在末尾添加:

HIVE_HOME=/opt/hive-2.0.0
PATH=$PATH:$HIVE_HOME/bin
  • 1
  • 2

4. 启动单机模式

Hive和Hadoop一样,有3种启动模式,分别是单机模式,伪分布模式,分布模式。这里先来说一下单机模式的启动方式。 
集群模式安装在http://blog.csdn.net/lnho2015/article/details/51355511

4.1 修改配置文件

cd /opt/hive-2.0.0/conf
vi hive-site.xml //也可以用hive-default.xml.template去改,不过这个文件中的配置项太多了
  • 1
  • 2

输入以下内容后保存:

<?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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

4.2 初始化数据库

schematool -initSchema -dbType derby
  • 1

出现以下几行说明初始化成功:

Starting metastore schema initialization to 2.0.0
Initialization script hive-schema-2.0.0.derby.sql
Initialization script completed
schemaTool completed
  • 1
  • 2
  • 3
  • 4

4.3 启动程序

mkdir -p /opt/hive-2.0.0/warehouse       // 创建元数据存储文件夹
chmod a+rwx /opt/hive-2.0.0/warehouse    // 修改文件权限
hive
  • 1
  • 2
  • 3

如果出现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)
  • 1

错误原因: 
数据库没有初始化,请参照4.2

5.2 使用schematool初始化数据库时出现

Initialization script hive-schema-2.0.0.derby.sql
Error: 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 ***
  • 1
  • 2
  • 3
  • 4

错误原因:数据库文件夹中已经存在一些文件,解决方法就是清空数据库文件夹(也就是前面配置的/opt/hive-2.0.0/metastore_db文件夹)



http://blog.csdn.net/lnho2015/article/details/51307438


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值