Hive的安装

一 下载hive
[root@centos opt]# wget https://mirror.bjtu.edu.cn/apache/hive/hive-2.1.1/apache-hive-2.1.1-bin.tar.gz
二 安装hive
[root@centos opt]# tar -zxvf apache-hive-2.1.1-bin.tar.gz
[root@centos opt]# mv apache-hive-2.1.1-bin hive-2.1.1
三  mysql驱动包导入
[root@centos lib]# ll mysql-connector-java-5.1.30-bin.jar
-rw-r--r-- 1 root root 954041 Mar 11  2014 mysql-connector-java-5.1.30-bin.jar
四 hadoop配置
1 启动HDFS和Yarn
[root@centos hadoop-2.7.4]# sbin/start-dfs.sh
[root@centos hadoop-2.7.4]# sbin/start-yarn.sh
[root@centos hadoop-2.7.4]# jps
4466 SecondaryNameNode
4631 ResourceManager
4887 Jps
4302 DataNode
4175 NameNode
4735 NodeManager
2 离开安全模式
[root@centos hadoop-2.7.4]# bin/hadoop  dfsadmin -safemode leave
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Safe mode is OFF
3 创建相关目录并赋予权限
[root@centos hadoop-2.7.4]# hdfs dfs -mkdir -p /usr/hive/warehouse
[root@centos hadoop-2.7.4]# hdfs dfs -mkdir -p /usr/hive/tmp
[root@centos hadoop-2.7.4]# hdfs dfs -mkdir -p /usr/hive/log
[root@centos hadoop-2.7.4]# hdfs dfs -chmod g+w /usr/hive/warehouse
[root@centos hadoop-2.7.4]# hdfs dfs -chmod g+w /usr/hive/tmp
[root@centos hadoop-2.7.4]# hdfs dfs -chmod g+w /usr/hive/log
[root@centos hadoop-2.7.4]# hdfs dfs -chmod o+w /usr/hive/tmp
[root@centos hadoop-2.7.4]# hdfs dfs -chmod o+w /usr/hive/log
[root@centos hadoop-2.7.4]# hdfs dfs -chmod o+w /usr/hive/warehouse
五 配置环境变量/etc/profile
export HIVE_HOME=/opt/hive-2.1.1
export PATH=$PATH:$HIVE_HOME/bin
[root@centos hive-2.1.1]# source /etc/profile
六 hive-env.sh配置
[root@centos conf]# cp hive-env.sh.template hive-env.sh
[root@centos conf]# vi hive-env.sh
[root@centos conf]# cat hive-env.sh
export JAVA_HOME=/opt/jdk1.8
export HADOOP_HOME=/opt/hadoop-2.7.4  
export HIVE_HOME=/opt/hive-2.1.1
export HIVE_CONF_DIR=$HIVE_HOME/conf
export HIVE_AUX_JARS_PATH=$HIVE_HOME/lib/*
七 hive-site.xml配置
[root@centos conf]# cp hive-default.xml.template hive-site.xml
该文件配置如下:
<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.exec.scratchdir</name>  
    <value>/usr/hive/tmp</value>  
    <description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, with ${hive.scratch.dir.permission}.</description>  
  </property>  
  <property>  
    <name>hive.metastore.warehouse.dir</name>  
    <value>/usr/hive/warehouse</value>  
    <description>location of default database for the warehouse</description>  
  </property>  
<property>  
    <name>hive.querylog.location</name>  
    <value>/usr/hive/log</value>  
    <description>Location of Hive run time structured log file</description>  
  </property>  
<property>  
    <name>javax.jdo.option.ConnectionURL</name>  
    <value>jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true</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>root</value>  
  </property>  
</configuration>
  <property>
    <name>hive.exec.local.scratchdir</name>
    <value>/usr/hive/tmp/local</value>
    <description>Local scratch space for Hive jobs</description>
  </property>
  <property>
    <name>hive.downloaded.resources.dir</name>
    <value>/usr/hive/tmp/resources</value>
    <description>Temporary local directory for added resources in the remote file system.</description>
  </property>
  <property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/opt/hive-2.1.1/iotmp</value>
    <description>Top level directory where operation logs are stored if logging functionality is enabled</description>
  </property>
八 测试
schematool 命令来执行初始化操作
[root@centos conf]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.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.slf4j.impl.Log4jLoggerFactory]
18/01/03 21:52:49 INFO conf.HiveConf: Found configuration file file:/opt/hive-2.1.1/conf/hive-site.xml
Metastore connection URL:     jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :     com.mysql.jdbc.Driver
Metastore connection User:     root
Starting metastore schema initialization to 2.1.0
Initialization script hive-schema-2.1.0.mysql.sql
Initialization script completed
schemaTool completed
2 连接测试
[root@centos hadoop-2.7.4]# hive
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/jdk1.8/bin:/opt/hadoop-2.7.4/bin:/opt/sqoop-1.4.6/bin:/opt/hive-2.1.1/bin:/root/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/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:/opt/hive-2.1.1/lib/hive-common-2.1.1.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> show databases;
OK
default
Time taken: 1.023 seconds, Fetched: 1 row(s)
九 参考
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值