暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL PRO 特性 - rdma 协议使用 - libpq - rsocket API

digoal 2019-09-22
1357

作者

digoal

日期

2019-09-22

标签

PostgreSQL , postgrespro , rdma , 性能


背景

Postgres Pro Enterprise provides support for client/server connections that use remote direct memory access (RDMA) technology. You must have an RDMA implementation set up on both client and server systems.

With RDMA, data can be sent directly into the memory of the remote system, bypassing the operating system kernel. As a result, this reduces the CPU load, ensures low network latency in distributed systems, and yields better performance.

例子

1、数据库端配置

监听

Since all connections use the same port specified in the port variable, make sure to specify different IP addresses in listen_addresses and listen_rdma_addresses to avoid conflicts.

listen_rdma_addresses = '172.17.3.21' wal_level = hot_standby hot_standby = on max_wal_senders = 1

pg_hba.conf防火墙

host all postgres 172.17.3.0/24 md5 host replication postgres 172.17.3.0/24 md5

2、客户端如何使用rdma连接数据库

使用postgrespro提供的支持rdma的客户端libpq。

https://postgrespro.com/docs/enterprise/11/rdma-connections#id-1.6.4.13.6

```

rsocket configuration

[rsocket]
host=hostname
port=5433
user=username
with_rsocket=true
```

或者使用环境变量

export WITH_RSOCKET=true

3、pg_dump导出

export WITH_RSOCKET=true

Once the setup is complete, launch pg_dump as usual. For example:

pg_dump dbname -h hostname > db.sql

4、在master-slave架构中使用rsocket。

standby连接主库时,使用rdma协议。

To set up the standby node:

Set the WITH_RSOCKET environment variable:

export WITH_RSOCKET=true

Copy the data from the master node using pg_basebackup:

pg_basebackup -D datadir -x -R -h 172.17.3.21 -U postgres

All the data appears on the standby node under the specified datadir directory.

Make sure the datadir/recovery.conf contains the with_rsocket parameter.

standby_mode = 'on' primary_conninfo = 'user=postgres host=172.17.3.21 port=5432 with_rsocket=true'

5、监听

In the postgresql.conf file, clear the listen_rdma_addresses parameter:

listen_rdma_addresses = ''

Once the setup is complete, start the standby node. The streaming replication is now performed over the RDMA connections using rsocket API.

On the server side, add the listen_rdma_addresses GUC variable to the postgresql.conf configuration file to specify TCP/IP address(es) on which the server is to listen for new RDMA connections via rsocket from client applications. For example:

listen_rdma_addresses = 'server1,172.17.3.21' # 哪些地址开启rdma监听

You can specify a comma-separated list of host names and/or numeric IP addresses. If set to *, this variable will enable RDMA connections via rsocket to all the available IP interfaces.

Important

Since all connections use the same port specified in the port variable, make sure to specify different IP addresses in listen_addresses and listen_rdma_addresses to avoid conflicts.

建议使用不同的监听地址,因为rdma和普通的连接监听端口都是一致的,所以建议通过ip地址来区分。

参考

https://postgrespro.com/docs/enterprise/11/libpq-connect#LIBPQ-CONNSTRING

with_rsocket

Connects to the server using rsocket API. You must also set the listen_rdma_addresses variable for your server to enable RDMA connections via rsocket.

https://postgrespro.com/list/id/e4588333-5faa-8acb-a74f-da37f82cfa8f@ww-it.cn

https://postgrespro.com/docs/enterprise/11/rdma-connections#id-1.6.4.13.6

PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

文章转载自digoal,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论