栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

【CentOS】安装 Hive 组件

【CentOS】安装 Hive 组件


文章目录

1、解压 Hive 安装包2、配置 Hive 环境变量3、配置 hive-env.sh4、配置 hive-site.xml5、初始化 Hive 元数据


环境准备

Hadoop 完全分布式集群系统安装有 MySQLHive 安装包:apache-hive-2.3.9-bin.tar.gzMySQL 连接jar包:mysql-connector-java-5.1.47.jar


1、解压 Hive 安装包

通过 XShell 将安装包上传至虚拟机:

解压安装包并重命名:

返回顶部


2、配置 Hive 环境变量

设置 Hive 环境变量并使其生效:

[root@server ~]# vi /etc/profile
# 在文件末尾追加以下配置内容
# set hive environment
export HIVE_HOME=/usr/local/src/hive
export PATH=$PATH:$HIVE_HOME/bin

# 使环境变量配置生效
[root@server ~]# source /etc/profile

返回顶部


3、配置 hive-env.sh

拷贝 hive-env.sh.template 文件为 hive-env.sh:

[root@server conf]# cp hive-env.sh.template hive-env.sh

配置内容如下:

# Larger heap size may be required when running queries over large number of files or partitions.
# By default hive shell scripts use a heap size of 256 (MB).  Larger heap size would also be
# appropriate for hive server.

# 修改如下:
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/home/hadoop/hadoop/

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

# Folder containing extra libraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/home/hive/lib/

注:第一个为Hadoop目录,第二个为Hive配置目录,最后一个为驱动jar包路径

返回顶部


4、配置 hive-site.xml

可以将 /usr/local/src/hive/conf 文件夹下 hive-default.xml.template 文件,更名为 hive-site.xml。也可以自行创建 hive-site.xml 文件(这里我采用自己创建)直接使用 vi 命令打开配置即可:


    
    
        javax.jdo.option.ConnectionURL
        jdbc:mysql://192.168.64.183:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8
    

    
    
    
    
        javax.jdo.option.ConnectionDriverName
        com.mysql.jdbc.Driver
    

    
    
        javax.jdo.option.ConnectionUserName
        root
    

    
    
        javax.jdo.option.ConnectionPassword
        123456
    

     
    
        hive.metastore.schema.verification
        false
    

    
    
        hive.metastore.warehouse.dir
        /user/hive/warehouse
    
    
	 	hive.querylog.location
	    /usr/local/src/hive/tmp
	    Location of Hive run time structured log file
    
    
        hive.exec.local.scratchdir
        /usr/local/src/hive/tmp
    
    
        hive.downloaded.resources.dir
        /usr/local/src/hive/tmp/resources
    
    
        hive.server2.logging.operation.log.location
        /usr/local/src/hive/tmp/operation_logs
    

在 Hive 安装目录中创建临时文件夹 tmp:

返回顶部


5、初始化 Hive 元数据

将 MySQL 数据库驱动(/../download/mysql-connector-java-5.1.46.jar)拷贝到 Hive 安装目录的 lib 下:

[root@server download]# ll
总用量 1251432
-rw-r--r--. 1 root root 286170958 2月  20 09:34 apache-hive-2.3.9-bin.tar.gz
-rw-r--r--. 1 root root 210606807 2月  19 13:18 hadoop-2.7.1.tar.gz
-rw-r--r--. 1 root root 185646832 12月 24 17:31 jdk-8u181-linux-x64.tar.gz
drwxr-xr-x. 2 root root      4096 2月  24 20:53 mysql-5.7.22
-rw-r--r--. 1 root root 598026240 2月  24 16:13 mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
-rw-r--r--. 1 root root   1004838 2月  26 2018 mysql-connector-java-5.1.46.jar
[root@server download]# cp mysql-connector-java-5.1.46.jar /usr/local/src/hive/lib/

重新启动 hadooop 即可:

[root@server sbin]# ./start-all.sh


初始化数据库:

[root@server ~]# schematool -initSchema -dbType mysql
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/src/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/src/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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.apache.logging.slf4j.Log4jLoggerFactory]
metastore connection URL:	 jdbc:mysql://192.168.64.183:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8
metastore Connection Driver :	 com.mysql.jdbc.Driver
metastore connection User:	 root
Fri Feb 25 15:01:39 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Fri Feb 25 15:01:40 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Initialization script completed
Fri Feb 25 15:01:41 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
schemaTool completed

启动hive:

[root@server ~]# hive
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/src/java/bin:/usr/local/src/hadoop/bin:/usr/local/src/hadoop/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/src/java/bin:/root/bin:/usr/local/src/java/bin:/usr/local/src/hadoop/bin:/usr/local/src/hadoop/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/src/java/bin:/usr/local/src/hadoop/bin:/usr/local/src/hadoop/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/src/java/bin:/root/bin:/usr/local/src/java/bin:/usr/local/src/hive/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/src/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/src/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/usr/local/src/hive/lib/hive-common-2.3.9.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> 

Hive 启动成功的同时,在mysql数据库中会建立一个hive数据库:

[root@server ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 13
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive               |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.07 sec)

到此 hive 安装完成!

返回顶部


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/745175.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号