引言
接着上两篇(Hadoop集群搭建、ZooKeeper 、HBase集群搭建),最后介绍下Hive的安装、配置。
MySQL安装、配置
安装
见安装Apache(2.4.17)、MySQL(5.5.46)、PHP7、Nginx(1.8)。
配置
创建hive用户并授权并接着创建hive数据库
create database hive;
use mysql;
grant all on hive.* to hive@'%' identified by 'hive';
flush privileges;
Hive部署
安装
去官网下载stable版本(在Master服务器上)
cd /usr/localhost
sudo wget http://mirrors.cnnic.cn/apache/hive/hive-2.1.0/apache-hive-2.1.0-bin.tar.gz
sudo tar zxf apache-hive-2.1.0-bin.tar.gz
sudo mv apache-hive-2.1.0-bin.tar.gz hive
sudo chown hadoop.hadoop hive -R
下载mysql配套的jar
包(在MySQL官网上),并放入Hive
的lib
目录。
配置
配置环境变量
sudo vim /etc/profile
export HIVE_HOEM=/usr/local/hive
export PATH=$PATH:/usr/local/hive/bin
在命令行输入. /etc/profile并回车使其生效
进入配置目录,把hive-env.sh.template
复制为hive-env.sh
,并配置
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
# hadoop安装目录
HADOOP_HOME=/usr/local/hadoop
# hive配置目录
export HIVE_CONF_DIR=/usr/local/hive/conf
创建hive-site.xml
并配置
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://10.254.21.30:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/usr/local/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>
</configuration>
运行
初始化
schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/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]
Metastore connection URL: jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: hive
Starting metastore schema initialization to 2.1.0
Initialization script hive-schema-2.1.0.mysql.sql
Initialization script completed
运行
hive
[hadoop@Master bin]$ hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/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:/usr/local/hive/lib/hive-common-2.1.0.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>