搭建Hive集群

6 篇文章 0 订阅

将下载后的hive包解压到相应目录改名:下载地址:https://mirrors.cnnic.cn/apache/hive

配置文件改名:

[yexin@node78 conf]$ mv beeline-log4j2.properties.template beeline-log4j2.properties
[yexin@node78 conf]$ mv hive-env.sh.template hive-env.sh
[yexin@node78 conf]$ mv hive-exec-log4j2.properties.template hive-exec-log4j2.properties
[yexin@node78 conf]$ mv hive-log4j2.properties.template hive-log4j2.properties
[yexin@node78 conf]$ mv llap-cli-log4j2.properties.template llap-cli-log4j2.properties
[yexin@node78 conf]$ mv llap-daemon-log4j2.properties.template llap-daemon-log4j2.properties

修改hive-env.sh文件

# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/home/yexin/Hadoop/hadoop/

# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/home/yexin/hive2/conf/

# Folder containing extra libraries required for hive compilation/execution can be controlled by:

export HIVE_AUX_JARS_PATH=/home/yexin/hive2/lib/

------------------------------------------------------------------------------------------------------------------

配置hive-site.xml:我这里因为将mysql安装在node78上,所以配置的使本地存储模式。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.  You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
<configuration>
  <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
  <!-- WARNING!!! Any changes you make to this file will be ignored by Hive.   -->
  <!-- WARNING!!! You must make your changes in hive-site.xml instead.         -->
  <!-- Hive Execution Parameters -->

  <!-- 插入一下代码 -->
    <property>
         <name>hive.metastore.warehouse.dir</name>
         <value>/hive/warehouse</value>
    </property>
    <property>
         <name>hive.metastore.uris</name>
         <value>thrift://node78:9083</value>
    </property>
    <property>
         <name>hive.querylog.location</name>
         <value>/home/yexin/hive2/logs</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>yexin</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>12345</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://node78:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
    </property>

    <property>
        <name>hive.server2.webui.host</name>
        <value>node78</value>
    </property>
    
    <property>
        <name>hive.server2.webui.host.port</name>
        <value>10002</value>
    </property>
</configuration>

  <!-- 到此结束代码 -->

==================================================================

下载MySQL Connector/J包:

http://central.maven.org/maven2/mysql/mysql-connector-java/6.0.6/

拷贝到:/home/yexin/hive2/lib

操作mysql数据库:给Mysql对用户yexin授权,修改用户hive不需要SSL

GRANT ALL PRIVILEGES ON *.* TO 'yexin'@'%' IDENTIFIED BY '12345';

GRANT ALL PRIVILEGES ON *.* TO 'yexin'@'localhost' IDENTIFIED BY '12345';

ALTER USER 'yexin'@'%' REQUIRE none;

yexin用户之前已经创建:

创建用户命令:

 

CREATE USER 'username'@'host' IDENTIFIED BY 'password'

=======================================================================

在node78节点启动hive

(1)创建数据库hive,在node78节点进入到/home/yexin/hive2/scripts/metastore/upgrade/mysql运行下面命令,

         因为mysql安装在node78

       mysql -hnode78 -uyexin -p12345

      

创建数据库:create database hive character set utf8;

                     use hive;

                     source hive-schema-2.3.0.mysql.sql;

     

启动hive metastore服务:

启动hiveservice2服务:

输入网址可咦看到启动成功:

 

 

         选择node82节点作为客户端主机安装HIve;同时/etc/profile也要修改和node78一样。

从node78拷贝过来:scp -r hive2/ yexin@node82:/home/yexin/

修改为为:

<configuration>
  <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
  <!-- WARNING!!! Any changes you make to this file will be ignored by Hive.   -->
  <!-- WARNING!!! You must make your changes in hive-site.xml instead.         -->
  <!-- Hive Execution Parameters -->

  <!-- 插入一下代码 -->
    <property>
         <name>hive.metastore.warehouse.dir</name>
         <value>/yexin/hive/warehouse</value>
    </property>
    <property>
         <name>hive.metastore.uris</name>
         <value>thrift://node78:9083</value>
    </property>
    <property>
         <name>hive.querylog.location</name>
         <value>/home/yexin/hive2/logs</value>
    </property>

</configuration>

 

测试Hive

创建数据库:

可以在hdfs中也可以看到通过hive-site.xml设置的warehouse.dir,数据保存在hdfs中;

SUCCESS!!!

杀掉进程即可关闭hive

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值