*注意:安装部署hive之前,首先要安装完成jdk和hadoop。如有需要,可以查看博客:Haoop2.5.0伪分布式环境搭建。
step1:解压安装包
tar -xzvf apache-hive-0.13.1-bin.tar.gz -C /opt/software/
step2:在hdfs上创建hive所需要的目录及权限修改
hdfs dfs -mkdir /tmp
hdfs dfs -mkdir -p /user/hive/warehouse
hdfs dfs -chmod g+w /tmp
hdfs dfs -chmod g+w /user/hive/warehouse
step3:修改hive-env.sh中HADOOP_HOME及HIVE_CONF_DIR属性值,注意改名
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/opt/software/hadoop-2.5.0
# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/opt/software/hive-0.13.1-bin/conf
step4:hive元数据信息默认是使用的Derby数据库,derby数据库只支持一个hive连接,修改为使用关系型数据库mysql存储hive元数据信息。
1.安装mysql数据库
# 查询系统中没有mysql
sudo rpm -qa | grep mysql
# 卸载自带的mysql库
sudo rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64
# 使用yum进行mysql的安装
sudo yum -y install mysql-server
# 查看mysqld服务是否开启
sudo service mysqld status
# 启动mysql服务
sudo service mysqld start
# 设置开机启动mysqld
sudo chkconfig mysqld on
# 设置mysql管理员root的密码
mysqladmin -u root password '123456'
2.设置mysql的连接权限
mysql -uroot -p # 进入mysql命令行
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges; # 刷新
quit; # 退出
sudo service mysqld restart # 重启mysql服务
3.自定义hive的配置文件,从默认的文件(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>
<property>
<name>hive.exec.mode.local.auto</name>
<value>true</value>
</property>
<property>
<name>hive.exec.mode.local.auto.input.files.max</name>
<value>100</value>
</property>
<property>
<name>hive.exec.mode.local.auto.inputbytes.max</name>
<value>13421772800000</value>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.current.db</name>