zoukankan      html  css  js  c++  java
  • 基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】HAWQ数据仓库 使用之 gpfdist协议

    一、HAWQ基本安装自带gpfdist协议

    gpfdist是HAWQ支持的外部表访问协议之一,这是hawq自带的一个简单的集成http服务命令。

    在我的前述安装hawq之后,gpfdist命令位于hawq的bin目录之中。/opt/gpadmin/apache-hawq/bin/gpfdist

    gpfdist使用说明很简单,且看:

    [root@ep-bd01 ~]# /opt/gpadmin/apache-hawq/bin/gpfdist --help
    gpfdist -- file distribution web server
    
    usage: gpfdist [--ssl <certificates_directory>] [-d <directory>] [-p <http(s)_port>] [-l <log_file>] [-t <timeout>] [-v | -V] [-m <maxlen>][-c file]
    
           gpfdist [-? | --help] | --version
    
            -?, --help : print this screen
            -v         : verbose mode
            -V         : more verbose
            -p port    : port to serve HTTP(S), default is 8080
            -d dir     : serve files under the specified directory,  default is '.'
            -l logfn   : log filename
            -t tm      : timeout in seconds 
            -m maxlen  : max data row length expected, in bytes. default is 32768
            --ssl dir  : start HTTPS server. Use the certificates from the specified directory
            -c file    : configuration file for transformations
            --version  : print version information

    这里我只关心-d和-p两个命令行参数

    二、gpfdist服务简单使用

    1,启动gpfdist服务

    gpfdist不像pxf协议那么麻烦,由于他只是服务于本机目录,所以只要在数据目录所在的主机上启动gpfdist,hawq即可访问了。

    [root@ep-bd01 ~]# /opt/gpadmin/apache-hawq/bin/gpfdist -p8809 -d/var/data/ext
    Serving HTTP on port 8809, directory /var/data/ext

    2,准备数据文件

    1)建立本地路径/var/data/ext/yxbw

    2)路径放置从hdfs文件系统中复制过来的用sqoop从其他数据库系统的数据表导入的数据文件,并且导入时启用了--compress参数,所以数据文件是gz压缩格式,这个gpfdist协议可以直接访问。

    [root@ep-bd01 pxf]# hdfs dfs -copyToLocal /var/data/ext/table1/* /var/data/ext/table1/. 
    [root@ep-bd01 pxf]# ll /var/data/ext/table1/
    总用量 152
    -rw-r--r--. 1 root root 69503 9月  10 09:45 part-m-00000.gz
    -rw-r--r--. 1 root root 41334 9月  10 09:45 part-m-00001.gz
    -rw-r--r--. 1 root root 24035 9月  10 09:45 part-m-00002.gz
    -rw-r--r--. 1 root root 14345 9月  10 09:45 part-m-00003.gz
    -rw-r--r--. 1 root root     0 9月  10 09:45 _SUCCESS

    3,建立hawq外部表

    注意,gpfdist路径中的table1路径是相对于gpfdist服务启动时通过参数"-d"指定的数据路径的。

    create external table ext.table1 (occur_time date, ......) location ('gpfdist://ep-bd01:8081/table1') format 'text'(delimiter ',' null '');    

    4,访问外部表

    epbd=> select count(*) from ext.table1;
     count 
    -------
      6288
    (1 row)
    
    Time: 258.015 ms
  • 相关阅读:
    机器学习-liuyubobobo(慕课网)
    python进阶 廖雪峰(慕课网)
    ajax 报0错误
    nav破解
    thinkphp5--关于多条件查询的分页处理问题
    JS/JQuery获取当前元素的上一个/下一个兄弟级元素等元素的方法
    linux 批量删除文件
    Linux下which命令使用详解(转)
    thinkphp5和nginx不得不说的故事
    Git基本操作和使用
  • 原文地址:https://www.cnblogs.com/dajianshi/p/9605563.html
Copyright © 2011-2022 走看看