赞
踩
安装包下载安装
把安装包上传到 /opt/software 目录
解压
[kevin@hadoop112 software]$ tar -zxvf apache-hive-2.3.6-bin.tar.gz -C /opt/module/
改名
[kevin@hadoop112 module]$ mv apache-hive-2.3.6-bin/ hive-2.3.6
配置
修改conf 目录下的 hive-env.sh.template 名称为 hive-env.sh
[kevin@hadoop112 hive-2.3.6]$ cd conf/
[kevin@hadoop112 conf]$ mv hive-env.sh.template hive-env.sh
[kevin@hadoop112 conf]$ vim hive-env.sh
配置 hive-env.sh 文件
# 配置 HADOOP_HOME 路径
export HADOOP_HOME=/opt/module/hadoop-2.7.2
# 配置 HIVE_CONF_DIR 路径
export HIVE_CONF_DIR=/opt/module/hive-2.3.6/conf
把Hive的元数据配置到MySQL
拷贝 mysql-connector-java-5.1.48-bin.jar 到/opt/module/hive-2.3.6/lib/
[kevin@hadoop112 conf]# cp /opt/software/mysql-libs-CentOS6/mysql-connector-java-5.1.48.jar /opt/module/hive-2.3.6/lib/
配置Metastore 到 MySQL(MySQL增加 metastore 数据库)
在/opt/module/hive-2.3.6/conf 目录下创建一个 hive-site.xml
[kevin@hadoop112 conf]$ touch hive-site.xml
[kevin@hadoop112 conf]$ vim hive-site.xml
根据官方文档配置参数,拷贝数据到 hive-site.xml 文件中
javax.jdo.option.ConnectionURL
jdbc:mysql://hadoop112:3306/metastore?createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore
javax.jdo.option.ConnectionUserName
root
username to use against metastore database
javax.jdo.option.ConnectionPassword
000000
password to use against metastore database
hive.metastore.warehouse.dir
/user/hive/warehouse
location of default database for the warehouse
hive.cli.print.header
true
hive.cli.print.current.db
true
hive.metastore.schema.verification
false
Enforce metastore schema version consistency.
True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manually 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.
datanucleus.schema.autoCreateAll
true
Auto creates necessary schema on a startup if one doesn't exist. Set this to false, after creating it once.To enable
auto create also set hive.metastore.schema.verification=false. Auto creation is not recommended for production use
cases, run schematool command instead.
配置日志存储位置
[kevin@hadoop112 conf]$ cp hive-log4j.properties.template hive-log4j.properties
[kevin@hadoop112 conf]$ vim hive-log4j.properties
# 修改
hive.log.dir=/opt/module/hive-2.3.6/logs
使用
启动Hadoop集群
[kevin@hadoop112 hive-2.3.6]$ hadoop-cluster.sh start
启动hive
[kevin@hadoop112 hive-2.3.6]$ bin/hive
测试-创建表
hive (default)> create table student(id int, name string);
测试-向表中插入数据
hive (default)> insert into student values(1, "zhangsan");
测试-查表
hive (default)> select * from student;
退出
hive (default)> quit;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。