安装Hive

对应HADOOP版本是2.5.2

安装MySQL

yum install mysql-server

启动MySQL

service mysqld start

进入MySQL

mysql

修改用户权限

> use mysql;
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
> SELECT host, user FROM user;
> DELETE FROM user where host !='%';
> flush privileges; # 刷新权限

下载hive

apache-hive-1.2.1-bin.tar.gz

修改环境变量/etc/profile

export HIVE_HOME=/home/hive-1.2.1
export PATH=$PATH:$HIVE_HOME/bin

hive配置文件

进入$HIVE_HOME/conf修改配置文件

cp hive-default.xml.template hive-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/user/hive_remote/warehouse</value> 
</property>
<property> 
    <name>hive.metastore.local</name> 
    <value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name> 
<value>jdbc:mysql://node1/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property> 
    <name>javax.jdo.option.ConnectionDriverName</name> 
    <value>com.mysql.jdbc.Driver</value>
</property>
<property> 
    <name>javax.jdo.option.ConnectionUserName</name> 
    <value>root</value>
</property>
<property> 
    <name>javax.jdo.option.ConnectionPassword</name> 
    <value>123</value>
</property>
</configuration>

添加MySQL的jar包

需要将 mysql 的 jar 包拷贝到$HIVE_HOME/lib 目录下

mysql-connector-java-5.1.32.jar下载拷贝至$HIVE_HOME/lib目录

替换HADOOP的Jline.jar

拷贝$HIVE_HOME/lib下的jline.jar替换/usr/local/hadoop/share/hadoop/yarn/lib目录下的jline.jar

直接输入hive即可启动

$ hive

Hive服务端与客户端

服务端配置

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property> 
    <name>hive.metastore.warehouse.dir</name> 
    <value>/user/hive/warehouse</value>
</property>

<property>
    <name>javax.jdo.option.ConnectionURL</name> 
    <value>jdbc:mysql://node1/hive?createDatabaseIfNotExist=true</value>
</property>

<property> 
    <name>javax.jdo.option.ConnectionDriverName</name> 
    <value>com.mysql.jdbc.Driver</value>
</property>

<property> 
    <name>javax.jdo.option.ConnectionUserName</name> 
    <value>root</value>
</property>

<property> 
    <name>javax.jdo.option.ConnectionPassword</name> 
    <value>123</value>
</property> 

</configuration>

拷贝MySQL的jar包至$HIVE_HOME/lib目录

启动HIVE服务端

$ hive --service metastore

客户端配置

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>

<property> 
    <name>hive.metastore.warehouse.dir</name> 
    <value>/user/hive/warehouse</value>
</property>

<property> 
    <name>hive.metastore.local</name> 
    <value>false</value>
</property>

<property> 
    <name>hive.metastore.uris</name> 
    <value>thrift://node2:9083</value>
</property>
    
</configuration>

用Hive的Jline.jar包替换HADOOP的Jline.jar包

/usr/local/hadoop/share/hadoop/yarn/lib

$ hive
    原文作者:MR_ChanHwang
    原文地址: https://www.jianshu.com/p/253a26237924
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞