1、驱动拷贝
1)在/opt/software/目录下解压mysql-connector-java-5.1.46.tar.gz驱动包
[victor@node1 software]$ unzip mysql-libs.zip
[victor@node1 mysql-libs]$ tar -zxvf mysql-connector-java-5.1.46.tar.gz
2)拷贝驱动到/opt/module/hive/lib/目录下
[victor@node1 mysql-con...]$ cp mysql-connector-java-5.1.46-bin.jar /opt/module/hive/lib/
2、配置Metastore到MySql
1)在/opt/module/hive/conf目录下创建一个hive-site.xml
[victor@node1 conf]$ touch hive-site.xml
[victor@node1 conf]$ vim hive-site.xml
**尖叫提示,如果用第三方编辑,需要先在hive-site.xml文件中输入任意字符后保存(保证编码)**
2)从hive-default.xml.template拷贝信息到hive-site.xml文件
[victor@node1 conf]$ cat hive-default.xml.template > hive-site.xml
尖叫提示: 复制头部信息即可
3)根据官方文档配置参数
官网地址
https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin
hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node1:3306/metastore?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>000000</value>
<description>password to use against metastore database</description>
</property>
</configuration>
尖叫提示:配置完毕后,如果启动hive异常,可以重新启动虚拟机。(重启后,别忘了启动hadoop集群)
3、多窗口启动Hive测试
1)先启动MySQL
[victor@node1 ~]$ service mysql start
[victor@node1 ~]$ service mysql status
[victor@node1 ~]$ mysql -uroot -p000000
2)查看有几个数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
3)再次打开多个窗口,分别启动hive
[victor@node1 hive]$ bin/hive
4)启动hive后,回到MySQL窗口查看数据库,显示增加了metastore数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| metastore |
| mysql |
| performance_schema |
| test |
+--------------------+