当前位置:   article > 正文

基于Hadoop安装Hive_安装hive+hadoop

安装hive+hadoop


一、安装准备工作

1、安装HIve前得安装好Hadoop集群,不会安装的去我前面文章找
2、安装包准备
3、在Hadoop的namenode节点服务器安装即可
  • 1
  • 2
  • 3

链接:链接:https://pan.baidu.com/s/1XuSDdssel1mzbfW3wAYmhQ
提取码:whrs
复制这段内容后打开百度网盘手机App,操作更方便哦–来自百度网盘超级会员V1的分享

二、安装

1、将HIve安装包上传至 /usr/local 文件下

tar -zxvf apache-hive-2.3.3-bin.tar.gz
#更换名称
mv apache-hive-2.3.3-bin hive
vim /etc/profile
export HIVE_HOME=/usr/local/hive
在之前的配置上加上  :$HIVE_HOME/bin
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

在这里插入图片描述
2、配置Hive

cd /usr/local/hive/conf
cp hive-default.xml.template  hive-site.xml
  • 1
  • 2

3、在Hdfs中创建Hive所需目录

[hadoop@master conf]$ hdfs dfs -mkdir -p /user/hive/warehouse
[hadoop@master conf]$ hdfs dfs -chmod -R 777 /user/hive/warehouse
[hadoop@master conf]$ hdfs dfs -mkdir -p /tmp/hive
[hadoop@master conf]$ hdfs dfs -chmod -R 777 /tmp/hive
[hadoop@master conf]$ hdfs dfs -ls /
Found 2 items
drwx------   - hadoop supergroup          0 2018-08-12 11:53 /tmp
drwxr-xr-x   - hadoop supergroup          0 2018-08-12 14:31 /user
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

4、配置Hive本地临时目录

将 hive-site.xml 文件中的 ${system:java.io.tmpdir} 替换为hive的本地临时目录,例如我使用的是 /usr/local/hive/tmp ,如果该目录不存在,需要先进行创建,并且赋予读写权限

cd /usr/local/hive
mkdir tmp/
chmod -R 777 tmp/
cd /usr/local/hive/conf
vim hive-site.xml
  • 1
  • 2
  • 3
  • 4
  • 5

vim命令模式下执行如下命令完成替换:

:%s#${system:java.io.tmpdir}#/usr/local/hive/tmp#g
  • 1

配置Hive用户名-----操作Hive的账户的用户名,博主此刻登录的root用户

:%s#${system:user.name}#root#g
  • 1

5、修改Hive数据库配置

Hive默认的配置使用的是Derby数据库来存储Hive的元数据信息,其配置信息如下:

<property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>org.apache.derby.jdbc.EmbeddedDriver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
    <description>
      JDBC connect string for a JDBC metastore.
      To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
      For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
    </description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>APP</value>
    <description>Username to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>mine</value>
    <description>password to use against metastore database</description>
  </property>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

如果你需要将Derby数据库切换为MySQL数据库的话,只需要修改以上4项配置,例如,我的是:

<property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.cj.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://192.168.220.137:3306/hive?createDatabaseIfNotExist=true</value>
    <description>
      JDBC connect string for a JDBC metastore.
      To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
      For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
    </description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>root</value>
    <description>Username to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>199700</value>
    <description>password to use against metastore database</description>
  </property>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

此外,还需要将MySQL的驱动包放到到Hive的lib目录下:
jar包在网盘中有,将jar包上传至hive的lib目录下

6、配置hive-env.sh

cd /usr/local/hive/conf
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
# 编辑 hive-env.sh 增加下面3行内容

export HADOOP_HOME=/usr/local/hadoop
export HIVE_CONF_DIR=/usr/local/hive/conf
export HIVE_AUX_JARS_PATH=/usr/local/hive/lib
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

三、启动和测试

初始化:

cd /usr/local/hive/bin
schematool -initSchema -dbType mysql
  • 1
  • 2

查看mysql:

在这里插入图片描述
会在mysql自动生成hive库。

3.1、启动HIve

cd /usr/local/hive/bin
./hive
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/java/bin:/usr/local/hadoop/bin:/usr/local/java/bin:/usr/local/hadoop/bin:/usr/local/hive/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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/hive/lib/hive-common-2.3.3.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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/567961
推荐阅读
相关标签
  

闽ICP备14008679号