罗名岳
发布于

Hive安装步骤

Hive 安装步骤(连网)
1.下载安装包,并配置环境变量

vim ~/.bash_profile
export HIVE_HOME=/app/hive/apache-hive-2.1.1-bin
PATH=$PATH:$HOME/bin:$HIVE_HOME/bin
export PATH

2.安装配置 MySQL

  # 下载rpm包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
# 安装rpm包
yum -y install mysql57-community-release-el7-10.noarch.rpm
# 安装mysql服务器
yum -y install mysql-community-server
安装完报错:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY 从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥 源 "MySQL 5.7 Community Server" 的 GPG 密钥已安装,但是不适用于此软件包。请检查源的公钥 URL 是否配置正确。 失败的软件包是:mysql-community-libs-compat-5.7.37-1.el7.x86_64 GPG 密钥配置为:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
执行如下命令后重新安装
sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/mysql-community.repo
yum -y install mysql-community-server
# 启动mysql并查看状态
systemctl start mysqld.service
systemctl status mysqld.service
此时MySQL已经开始正常运行,不过要想进入MySQL还得先找出此时root用户的密码,通过如下命令可以在日志文件中找出密码:

grep "password" /var/log/mysqld.log

# 登录mysql
mysql -uroot -p
# 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Oushu@1234';
# 开启mysql远程访问
grant all privileges on *.* to 'root'@'%' identified by 'Oushu@1234' with grant option;
flush privileges;

3.编辑 hive-env.sh,加入如下内容

  JAVA_HOME=/usr/java/default
HADOOP_HOME=/usr/hdp/2.5.3.0-37/hadoop
HIVE_HOME=/opt/module/hive
export HIVE_CONF_DIR=$HIVE_HOME/conf
#export HIVE_AUX_JARS_PATH=$SPARK_HOME/lib/spark-assembly-1.6.0-hadoop2.6.0.jar
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$HADOOP_HOME/lib:$HIVE_HOME/lib
#export HADOOP_OPTS="-Dorg.xerial.snappy.tempdir=/tmp -Dorg.xerial.snappy.lib.name=libsnappyjava.jnilib $HADOOP_OPTS

4.修改 hive-log4j.properties

  cp hive-log4j2.properties.template hive-log4j2.properties

5.编辑 hive-site.xml,参考如下内容

  cp hive-default.xml.template hive-site.xml
  <?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


   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--><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>javax.jdo.option.ConnectionUserName</name>用户名(这4是新添加的,记住删除配置文件原有的哦!)
        <value>root</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionPassword</name>密码
        <value>123456</value>
    </property>
   <property>
        <name>javax.jdo.option.ConnectionURL</name>mysql
        <value>jdbc:mysql://192.168.1.68:3306/hive</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>mysql驱动程序
        <value>com.mysql.jdbc.Driver</value>
    </property>
        <!-- 到此结束代码 -->




  <property>
    <name>hive.exec.script.wrapper</name>
    <value/>
    <description/>
  </property>
</configuration>

6.在 MySQL 中创建 Hive 数据库

  mysql> CREATE DATABASE hive;
mysql> USE hive;
mysql> CREATE USER 'hive'@'localhost' IDENTIFIED BY 'Hive@123';
mysql> GRANT ALL ON hive.* TO 'hive'@'localhost' IDENTIFIED BY 'Hive@123';
mysql> GRANT ALL ON hive.* TO 'hive'@'%' IDENTIFIED BY 'Hive@123';
mysql> FLUSH PRIVILEGES;
mysql> quit;

7.初始化

  schematool -dbType mysql -initSchema

8.使用 hive 命令启动数据库

  hive

9.beeline 工具测试 hive 连接

  $HIVE_HOME/bin/beeline -u jdbc:hive2://localhost:10000

使用 JDBC 连接 hive 时的启动方式

nohup hive --service metastore &
nohup hive --service hiveserver2 &
评论
    test