搭建Hadoop2.7.3+Hive2.1.1及MySQL(配置Hive+MySQL+Connector)
Posted 中国风
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搭建Hadoop2.7.3+Hive2.1.1及MySQL(配置Hive+MySQL+Connector)相关的知识,希望对你有一定的参考价值。
续上一篇:
搭建Hadoop2.7.3+Hive2.1.1及mysql(配置Hive+Hadoop)(二)
准备工作下载最新连接器地址
https://dev.mysql.com/downloads/connector/j/
例子:下载mysql-connector-java-5.1.41.tar
1、解压连接器connector文件
1.1、解压
[root@localhost Software]# tar xzfmysql-connector-java-5.1.41.tar.gz
[root@localhost Software]# cd mysql-connector-java-5.1.41/
1.2、查看文件夹
[root@localhostmysql-connector-java-5.1.41]# ll
1.3、Copy到hive/lib路径下
[root@localhost Software]# cpmysql-connector-java-5.1.41/mysql-connector-java-5.1.41-bin.jar/usr/hive/lib/mysql-connector-java-5.1.41-bin.jar
2、登陆MySQL创建数据库:hive_db(注意配置hive-site.xml时有指定)
2.1、用户名:root 密码:password,另开一个终端登陆MySQL,创建数据库hive_db
[root@localhost hive]# mysql -u root -ppassword
mysql> create database hive_db;
3、改配置文件hive-site.xml
以下只列出改动的配置项,其它保留默认
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/usr/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
<description>Use false if a production metastore server is used</description>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive</value>
<description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, with ${hive.scratch.dir.permission}.</description>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_db?createDatabaseIfNoExist=true</value>
<description> Roy
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>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>User-Defined(Roy) Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>User-defined(Roy)Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
<description>User-defined(Roy)password to use against metastore database</description>
</property>
</configuration>
4、使用schematool初始化
以上是关于搭建Hadoop2.7.3+Hive2.1.1及MySQL(配置Hive+MySQL+Connector)的主要内容,如果未能解决你的问题,请参考以下文章