文章地址:http://www.haha174.top/article/details/253250
一.下载
http://www.apache.org/dyn/closer.cgi/hive/
可以去官网下载适合的版本
二.安装mysql
可以参考
http://www.haha174.top/article/details/257849
三.mysql connector
yum install -y mysql-connector-java
cp /usr/share/java/mysql-connector-java-5.1.17.jar /hadoop/hive/apache-hive-2.2.0-bin/lib
执行命令 mysql 登陆数据库
create database if not exists hive_metadata;
GRANT ALL PRIVILEGES ON hive_metadata.* TO ‘hive’@’%’ IDENTIFIED BY ‘hive’;
GRANT ALL PRIVILEGES ON hive_metadata.* TO ‘hive’@’localhost’ IDENTIFIED BY ‘hive’;
GRANT ALL PRIVILEGES ON hive_metadata.* TO ‘hive’@’spark’ IDENTIFIED BY ‘hive’;
flush privileges;
四.配置hive
cp hive-default.xml.template hive-site.xml
vi hive-site.xml
主要修改下面几项
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</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.ConnectionURL</name>
<value>jdbc:mysql://spark1:3306/hive_metadata?createDatabaseIfNotExist=true</value>
<description>
JDBC connect string for a JDBC metastore.
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
</description>
</property>
注意要将所有 ${system:java.io.tmpdir} 修改掉不然启动可能会报错
如果懒的话可以直接下载我已经配置好的
www.haha174.top:8086/hive/hive-site.xml
cp hive-env.sh.template hive-env.sh
加上
export JAVA_HOME=/apps/adf/java/jdk1.8.0_121
export HIVE_HOME=/hadoop/hive/apache-hive-2.2.0-bin
export HADOOP_HOME_HOME=/hadoop/hadoop-2.9.0
到hive 的bin 目录下
执行 schematool -dbType mysql -initSchema
切换一下到mysql
然后
./hive
气动hive
如果启动成功则会看到