gpt4 book ai didi

wordpress - 谷歌云计算实例 + WordPress

转载 作者:行者123 更新时间:2023-12-01 12:28:13 25 4
gpt4 key购买 nike

我最近使用 Google Cloud Compute VM 实例设置并部署了两个标准的 WordPress 安装。

我遇到的问题是,当站点空闲几个小时或几天时,建立与数据库的连接时出错。

如果我重置服务器,一切正常。

我距离成为基于云的服务器的专家还差得很远,如果有任何建议,我将不胜感激!

最佳答案

我还在 Google GCE Group 中发布了这个问题。

https://groups.google.com/forum/#!topic/gce-discussion/8knQumfLsBY

感谢来自 Google 支持的 George,修复非常简单。

On GCE idle TCP connections are disconnected after 10 minutes. If your instance initiates or accepts long-lived connections with an external host, you can adjust TCP keep-alive settings to prevent these timeouts from dropping connections. You can configure the keep-alive settings on the Compute Engine instance, your external client, or both, depending on the host that typically initiates the connection. You should set the keep-alives to less than 600 seconds to ensure that connections are refreshed before the timeout occurs. You can do that by running the following command:

sudo /sbin/sysctl -w net.ipv4.tcp_keepalive_time=60 net.ipv4.tcp_keepalive_intvl=60 net.ipv4.tcp_keepalive_probes=5

您只能以 root 身份运行该命令。所以 sudo su 切换到 root。

To ensure that the settings survive a reboot, add the settings to your /etc/sysctl.conf file.

This option is only available from the command line on the instance itself. In order to have the changes added to the " /etc/sysctl.conf " you can access the file using any of your preferred editors (vi, nano...) and add the following:

# increase the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 60

此解决方案已确认解决了我的问题,希望对其他人有所帮助。

关于wordpress - 谷歌云计算实例 + WordPress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37446372/

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