文章目录
  1. 1. Prerequisite
  2. 2. Versions (2018/03/14)
  3. 3. Install Hive and Hadoop
  4. 4. Configure enviromental variables
  5. 5. Download JDBC
  6. 6. Setup MySQL database
  7. 7. Copy hive-default-xml to hive-site.xml
  8. 8. Edit following lines in hive-site.xml
  9. 9. Run hive

Prerequisite

MySQL 5.6.22 is already installed.

Versions (2018/03/14)

  • Hadoop 3.0.0
  • Hive 2.3.1

Install Hive and Hadoop

1
2
$ brew update
$ brew install hive

Configure enviromental variables

1
2
3
# ~/.bashrc
export HADOOP_HOME=/usr/local/Cellar/hadoop/3.3.0/libexec
export HIVE_HOME=/usr/local/Cellar/hive/2.7.1/libexec

Download JDBC

Go to mysql page and download the latest jdbc (sign up is required)
http://dev.mysql.com/downloads/connector/j/

1
2
$ tar zxvf mysql-connector-java-5.1.35.tar.gz
$ sudo cp mysql-connector-java-5.1.35/mysql-connector-java-5.1.35-bin.jar /usr/local/Cellar/hive/2.7.1/libexec/lib/

Setup MySQL database

1
2
3
4
5
$ mysql
mysql> CREATE DATABASE metastore;
mysql> USE metastore;
mysql> CREATE USER 'hiveuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE ON metastore.* TO 'hiveuser'@'localhost';

Copy hive-default-xml to hive-site.xml

1
2
$ cd /usr/local/Cellar/hive/2.7.1/libexec/conf
$ cp hive-default.xml.template hive-site.xml

Edit following lines in hive-site.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hiveuser</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>false</value>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/tmp/hive</value>
<description>Local scratch space for Hive jobs</description>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/tmp/hive</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
<property>
<name>hive.querylog.location</name>
<value>/tmp/hive</value>
<description>Location of Hive run time structured log file</description>
</property>

Run hive

1
2
$ hive
hive > show tables;
文章目录
  1. 1. Prerequisite
  2. 2. Versions (2018/03/14)
  3. 3. Install Hive and Hadoop
  4. 4. Configure enviromental variables
  5. 5. Download JDBC
  6. 6. Setup MySQL database
  7. 7. Copy hive-default-xml to hive-site.xml
  8. 8. Edit following lines in hive-site.xml
  9. 9. Run hive