CentOS7.2安装Hive

一、环境

    Centso7.2    64位     apache-hive-2.3.3-bin.tar.gz

二、安装

    1、下载 apache-hive-2.3.3-bin.tar.gz

    链接:http://hive.apache.org/downloads.html

    2、通过Xshell工具将压缩包上传至/usr/local/src并解压缩

cd /usr/local/src
tar -xzvf apache-hive-2.3.3-bin.tar.gz

    3、将解压缩的apache-hive-2.3.3-bin移动至/usr/local

mv /usr/local/src/apache-hive-2.3.3-bin /usr/local/hive

    4、配置环境变量

cd /usr/local/hive/conf
cp hive-default.xml.template hive-site.xml
修改hive.metastore.schema.verification,设定为false
创建/usr/local/hive/tmp目录,替换${system:java.io.tmpdir}为该目录
替换${system:user.name}为root

    5、建立数据库

    5.1、hive内置数据库derby配置

schematool -initSchema -dbType derby 
在当前目录下建立metastore_db的数据库;
请注意!!!下次执行hive时应该还在同一目录,默认到当前目录下寻找metastore ;
遇到问题,把metastore_db删掉,重新执行命令
实际工作环境中,经常使用mysql作为metastore的数据。

5.2、hive配置mysql数据库:

  A、单用户模式:

cd /usr/local/hive/conf

vi hive-site.xml

<configuration>
  <property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/user/hive/warehouse</value>
    <description>location of default database for the warehouse</description>
  </property>
    <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://192.168.199.101:3306/hive?createDatabaseIfNotExist=true&amp;characterEncoding=UTF-8</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>root</value>
    <description>Username to use against metastore database</description>
  </property>
    <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>root</value>
    <description>password to use against metastore database</description>
  </property>
</configuration>

   添加两个Jar包:mysql-connector-java.jar和jline*.jar包至hadoop Jar包文件夹;

   B、多用户模式:

## 服务端hive -- slave1
<configuration>
  <property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/user/hive/warehouse</value>
    <description>location of default database for the warehouse</description>
  </property>
    <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://192.168.199.101:3306/multiUsersHive?createDatabaseIfNotExist=true&amp;characterEncoding=UTF-8</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>root</value>
    <description>Username to use against metastore database</description>
  </property>
    <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>root</value>
    <description>password to use against metastore database</description>
  </property>
</configuration>

## 客户端hive -- slave2
<configuration>
  <property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/user/hive/warehouse</value>
    <description>location of default database for the warehouse</description>
  </property>
    <property>
    <name>hive.metastore.local</name>
    <value>false</value>
  </property>
    <property>
    <name>hive.metastore.uris</name>
    <value>thrift://192.168.199.102:9083</value>
    <description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>
  </property>
</configuration>

先启动服务端:hive --service metastore & ; (注意拷贝mysql Jar包);再启动客户端:hive ;

6、启动Hive:

hive

    7、简单操作:

show databases;
use default;
create table emp(name string,agent string,age int,salary double);
show tables;
desc emp;
select * from emp;
drop table emp;

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值