基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】HAWQ数据仓库 使用之 gpfdist协议
一、HAWQ基本安裝自帶gpfdist協(xié)議
gpfdist是HAWQ支持的外部表訪問(wèn)協(xié)議之一,這是hawq自帶的一個(gè)簡(jiǎn)單的集成http服務(wù)命令。
在我的前述安裝hawq之后,gpfdist命令位于hawq的bin目錄之中。/opt/gpadmin/apache-hawq/bin/gpfdist
gpfdist使用說(shuō)明很簡(jiǎn)單,且看:
[root@ep-bd01 ~]# /opt/gpadmin/apache-hawq/bin/gpfdist --help gpfdist -- file distribution web serverusage: 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這里我只關(guān)心-d和-p兩個(gè)命令行參數(shù)
二、gpfdist服務(wù)簡(jiǎn)單使用
1,啟動(dòng)gpfdist服務(wù)
gpfdist不像pxf協(xié)議那么麻煩,由于他只是服務(wù)于本機(jī)目錄,所以只要在數(shù)據(jù)目錄所在的主機(jī)上啟動(dòng)gpfdist,hawq即可訪問(wèn)了。
[root@ep-bd01 ~]# /opt/gpadmin/apache-hawq/bin/gpfdist -p8809 -d/var/data/ext Serving HTTP on port 8809, directory /var/data/ext2,準(zhǔn)備數(shù)據(jù)文件
1)建立本地路徑/var/data/ext/yxbw
2)路徑放置從hdfs文件系統(tǒng)中復(fù)制過(guò)來(lái)的用sqoop從其他數(shù)據(jù)庫(kù)系統(tǒng)的數(shù)據(jù)表導(dǎo)入的數(shù)據(jù)文件,并且導(dǎo)入時(shí)啟用了--compress參數(shù),所以數(shù)據(jù)文件是gz壓縮格式,這個(gè)gpfdist協(xié)議可以直接訪問(wèn)。
[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路徑是相對(duì)于gpfdist服務(wù)啟動(dòng)時(shí)通過(guò)參數(shù)"-d"指定的數(shù)據(jù)路徑的。
create external table ext.table1 (occur_time date, ......) location ('gpfdist://ep-bd01:8081/table1') format 'text'(delimiter ',' null '');4,訪問(wèn)外部表
epbd=> select count(*) from ext.table1;count -------6288 (1 row)Time: 258.015 ms?
總結(jié)
以上是生活随笔為你收集整理的基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】HAWQ数据仓库 使用之 gpfdist协议的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Ant Design Pro开发后台管理
- 下一篇: nodejs源码—初始化