pgspider gzip fdw试用(集成gzip+http+graphql-engine)
gzip 也是一个在实际中比较有用的处理工具,可以减少数据传输,以下是集成gzip http 以及plv8 的处理
gzip Docker 镜像
- Dockerfile
FROM dalongrong/pgspider:base as build
WORKDIR /app
RUN apt-get update && apt-get install -y libssl-dev libz-dev pkg-config
RUN git clone https://github.com/pramsey/pgsql-gzip.git /app/postgresql-11.6/contrib/pgsql-gzip
RUN cd /app/postgresql-11.6/contrib/pgsql-gzip && make && make install
FROM debian:stretch-slim
ENV GOSU_VERSION 1.11
RUN apt-get update && apt-get install -y wget libssl-dev libz-dev libreadline-dev
# explicitly set user/group IDs
RUN set -eux; \
groupadd -r postgres --gid=999; \
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
# also create the postgres user's home directory with appropriate permissions
# see https://github.com/docker-library/postgres/issues/274
mkdir -p /var/lib/postgresql; \
chown -R postgres:postgres /var/lib/postgresql
RUN wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN set -eux; \
if [ -f /etc/dpkg/dpkg.cfg.d/docker ]; then \
# if this file exists, we're likely in "debian:xxx-slim", and locales are thus being excluded so we need to remove that exclusion (since we need locales)
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
fi; \
apt-get update; apt-get install -y locales; rm -rf /var/lib/apt/lists/*; \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8
# install "nss_wrapper" in case we need to fake "/etc/passwd" and "/etc/group" (especially for OpenShift)
# https://github.com/docker-library/postgres/issues/359
# https://cwrap.org/nss_wrapper.html
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends libnss-wrapper; \
rm -rf /var/lib/apt/lists/*
RUN mkdir /docker-entrypoint-initdb.d
COPY --from=build /usr/local/pgspider /usr/local/pgspider
RUN sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/pgspider/share/postgresql/postgresql.conf.sample; \
grep -F "listen_addresses = '*'" /usr/local/pgspider/share/postgresql/postgresql.conf.sample
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
ENV PATH $PATH:/usr/local/pgspider/bin
ENV PGDATA /var/lib/postgresql/data
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"
VOLUME /var/lib/postgresql/data
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]
- 集成http 的docker 镜像
FROM dalongrong/pgspider:base as build
WORKDIR /app
RUN apt-get update && apt-get install -y libssl-dev libz-dev pkg-config libcurl4-openssl-dev
RUN git clone https://github.com/pramsey/pgsql-gzip.git /app/postgresql-11.6/contrib/pgsql-gzip
RUN git clone https://github.com/pramsey/pgsql-http.git /app/postgresql-11.6/contrib/pgsql-http
RUN cd /app/postgresql-11.6/contrib/pgsql-gzip && make && make install
RUN cd /app/postgresql-11.6/contrib/pgsql-http && make && make install
FROM debian:stretch-slim
ENV GOSU_VERSION 1.11
RUN apt-get update && apt-get install -y wget libssl-dev libcurl4-openssl-dev libz-dev libreadline-dev
# explicitly set user/group IDs
RUN set -eux; \
groupadd -r postgres --gid=999; \
# https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
# also create the postgres user's home directory with appropriate permissions
# see https://github.com/docker-library/postgres/issues/274
mkdir -p /var/lib/postgresql; \
chown -R postgres:postgres /var/lib/postgresql
RUN wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN set -eux; \
if [ -f /etc/dpkg/dpkg.cfg.d/docker ]; then \
# if this file exists, we're likely in "debian:xxx-slim", and locales are thus being excluded so we need to remove that exclusion (since we need locales)
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
fi; \
apt-get update; apt-get install -y locales; rm -rf /var/lib/apt/lists/*; \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8
# install "nss_wrapper" in case we need to fake "/etc/passwd" and "/etc/group" (especially for OpenShift)
# https://github.com/docker-library/postgres/issues/359
# https://cwrap.org/nss_wrapper.html
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends libnss-wrapper; \
rm -rf /var/lib/apt/lists/*
RUN mkdir /docker-entrypoint-initdb.d
COPY --from=build /usr/local/pgspider /usr/local/pgspider
RUN sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/pgspider/share/postgresql/postgresql.conf.sample; \
grep -F "listen_addresses = '*'" /usr/local/pgspider/share/postgresql/postgresql.conf.sample
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
ENV PATH $PATH:/usr/local/pgspider/bin
ENV PGDATA /var/lib/postgresql/data
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"
VOLUME /var/lib/postgresql/data
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]
- 集成plv8 的镜像
基于已有的基础镜像添加plv8 支持,因为构建方式使用了静态连接库
FROM dalongrong/pgspider:gzip-http
RUN apt-get update && apt-get install -y libc++1
COPY --from=dalongrong/pgspider:plv8 /usr/local/pgspider/lib/postgresql/plv8-2.3.12.so /usr/local/pgspider/lib/postgresql/plv8-2.3.12.so
COPY --from=dalongrong/pgspider:plv8 /usr/local/pgspider/share/postgresql/extension /usr/local/pgspider/share/postgresql/extension
集成使用
- docker-compose 文件
version: "3"
services:
graphql-engine:
image: hasura/graphql-engine:v1.1.0
ports:
- "8080:8080"
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:dalong@pgspider-fdw:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
pgspider-fdw:
image: dalongrong/pgspider:gzip-http-plv8
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD=dalong"
- 启动
docker-compose up -d
- 使用扩展
// create extension
create extension plv8;
create extension http;
create extension gzip;
// create fucntion
CREATE OR REPLACE FUNCTION plv8_eval_test()
RETURNS text AS $$
var result = eval("1+2")
return JSON.stringify(result);
$$ LANGUAGE plv8 IMMUTABLE STRICT;
// select
create table appdemos as
select encode(gzip(content),'hex') as gzip ,plv8_eval_test() FROM http_get('http://httpbin.org/ip');
- hasura 集成
说明
以上是几个扩展的集成,我们可以灵活的扩展pg 对于数据的支持能力
参考资料
https://github.com/rongfengliang/pgspider-docker
https://github.com/hasura/graphql-engine/releases
https://github.com/pramsey/pgsql-gzip
https://github.com/pramsey/pgsql-http
https://hub.docker.com/repository/docker/dalongrong/pgspider
pgspider gzip fdw试用(集成gzip+http+graphql-engine)的更多相关文章
- tar解压问题gzip: stdin: not in gzip format
如下所示,使用tar -zxvf解压文件时遇到"gzip: stdin: not in gzip format"等错误: [root@DB-Server tmp]# [root@D ...
- 解压.tar.gz出错gzip: stdin: not in gzip format tar: /Child returned status 1 tar: Error is not recoverable: exiting now
先查看文件真正的属性是什么? [root@xxxxx ~]# tar -zxvf tcl8.4.16-src.tar.gz gzip: stdin: not in gzip format tar: ...
- tar 报错gzip: stdin: not in gzip format
今天在linux下 用tar -zxvf xxx.tar.bz2 然后就报这个错. gzip: stdin: not in gzip formattar: Child returned status ...
- 解压tar.gz文件报错gzip: stdin: not in gzip format解决方法
解压tar.gz文件报错gzip: stdin: not in gzip format解决方法 在解压tar.gz文件的时候报错 1 2 3 4 5 [Sun@localhost Downloads] ...
- linux下centos解压时报错: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
最近在linux下安装python时,解压Python.tgz文件时遇到一个问题: gzip: stdin: not in gzip format tar: Child r ...
- MongoDB解压报错gzip: stdin: not in gzip format的解决方法
MongoDB解压报错gzip: stdin: not in gzip format的解决方法 在安装MongoDB时出现如下报错: [root@vm172--- mongodb]# tar -zxv ...
- memcached解压报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now的解决方法
最近在部署环境,在安装memcached的过程中解压时, 解压命令:tar -zvxf memcached-1.4.34.tar.gz 遇到了一个问题, gzip: stdin: not in gzi ...
- 使用tar解压文件提示gzip: stdin: not in gzip format错误
使用tar解压文件提示gzip: stdin: not in gzip format错误 1. 问题描述 使用docker save xxxx > xxx.tar导出镜像,由于文件太大,需要sp ...
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
[root@Gris- FMIS2600bak]# tar -zxvf /home/oradata/FMIS2600DMP.tar.gz gzip: stdin: not in gzip format ...
随机推荐
- cesium纽约3dtiles数据下载
cesium示例有纽约的3dtiles数据,下载官方有下载链接,但是下载后为乱码. 因此研究了下,写了个爬虫解码下载,使用办法,安装Python直接运行即可,代码如下: #coding=utf-8 f ...
- java 编程小知识点
--------------------------------- 时间不多了,抓紧做自己喜欢的事情 1. 使用位运算 & 来判断一个数是否是奇数.偶数的速度很快 (a & 1 ) = ...
- jQuery使用ajax向node后台发送对象、数组参数
引言 最近在使用jq,做一些小demo,但是突然发现jq使用ajax像后台(node)传递一个对象参数,但是后台却接收不了. 原因 后面了解到.jq会将一个对象解析成obj[key]: value这样 ...
- angular之模块开发一
模块化开发 概述 什么是模块化开发 将软件产品看作为一系列功能模块的组合 通过特定的方式实现软件所需模块的划分.管理.加载 为什么使用模块化开发 https://github.com/seajs/se ...
- Ceph 存储集群7-故障排除
Ceph 仍在积极开发中,所以你可能碰到一些问题,需要评估 Ceph 配置文件.并修改日志和调试选项来纠正它. 一.日志记录和调试 般来说,你应该在运行时增加调试选项来调试问题:也可以把调试选项添加到 ...
- CassandraAppender - distributed logging,分布式软件logback-appender
农历年最后一场scala-meetup听刘颖分享专业软件开发经验,大受启发.突然意识到一直以来都没有完全按照任何标准的开发规范做事.诚然,在做技术调研和学习的过程中不会对规范操作有什么严格要求,一旦技 ...
- 如何查看dll或者exe是X86还是X64架构
使用VS里面的dumpbin.exe 用法:dumpbin /headers *.exe(需要运行vcvarsall.bat) C32 or Winhex PE L为x86.PE d†为x64 P ...
- JAVA&&JAVA WEB开发包U盘封装版
难以忍受机房的开发环境,就简单实现了将所有的开发文件封装进了U盘. 基于wmic的强大功能,实现了机房变态环境下的设置环境变量OS不用重新启动OS! install.bat @echo off mod ...
- POJ_2593_DP
http://poj.org/problem?id=2593 和2479一样. #include<iostream> #include<cstdio> #define MIN ...
- 7天用Go动手写/从零实现分布式缓存GeeCache
1 谈谈分布式缓存 第一次请求时将一些耗时操作的结果暂存,以后遇到相同的请求,直接返回暂存的数据.我想这是大部分童鞋对于缓存的理解.在计算机系统中,缓存无处不在,比如我们访问一个网页,网页和引用的 J ...