PostgreSQL 备份链路sslcompression压缩

通过链路压缩,提高窄带网络PostgreSQL数据库的备份性能。
需要用到PostgreSQL的SSL支持,用法请参考
http://blog.163.com/digoal@126/blog/static/163877040201342233131835

流复制协议,pg_dump都支持ssl,因为它们都走libpq的调用,libpq是支持ssl的。

http://www.postgresql.org/docs/9.3/static/libpq-envars.html

PGSSLCOMPRESSION behaves the same as the sslcompression connection parameter.

http://www.postgresql.org/docs/9.5/static/libpq-connect.html#LIBPQ-CONNECT-SSLCOMPRESSION

sslcompression
If set to 1 (default), data sent over SSL connections will be compressed (this requires OpenSSL version 0.9.8 or later). If set to 0, compression will be disabled (this requires OpenSSL 1.0.0 or later). This parameter is ignored if a connection without SSL is made, or if the version of OpenSSL used does not support it.

Compression uses CPU time, but can improve throughput if the network is the bottleneck. Disabling compression can improve response time and throughput if CPU performance is the limiting factor.

注意如果你用的是linux,可能会遇到LINUX的一个BUG,使用时,数据库服务端和客户端都必须先设置以下环境变量

export OPENSSL_DEFAULT_ZLIB=1

然后启动数据库,和客户端。

psql postgresql://xxx.xxx.xxx.xxx:1921/postgres?user=postgres\&sslcompression=1\&application_name=myapp\&password=postgres\&sslmode=require
psql (9.5.2)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: on)
Type "help" for help.

postgres=# select * from pg_stat_ssl;
 pid  | ssl | version |           cipher            | bits | compression | clientdn 
------+-----+---------+-----------------------------+------+-------------+----------
 9091 | t   | TLSv1.2 | ECDHE-RSA-AES256-GCM-SHA384 |  256 | t           | 
 9106 | t   | TLSv1.2 | ECDHE-RSA-AES256-GCM-SHA384 |  256 | t           | 
(2 rows)

逻辑备份使用ssl压缩

pg_dump postgresql://xxx.xxx.xxx.xxx:1921/postgres?user=postgres\&sslcompression=1\&application_name=myapp\&password=postgres\&sslmode=require -F c -f ./test.dmp

流复制使用SSL压缩

primary_conninfo = 'host=xxx.xxx.xxx.xxx port=xxxx user=xxx password=xxx sslmode=require sslcompression=1'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值