Hive 组件部署2

2.1解压Hive安装包到“/usr/project”路径

[root@master ~]# tar -zxvf apache-hive-1.1.0-bin.tar.gz -C /usr/project/

1、 使用相关命令,修改解压后文件夹名为Hive,进入Hive文件夹

[root@master ~]# cd /usr/project/

[root@master project]# mv apache-hive-1.1.0-bin/ hive

[root@master project]# ls

hadoop  hive  jdk1.8.0_144

[root@master project]# cd hive/

[root@master hive]# ls

bin  conf  examples  hcatalog  lib  LICENSE  NOTICE  README.txt  RELEASE_NOTES.txt  scripts

2.2设置Hive环境变量并使环境变量只对当前用户生效;

vi ~/.bashrc

export HIVE_HOME=/usr/project/hive
export PATH=$PATH:$HIVE_HOME/bin

source ~/.bashrc

2、 新建并或hive-site.xml文件,实现“Hive元存储”的存储位置为MySQL数据库;

cd /usr/project/hive/conf/
cp hive-default.xml.template hive-site.xml
vi hive-site.xml
<property>
    <name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
</property>

<property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>passwd</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>hive.querylog.location</name>
      <value>/usr/project/hive/tmp</value>
</property>

<property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/usr/project/hive/tmp/operation_logs</value>
</property>

<property>
    <name>hive.exec.local.scratchdir</name>
    <value>/usr/project/hive/tmp</value>
</property>

<property>
    <name>hive.downloaded.resources.dir</name>
    <value>/usr/project/hive/tmp/resources</value>
</property>

2.3初始化Hive元数据(将MySQL数据库JDBC驱动拷贝到Hive安装目录的lib下),初始化结果;

[root@master conf]# cp ~/mysql-connector-java-5.1.47.jar $HIVE_HOME/lib
[hadoop@master lib]$ rm -f $HADOOP_HOME/share/hadoop/yarn/lib/jline-0.9.94.jar
[hadoop@master lib]$ stop-all.sh
[hadoop@master lib]$ start-all.sh
[root@master conf]# schematool -initSchema -dbType mysql
Metastore connection URL:     jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true&useSSL=false
Metastore Connection Driver :     com.mysql.jdbc.Driver
Metastore connection User:     root
Starting metastore schema initialization to 1.1.0
Initialization script hive-schema-1.1.0.mysql.sql
Initialization script completed
schemaTool completed

2.4启动Hive, 检查是否安装成功;

[root@master ~]# hive

Logging initialized using configuration in jar:file:/usr/project/hive/lib/hive-common-1.1.0.jar!/hive-log4j.properties

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/usr/project/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/usr/project/hive/lib/hive-jdbc-1.1.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

hive> create database stu;

OK

Time taken: 0.151 seconds

hive> show databases;

OK

default

stu

Time taken: 0.011 seconds, Fetched: 2 row(s)

hive> create table stu(name string,age int);

OK

Time taken: 0.204 seconds

hive> show tables;

OK

stu

Time taken: 0.022 seconds, Fetched: 1 row(s)

hive> desc stu;

OK

name string

age int

Time taken: 0.172 seconds, Fetched: 2 row(s)

results matching ""

    No results matching ""