使用QGTUNNEL(价格)分开PymySQL数据库连接的任何地方的最佳方法?

发布于 2025-01-29 11:39:23 字数 458 浏览 6 评论 0原文

我们正在运行15-20个不同的python脚本,这些脚本都与同一数据库交谈。该脚本是通过有时会同时运行的不同任务进行安排的,在启动QGTUNNEL时我们会遇到以下错误...

2022/05/16 12:52:11 Error initializing tcp socket 127.0.0.1:3306: listen tcp 127.0.0.1:3306: bind: address already in use

2022/05/16 12:52:11 Error initializing tcp socket 127.0.0.1:1433: listen tcp 127.0.0.1:1433: bind: address already in use 

我们考虑要求我们的MySQL提供商让MySQL在更多端口上收听,但他们不允许这样做。我们还考虑过每个脚本都有不同的环境,但是在尝试之前,我想询问是否有更好的方法。感谢建议。

We are running 15-20 different python anywhere scripts that all talk to the same database. The script are scheduled through different tasks that are sometimes running simultaneously and we get the following error when launching qgtunnel...

2022/05/16 12:52:11 Error initializing tcp socket 127.0.0.1:3306: listen tcp 127.0.0.1:3306: bind: address already in use

2022/05/16 12:52:11 Error initializing tcp socket 127.0.0.1:1433: listen tcp 127.0.0.1:1433: bind: address already in use 

We thought about asking our mysql provider to have mysql listen on more ports but they don't allow that. We also thought about having a different environment for each script but before we try that I wanted to ask if there's a better way. Apprecite the advice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

茶花眉 2025-02-05 11:39:23

因此,在与配额合作后,他们的CTO有了一个好主意。在运行每个脚本之前,覆盖.qgtunnel设置文件并指定您的端口。我将其推出了所有脚本,现在没有绑定错误。覆盖设置文件看起来像这样...

cat <<EOF > /home/qgtunnel/.qgtunnel
[qgtunnel.Name_of_script_changing_file_sh]
accept = "127.0.0.1:5007"
connect = "host_url:3306"
encrypted = false
transparent = true
EOF

cd /home/qgtunnel ./bin/qgtunnel python3 ~/dir/python_script.py

So after working with quotaquard their CTO had a great idea. Before running each script overwrite the .qgtunnel settings files and specify your port. I rolled that out to all the scripts and now I have no binding errors. Overwriting the settings file looks like this...

cat <<EOF > /home/qgtunnel/.qgtunnel
[qgtunnel.Name_of_script_changing_file_sh]
accept = "127.0.0.1:5007"
connect = "host_url:3306"
encrypted = false
transparent = true
EOF

cd /home/qgtunnel ./bin/qgtunnel python3 ~/dir/python_script.py
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文