Hive-0.12.0 配置Mysql的Metasotre

转载自:Hive-0.12.0 配置Mysql的Metasotre

  1.  官网下载Hive-0.12.0

    下载地址:hive-0.12.0

  2、安装Mysql-server

Hive-0.12.0 配置Mysql的Metasotre
#注意:如果安装mysql完整的server-client,yum执行yum -y install mysql-server 如果,仅仅安装客户端yum -y install mysql即可
#这里我们安装完整的mysql-server
$sudo yum -y install mysql-server
#设置开机自启动
$sudo /sbin/chkconfig --add mysqld
$sudo /sbin/chkconfig mysqld on  
$sudo /sbin/service mysqld start
#设置初始root密码
$sudo mysqladmin -u root password a123456

$mysql -uroot -pa123456

#创建DB for Hive MetaStore
mysql> create database hive_metastore;
#给予mysql root用户以master.hadoop上的所有权限,本机hostname为master.hadoop
mysql> grant all privileges on *.* to root@master.hadoop identified by a123456;
mysql> flush privileges;
Hive-0.12.0 配置Mysql的Metasotre

  

  3.  解压压缩包并修改环境变量.

Hive-0.12.0 配置Mysql的Metasotre
[hadoop@master ~]$ tar -xzvf hive-0.12.0.tar.gz
[hadoop@master ~]$ cd hive-0.12.0/
[hadoop@master hive-0.12.0]$ pwd
/home/hadoop/hive-0.12.0  

#修改/etc/profile 添加HIVE_HOME环境变量,并将Hive的bin添加到PATH中
[hadoop@master hive-0.12.0]$ sudo vim /etc/profile
#在最后追加:
#hive-0.12.0
export HIVE_HOME=/home/hadoop/hive-0.12.0
export PATH=${PATH}:${HIVE_HOME}/bin

#编辑完之后到shell下执行:
[hadoop@master hive-0.12.0]$ source /etc/profile
Hive-0.12.0 配置Mysql的Metasotre

  

  4.  阅读官方文档关于Mysql-Metastore有关Remote Metastore的介绍

  官方地址:https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin

 

   其中有关Remote Metastore的Server端配置说明如下:

   Hive-0.12.0 配置Mysql的Metasotre

  根据以上信息配置hive-site.xml

  

Hive-0.12.0 配置Mysql的Metasotre
[hadoop@master hive-0.12.0]$ cd conf/
[hadoop@master conf]$ cp hive-default.xml.template hive-site.xml 
Hive-0.12.0 配置Mysql的Metasotre

  编辑hive-site.xml

  找到:javax.jdo.option.ConnectionURLjavax.jdo.option.ConnectionDriverName,修改为:

Hive-0.12.0 配置Mysql的Metasotre
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://master.hadoop/hive_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>
Hive-0.12.0 配置Mysql的Metasotre

   找到:javax.jdo.option.ConnectionUserNamejavax.jdo.option.ConnectionPassword,修改为:

Hive-0.12.0 配置Mysql的Metasotre
<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>a123456</value>
  <description>password to use against metastore database</description>
</property>
Hive-0.12.0 配置Mysql的Metasotre

  将准备好的mysql-jdbc的jar, copy到$HIVE_HOME/lib下:

Hive-0.12.0 配置Mysql的Metasotre
[hadoop@master]$ cp mysql-connector-java-5.1.9.jar $HIVE_HOME/lib/
Hive-0.12.0 配置Mysql的Metasotre

  仅仅设置完后,仍然报错:

Hive-0.12.0 配置Mysql的Metasotre

  查看Hive的日志,默认的位于/tmp/${username}/hive.log, 在hive-site.xml中配置。

Hive-0.12.0 配置Mysql的Metasotre

  回头查看Remote Metastore文档下面有:

 

 Hive-0.12.0 配置Mysql的Metasotre

  我们回头编辑hive-site.xml文件找到hive.metastore.schema.verification的配置,并将其设置成false。(注意:改参数在生成metastore时会用到)

Hive-0.12.0 配置Mysql的Metasotre
<property>
  <name>hive.metastore.schema.verification</name>
  <value>false</value>
   <description>
   Enforce metastore schema version consistency.
   True: Verify that version information stored in metastore matches with one from Hive jars.  Also disable automatic
         schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures
         proper metastore schema migration. (Default)
   False: Warn if the version information stored in metastore doesn‘t match with one from in Hive jars.
   </description>
</property>
Hive-0.12.0 配置Mysql的Metasotre

配置完成。

  5.  启动hive shell环境,执行show databases 则代表已经成功生成metastore。

Hive-0.12.0 配置Mysql的Metasotre

  进入mysql环境,查看hive元数据。

Hive-0.12.0 配置Mysql的Metasotre

 

Hive 的具体操作请参看:Hive官方文档

Hive-0.12.0 配置Mysql的Metasotre,布布扣,bubuko.com

Hive-0.12.0 配置Mysql的Metasotre

上一篇:mysql配置之skip-external-locking


下一篇:在VB.NET中,将数据库里的数据导出到Excel中