zoukankan      html  css  js  c++  java
  • 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

    • hadoop-senior.ibeifeng.com  #mysql主机名
    • 3306  #mysql 端口
    • metastore  #存储hive元数据的库,此库不用创建,会自动生成
    • createDatabaseIfNotExist=true  #此句就是判断metastore库是否存在的,不存在则自动创建

    另外用户名、密码是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)
  • 相关阅读:
    Redis Sentinel:集群Failover解决方案(转载)
    C#获取Windows屏幕尺寸
    C# 获取屏幕的大小 SystemInformation类
    拆分器控件Splitcontainer
    (收藏)《博客园精华集》分类索引(转 )
    Redis内存数据库在Exchange会议室的应用(转)
    【转】开源Math.NET基础数学类库使用(01)综合介绍
    15个nosql数据库
    20个代码生成框架(转)
    nodeJS安装和环境变量的配置
  • 原文地址:https://www.cnblogs.com/weiyiming007/p/10734482.html
Copyright © 2011-2022 走看看