因为我们选择使用MySQL版安装方式,所以我们保证已经有了一个可连接的MySQL服务。
这里默认装在了Hadoop1主机上,端口是3306,用户名root,密码root。
一、上传安装包并解压
```bash
tar -zxvf apache-hive-1.2.2-bin.tar.gz -C /opt/
```
为了方便操作,将解压后目录更为`hive`。
二、配置文件
```bash
vi /opt/hive/conf/hive-env.sh
```
```bash
# 添加内容
export HADOOP_HOME=/opt/hadoop
```
```bash
vi /opt/hive/conf/hive-default.xml # 配置MYSQL连接
```
```xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop1:3306/hive?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>root</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
<description>password to use against metastore database</description>
</property>
```
三、选择一个MySQL驱动包放入`/opt/hive/lib`目录下。[mysql-connector-java-5.1.6.jar]
启动Hive
```bash
/opt/hive/bin/hive
```