• Hive基础(二):使用基础(2)Hive 安装(一)(centos)


    1 Hive安装地址

    1Hive官网地址

    http://hive.apache.org/

    2文档查看地址

    https://cwiki.apache.org/confluence/display/Hive/GettingStarted

    3下载地址

    http://archive.apache.org/dist/hive/

    4github地址

    https://github.com/apache/hive

    2 MySql安装

    2.1 安装包准备

    1)卸载自带的Mysql-libs(如果之前安装过mysql,要全都卸载掉)

    [atguigu@hadoop102 software]$ rpm -qa | grep -i -E mysql|mariadb | xargs -n1 sudo rpm -e --nodeps

    2)将安装包和JDBC驱动上传到/opt/software,共计6

    01_mysql-community-common-5.7.29-1.el7.x86_64.rpm
    02_mysql-community-libs-5.7.29-1.el7.x86_64.rpm
    03_mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
    04_mysql-community-client-5.7.29-1.el7.x86_64.rpm
    05_mysql-community-server-5.7.29-1.el7.x86_64.rpm
    mysql-connector-java-5.1.48.jar

    2.2 安装MySql

    1安装mysql依赖

    [atguigu@hadoop102 software]$ sudo rpm -ivh 01_mysql-community-common-5.7.29-1.el7.x86_64.rpm
    [atguigu@hadoop102 software]$ sudo rpm -ivh 02_mysql-community-libs-5.7.29-1.el7.x86_64.rpm
    [atguigu@hadoop102 software]$ sudo rpm -ivh 03_mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm

    2安装mysql-client

    [atguigu@hadoop102 software]$ sudo rpm -ivh 04_mysql-community-client-5.7.29-1.el7.x86_64.rpm

    3安装mysql-server

    [atguigu@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.29-1.el7.x86_64.rpm

    4启动mysql

    [atguigu@hadoop102 software]$ sudo systemctl start mysqld

    5查看mysql密码

    [atguigu@hadoop102 software]$ sudo cat /var/log/mysqld.log | grep password

    2.3 配置MySql

    配置只要是root用户+密码,在任何主机上都能登录MySQL数据库。

    1)用刚刚查到的密码进入mysql(如果报错,给密码加单引号)

    [atguigu@hadoop102 software]$ mysql -uroot -p’password’

    2)设置复杂密码(由于mysql密码策略,此密码必须足够复杂)

    mysql> set password=password("Qs23=zs32");

    3)更改mysql密码策略

    mysql> set global validate_password_length=4;
    mysql> set global validate_password_policy=0;

    4设置简单好记的密码

    mysql> set password=password("000000");

    5进入msyql

    mysql> use mysql

    6查询user

    mysql> select user, host from user;

    7修改userHost表内容修改为%

    mysql> update user set host="%" where user="root";

    8刷新

    mysql> flush privileges;

    9退出

    mysql> quit;

    Hive安装部署

    1apache-hive-3.1.2-bin.tar.gz上传到linux/opt/software目录下

    2解压apache-hive-3.1.2-bin.tar.gz/opt/module/目录下面

    [atguigu@hadoop102 software]$ tar -zxvf /opt/software/apache-hive-3.1.2-bin.tar.gz -C /opt/module/

    3修改apache-hive-3.1.2-bin.tar.gz的名称为hive

    [atguigu@hadoop102 software]$ mv /opt/module/apache-hive-3.1.2-bin/ /opt/module/hive

    4修改/etc/profile.d/my_env.sh添加环境变量

    [atguigu@hadoop102 software]$ sudo vim /etc/profile.d/my_env.sh

    5添加内容

    #HIVE_HOME
    export HIVE_HOME=/opt/module/hive
    export PATH=$PATH:$HIVE_HOME/bin

    重启Xshell对话框使环境变量生效

    6)解决日志Jar包冲突

    [atguigu@hadoop102 software]$ mv $HIVE_HOME/lib/log4j-slf4j-impl-2.10.0.jar $HIVE_HOME/lib/log4j-slf4j-impl-2.10.0.bak

    4 Hive元数据配置到MySql

    4.1 拷贝驱动

    MySQLJDBC驱动拷贝到Hivelib目录下

    [atguigu@hadoop102 software]$ cp /opt/software/mysql-connector-java-5.1.48.jar $HIVE_HOME/lib

    4.2 配置MetastoreMySql

    $HIVE_HOME/conf目录下新建hive-site.xml文件

    [atguigu@hadoop102 software]$ vim $HIVE_HOME/conf/hive-site.xml

    添加如下内容

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    <configuration>
        <property>
            <name>javax.jdo.option.ConnectionURL</name>
            <value>jdbc:mysql://hadoop102:3306/metastore?useSSL=false</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>000000</value>
        </property>
    
        <property>
            <name>hive.metastore.warehouse.dir</name>
            <value>/user/hive/warehouse</value>
        </property>
    
        <property>
            <name>hive.metastore.schema.verification</name>
            <value>false</value>
        </property>
    
        <property>
            <name>hive.metastore.uris</name>
            <value>thrift://hadoop102:9083</value>
        </property>
    
        <property>
        <name>hive.server2.thrift.port</name>
        <value>10000</value>
        </property>
    
        <property>
            <name>hive.server2.thrift.bind.host</name>
            <value>hadoop102</value>
        </property>
    
        <property>
            <name>hive.metastore.event.db.notification.api.auth</name>
            <value>false</value>
        </property>
    
    </configuration>

    5 安装Tez引擎

    Tez一个Hive的运行引擎,性能优于MR。为什么优于MR呢?看下图。

    Hive直接编写MR程序假设有四个有依赖关系的MR作业,上图中,绿色是Reduce Task,云状表示写屏蔽需要中间结果持久化写到HDFS

    Tez可以将多个有依赖的作业转换为一个作业这样只需写一次HDFS,且中间节点较少,从而大大提升作业的计算性能

    1)将tez安装包拷贝到集群,并解压tar

    [atguigu@hadoop102 software]$ mkdir /opt/module/tez
    [atguigu@hadoop102 software]$ tar -zxvf /opt/software/tez-0.10.1-SNAPSHOT-minimal.tar.gz -C /opt/module/tez

    2)上传tez依赖到HDFS

    [atguigu@hadoop102 software]$ hadoop fs -mkdir /tez
    [atguigu@hadoop102 software]$ hadoop fs -put /opt/software/tez-0.10.1-SNAPSHOT.tar.gz /tez

    3新建tez-site.xml

    [atguigu@hadoop102 software]$ vim $HADOOP_HOME/etc/hadoop/tez-site.xml

    添加如下内容

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    <configuration>
    <property>
        <name>tez.lib.uris</name>
        <value>${fs.defaultFS}/tez/tez-0.10.1-SNAPSHOT.tar.gz</value>
    </property>
    <property>
         <name>tez.use.cluster.hadoop-libs</name>
         <value>true</value>
    </property>
    <property>
         <name>tez.am.resource.memory.mb</name>
         <value>1024</value>
    </property>
    <property>
         <name>tez.am.resource.cpu.vcores</name>
         <value>1</value>
    </property>
    <property>
         <name>tez.container.max.java.heap.fraction</name>
         <value>0.4</value>
    </property>
    <property>
         <name>tez.task.resource.memory.mb</name>
         <value>1024</value>
    </property>
    <property>
         <name>tez.task.resource.cpu.vcores</name>
         <value>1</value>
    </property>
    </configuration>

    4)修改Hadoop环境变量

    编辑hadoop-env.sh

    [atguigu@hadoop102 software]$ vim $HADOOP_HOME/etc/hadoop/shellprofile.d/tez.sh

    添加TezJar包相关信息

    hadoop_add_profile tez
    function _tez_hadoop_classpath
    {
        hadoop_add_classpath "$HADOOP_HOME/etc/hadoop" after
        hadoop_add_classpath "/opt/module/tez/*" after
        hadoop_add_classpath "/opt/module/tez/lib/*" after
    }

    5)修改Hive的计算引擎

    [atguigu@hadoop102 software]$ vim $HIVE_HOME/conf/hive-site.xml

    添加

    <property>
        <name>hive.execution.engine</name>
        <value>tez</value>
    </property>
    <property>
        <name>hive.tez.container.size</name>
        <value>1024</value>
    </property>

    6)解决日志Jar包冲突

    [atguigu@hadoop102 software]$ rm /opt/module/tez/lib/slf4j-log4j12-1.7.10.jar

    本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/13358328.html

  • 相关阅读:
    考试备忘
    php代码规范
    text-indent: -999px;是什么意思
    MYSQL中的普通索引,主健,唯一,全文索引区别
    Mysql索引介绍及常见索引(主键索引、唯一索引、普通索引、全文索引、组合索引)的区别
    flush privileges是什么意思?
    大长今
    深入理解this对象
    如何将js与HTML完全脱离
    php页面相互调用的知识点
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/13358328.html
Copyright © 2020-2023  润新知