其他分享
首页 > 其他分享> > 1.6 Hive配置metastore

1.6 Hive配置metastore

作者:互联网

一、配置

1、配置文件

#创建配置文件
[root@hadoop-senior ~]# cd /opt/modules/hive-0.13.1/conf/

[root@hadoop-senior conf]# ls
hive-default.xml.template  hive-env.sh  hive-exec-log4j.properties.template  hive-log4j.properties.template

[root@hadoop-senior conf]# touch hive-site.xml


#
此时可以对比着hive-default.xml.template文件来修改;
hive-default.xml.template是一个模板文件;


#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://hadoop-senior.ibeifeng.com: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>123456</value>
        <description>password to use against metastore database</description>
    </property>

</configuration>

hive-site.xml配置文件中,JDBC的配置可参考官网:https://cwiki.apache.org/confluence/display/Hive/AdminManual+Metastore+Administration

image

jdbc:mysql://hadoop-senior.ibeifeng.com:3306/metastore?createDatabaseIfNotExist=true

另外用户名、密码是mysql的,我这里是root、123456

现在hive与mysql是在同一台服务器上;


2、拷贝mysq1驱动jar包,到Hive安装目录的1ib下

[root@hadoop-senior mysql-libs]# tar zxf mysql-connector-java-5.1.27.tar.gz 

[root@hadoop-senior mysql-libs]# ls
MySQL-client-5.6.24-1.el6.x86_64.rpm  mysql-connector-java-5.1.27  mysql-connector-java-5.1.27.tar.gz  MySQL-server-5.6.24-1.el6.x86_64.rpm

[root@hadoop-senior mysql-libs]# cd mysql-connector-java-5.1.27

[root@hadoop-senior mysql-connector-java-5.1.27]# ls
build.xml  CHANGES  COPYING  docs  mysql-connector-java-5.1.27-bin.jar  README  README.txt  src

[root@hadoop-senior mysql-connector-java-5.1.27]# cp mysql-connector-java-5.1.27-bin.jar /opt/modules/hive-0.13.1/lib/

3、进入hive

#连接hive
[root@hadoop-senior hive-0.13.1]# bin/hive
Logging initialized using configuration in jar:file:/opt/modules/hive-0.13.1/lib/hive-common-0.13.1.jar!/hive-log4j.properties
hive> 


#查看mysql库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| metastore          |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

可见已经多了一个metastore 库,此库不用创建,是自动生成的;


#hive的元数据都在metastore库中,在mysql中查看
mysql> use metastore;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------+
| Tables_in_metastore       |
+---------------------------+
| BUCKETING_COLS            |
| CDS                       |
| COLUMNS_V2                |
| DATABASE_PARAMS           |
| DBS                       |
| FUNCS                     |
| FUNC_RU                   |
| GLOBAL_PRIVS              |
| PARTITIONS                |
| PARTITION_KEYS            |
| PARTITION_KEY_VALS        |
| PARTITION_PARAMS          |
| PART_COL_STATS            |
| ROLES                     |
| SDS                       |
| SD_PARAMS                 |
| SEQUENCE_TABLE            |
| SERDES                    |
| SERDE_PARAMS              |
| SKEWED_COL_NAMES          |
| SKEWED_COL_VALUE_LOC_MAP  |
| SKEWED_STRING_LIST        |
| SKEWED_STRING_LIST_VALUES |
| SKEWED_VALUES             |
| SORT_COLS                 |
| TABLE_PARAMS              |
| TAB_COL_STATS             |
| TBLS                      |
| VERSION                   |
+---------------------------+
29 rows in set (0.00 sec)

标签:1.6,hadoop,hive,metastore,Hive,mysql,senior,root
来源: https://www.cnblogs.com/weiyiming007/p/10734482.html