一 环境
OS:ubuntu 16.04.3 LTS
Hadoop:2.6.5
java:1.8.0_151
Hive 2.1.1
Hadoop集群环境
10.190.3.10 master
10.190.3.6 slave
二 安装
2.1 配置环境变量
HIVE_HOME=/home/hadoop/apache-hive-2.1.1-bin
PATH=$PATH:$HIVE_HOME/bin
export HIVE_NAME PATH
2.2 Metastore
metastore是Hive元数据集中存放地。它包括两部分:服务和后台数据存储。有三种方式配置metastore:内嵌metastore、本地metastore以及远程metastore。
本次搭建中采用MySQL作为远程仓库,部署在master节点上,hive服务端也安装在master上,hive客户端即slave访问hive服务器。
2.3 Mysql安装
sudo apt install mysql-server
2.3.1 编辑/etc/mysql/mysqld.conf.d/mysqld.cnf
bind-address = 10.190.3.10
完成后重启mysql
sudo service mysql restart
2.3.2 创建hive用户并且可以赋予hive远程登录的权限
mysql -u root -p
CREATE USER 'hive' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' WITH GRANT OPTION;
flush privileges;
2.3.3 创建hive数据库
mysql -uroot -p
create database hive
2.4 配置Hive
进入到hive的配置文件目录下,找到hive-default.xml.template,cp份为hive-default.xml
另创建hive-site.xml并添加参数
javax.jdo.option.ConnectionURL
jdbc:mysql://10.190.3.10:3306/hive?createDatabaseIfNotExist=true
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
javax.jdo.option.ConnectionUserName
hive
javax.jdo.option.ConnectionPassword
hive
hive.metastore.schema.verification
false
Enforce metastore schema version consistency.
True: Verify that version information stored in metastore matches with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
2.5 JDBC下载
cp mysql-connector-java-5.1.45-bin.jar apache-hive-2.1.1-bin/lib/
2.6 Hive客户端配置
scp -r apache-hive-1.2.1-bin/ hadoop@slave:/home/hadoop
#登录slave机器
vi hive-site.xml
hive.metastore.uris
thrift://10.190.3.10:9083
Thrift uri for the remote metastore. Used by metastore client to connect to remote metastore.
2.7 Hive启动
schematool -dbType mysql -initSchema --verbose #mysql元数据库初始化
hive --service metastore &
jps
10288 RunJar #多了一个进程
9365 NameNode
9670 SecondaryNameNode
11096 Jps
9944 NodeManager
9838 ResourceManager
9471 DataNode
Hive服务器端即master访问
hive
Hive客户端即slave访问
hive
参考:
1: https://cwiki.apache.org/confluence/display/Hive/AdminManual+Installation
2: https://cwiki.apache.org/confluence/display/Hive/AdminManual+Installation