hive安装

今天在hadoop2.6.0的集群上安装了hive-1.1.0,感觉hive就是一个驱动层,只是连了连数据库,连了连hadoop

1.简述

整个安装步骤主要分为三步

  1. myslq准备
  2. 安装hive

本次安装的操作系统环境为centos6.8
hadoop版本为2.6.0
hive版本为1.1.0

2. 安装过程

1. mysql准备

hive使用mysql作为元数据管理的系统,所以必须先安装mysql
可以在mysql中先创建一个库给hive使用,我这里创建的库叫query_hive

2. 安装hive

注意,安装hive之前要先安装hadoop,我这里前面装过hadoop,就不再重复安装了

1. 下载hive-1.1.0

老版本的hive可以在这里找到

wget https://archive.apache.org/dist/hive/hive-1.1.0/apache-hive-1.1.0-bin.tar.gz

tar -xzvf apache-hive-1.1.0-bin.tar.gz  -C /usr/local

mv apache-hive-1.1.0-bin hive

2. 配置环境变量
vim /etc/profile

export HIVE_HOME=/usr/local/hive

export PATH=$PATH:$HIVE_HOME/bin

3. 创建hive-site.xml并配置
cd /usr/local/hive/conf
touch hive-site.xml

添加如下内容

<configuration>

 <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://10.76.4.113:3306/query_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>query_hive_wr</value>
    <description>Username to use against metastore database</description>
  </property>


  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>hVLjcAiLUrxJsylu</value>
    <description>password to use against metastore database</description>
  </property>

</configuration>

4. 初始化数据库
schematool -dbType mysql -initSchema

#返回

Metastore connection URL:        jdbc:mysql://10.76.4.113:3306/query_hive?createDatabaseIfNotExist=true
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       query_hive_wr
Starting metastore schema initialization to 1.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
init Failed

说明失败了,这个是因为缺少mysql的jar

cd /usr/local/hive/lib

wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.36/mysql-connector-java-5.1.36.jar

再执行

schematool -dbType mysql -initSchema

报错

[root@master bin]# ./hive

[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
    at jline.TerminalFactory.create(TerminalFactory.java:101)
    at jline.TerminalFactory.get(TerminalFactory.java:158)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
    at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
    at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

这个是因为hive中的/user/local/hive/lib/jline-2.12.jar和hadoop中的的/usr/local/hadoop/share/hadoop/yarn/lib/jline-0.9.94.jar版本冲突了,
使用高版本的替换低版本的即可

schematool -dbType mysql -initSchema

# 返回
Metastore connection URL:	 jdbc:mysql://10.76.4.113:3306/query_hive?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 query_hive_wr
Starting metastore schema initialization to 1.1.0
Initialization script hive-schema-1.1.0.mysql.sql
Initialization script completed
schemaTool completed

终于成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值