01 在CentOS7中安装Hive

hive是能够使mapreduce过程简化的数据仓库,提供了众多的常用算子。hive的安装部署有三种:默认[使用自带deby数据库]、本地[使用mysql数据库]和远程[metastore和mysql不在同一个机子]。本文将阐述hive在CentOS7中的默认安装。

1 系统、软件以及前提约束

  • CentOS 7 64 工作站 作者的机子ip是192.168.100.200,主机名为 danji,请读者根据自己实际情况设置
  • 在CentOS7中已经安装hadoop并启动
    https://www.jianshu.com/p/b7ae3b51e559
  • apache-hive-0.14.0
    hive下载链接:https://pan.baidu.com/s/1c_skDYabCRSkS5hRUB6lFQ
    提取码:a00t
    apache-hive-0.14.0-bin.tar.gz已上传到192.168.100.200的/root目录下
  • xshell
  • 为去除权限对操作的影响,所有操作都以root进行

2 操作

  • 1.使用xshell以root登录到192.168.100.200
  • 2.解压和配置环境变量
tar -xvf apache-hive-0.14.0-bin.tar.gz
# 配置环境变量,修改~/.bashrc,在其中加入以下内容【请读者根据实际情况修改路径】
export JAVA_HOME=/root/jdk1.8.0_152
export HIVE_HOME=/root/apache-hive-0.14.0-bin
export PATH=$HIVE_HOME/bin:$HIVE_HOME/conf:$JAVA_HOME/bin:$PATH
# 保存退出,使生效
source ~/.bashrc
  • 3.修改hive-site.xml
# 进入hive配置目录
cd /root/apache-hive-0.14.0-bin/conf
# 由模板拷贝一份hive-site.xml
cp hive-default.xml.template hive-site.xml  
# 修改hive-site.xml,加入以下内容,保存退出
<property>
   <name>system:java.io.tmpdir</name>
     <value>/root/apache-hive-0.14.0-bin/tmpdir</value>
     </property>
<property>
     <name>system:user.name</name>
     <value>hive</value>
   </property>
  • 4.在HDFS中创建两个文件夹并赋予权限
    hive.metastore.warehouse.dir:该参数指定了 Hive 的数据存储目录
    hive.exec.scratchdir:该参数指定了 Hive 的数据临时文件目录
# 进入hadoop的bin目录
cd /root/hadoop-2.5.2/bin
# 创建/user/hive/warehouse
./hdfs dfs -mkdir -p /user/hive/warehouse  
# 赋予/user/hive/warehouse权限
./hdfs dfs -chmod 777 /user/hive/warehouse  
# 创建/tmp/hive 
./hdfs dfs -mkdir -p /tmp/hive 
# 赋予/tmp/hive 权限
./hdfs dfs -chmod 777 /tmp/hive 
  • 拷贝并修改hive-env.sh
# 进入hive的conf目录
cd /root/apache-hive-0.14.0-bin/conf   
# 拷贝hive-env.sh
cp hive-env.sh.template hive-env.sh
# 修改以下键值对
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/root/hadoop-2.5.2

# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/root/apache-hive-0.14.0-bin/conf

# Folder containing extra ibraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/root/apache-hive-0.14.0-bin/lib

3 测试

# 进入hive的bin目录
cd /root/apache-hive-0.14.0-bin/bin
# 启动hive
./hive
# 出现以下内容,则启动成功,具体内容有些许差别,但大体一致
[root@localhost bin]# ./hive
Logging initialized using configuration in jar:file:/root/apache-hive-0.14.0-bin/lib/hive-common-0.14.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/apache-hive-0.14.0-bin/lib/hive-jdbc-0.14.0-standalone.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]
hive> 

以上,就是在CentOS7中安装hive默认方式的过程。

转载于:https://www.jianshu.com/p/755944f01fab

猜你喜欢

转载自blog.csdn.net/weixin_34281537/article/details/91051970