gpt4 book ai didi

ssh-tunnel - 通过 ssh 隧道使用 postgres_fdw

转载 作者:行者123 更新时间:2023-12-03 21:39:41 25 4
gpt4 key购买 nike

可以使用 postgres_fdw 通过 ssh 隧道连接吗?

数据库只能从数据库服务器访问,我需要从另一个远程服务器加入。数据库服务器使用 SSH key 登录。

如果可以,请问怎么做?

最佳答案

对的,这是可能的。我像这样为 mysql_fdw 解决了它;
我使用 autossh 进行端口转发。使用 autossh,您可以始终保持连接。
在 Postgres 服务器上运行命令:autossh -L 127.0.0.1:3306:mysql_ip:3306 root@mysql_ip -N -i .ssh/id_rsa.mysql测试从 Postgres 到 Mysql 的 autossh 访问。
在 Postgres 服务器上运行命令;mysql --host=127.0.0.1 --port=3306 -u mysqldbuser -p最后不同的部分是;CREATE SERVER mysql_server FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host '127.0.0.1', port '3306');其他的都是一样的。

关于ssh-tunnel - 通过 ssh 隧道使用 postgres_fdw,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26408566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com