hive 2.1.0 安装及MySQL元数据管理配置

时间:2022-09-21 20:24:41

一、环境准备
jdk 1.8+
hadoop 2.x
mysql 5.x
安装之前请确保以上环境已准备完毕
二、安装
1. 下载并解压
进入解压之后的目录,使用当前路径配置HIVE_HOME
2. 进入安装目录下conf目录
vim 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.ConnectionURL</name>
<value>jdbc:mysql://worker2:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
</configuration>
  1. 修改安装目录下bin目录里的hive-config.sh
    vim hive-config.sh
    加入以下配置:
export JAVA_HOME=/wxm/software/java/jdk8/jdk1.8.0_91
export HIVE_HOME=/wxm/software/hive/apache-hive-2.1.0-bin
export HADOOP_HOME=/wxm/software/hadoop/hadoop2.7.2/hadoop-2.7.2
  1. 初始化元数据
bin/schematool -dbType  mysql -initSchema
  1. 启动并测试
    bin/hive
    create database test_1121;
    use test_1121;
    create table student (id int,name string);
    insert into student values(1,’test’);
    select * from student;