1.http://mirrors.hust.edu.cn/apache/hive/ 进入hive-1.2.2/ 下载 apache-hive-1.2.2-bin.tar.gz, 上传到 /opt/
2.tar apache-hive-1.2.2-bin.tar.gz 解压。
3.export HIVE_HOME=/opt/apache-hive-1.2.2-bin
进入apache-hive-1.2.2-bin/conf 目录
cp hive-default.xml.template hive-default.xml
touch hive-site.xml
全局默认配置hive-default.xml
用户自定义配置hive-site.xml会覆盖hive-default.xml
cp hive-env.sh.template hive-env.sh
hive-site.xml配置如下:
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://host:port/hive_meta?createDatabaseIfNotExist=true</value> <description>JDBC connect string for a JDBC metastore</description> </property> <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.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>mysql:命令
grant all privileges on *.* to hive@root identified by 'hive';
flush privileges;
创建mysql用户hive:
create database hive_metastore;grant all on hive_metastore.* to hive@'%' identified by 'hive';grant all on hive_metastore.* to hive@localhost identified by 'hive';ALTER DATABASE hive_metadata CHARACTER SET latin1;出现的坑:
Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
......
---
Hive2需要hive元数据库初始化:执行命令:schematool -dbType mysql -initSchema
启动Hive服务端程序:hive --service metastore
执行hive: hive
参考博客:https://blog.csdn.net/t1dmzks/article/details/72026876
http://www.tianshouzhi.com/api/tutorials/hive/151