解决 Azure Databases for MariaDB 的连接问题Troubleshoot connection issues to Azure Database for MariaDB

连接问题可能由多种因素造成,包括:Connection problems may be caused by a variety of things, including:

  • 防火墙设置Firewall settings
  • 连接超时Connection time-out
  • 不正确的登录信息Incorrect login information
  • 某些 Azure Database for MariaDB 资源达到了最大限制Maximum limit reached on some Azure Database for MariaDB resources
  • 服务的基础结构出现问题Issues with the infrastructure of the service
  • 正在服务中执行维护Maintenance being performed in the service
  • 通过缩放 vCore 数目或移到不同的服务层级更改了服务器的计算资源分配The compute allocation of the server is changed by scaling the number of vCores or moving to a different service tier

通常,Azure Database for MariaDB 的连接问题可按如下方式分类:Generally, connection issues to Azure Database for MariaDB can be classified as follows:

  • 暂时性错误(短暂或间歇性)Transient errors (short-lived or intermittent)
  • 持久或非暂时性错误(定期重复发生的错误)Persistent or non-transient errors (errors that regularly recur)

对暂时性错误进行故障排除Troubleshoot transient errors

在执行维护、系统遇到硬件或软件错误,或更改服务器的 vCore 数目或服务层级时,会发生暂时性错误。Transient errors occur when maintenance is performed, the system encounters an error with the hardware or software, or you change the vCores or service tier of your server. Azure Database for MariaDB 服务具有内置的高可用性,可以自动缓解此类问题。The Azure Database for MariaDB service has built-in high availability and is designed to mitigate these types of problems automatically. 但是,应用程序会短暂地与服务器断开连接,通常不会超过 60 秒。However, your application loses its connection to the server for a short period of time of typically less than 60 seconds at most. 某些事件偶尔可能需要更长的时间才能缓解,例如,当某个大型事务导致恢复长时间运行时。Some events can occasionally take longer to mitigate, such as when a large transaction causes a long-running recovery.

解决暂时性连接问题的步骤Steps to resolve transient connectivity issues

  1. 检查 Azure 服务仪表板,了解在由应用程序报告错误期间是否发生任何已知的服务中断。Check the Azure Service Dashboard for any known outages that occurred during the time in which the errors were reported by the application.
  2. 连接到云服务的应用程序(例如 Azure Database for MariaDB)应预料到会发生暂时性错误,并实施重试逻辑来处理这些错误,而不是将它们作为应用程序错误展现给用户。Applications that connect to a cloud service such as Azure Database for MariaDB should expect transient errors and implement retry logic to handle these errors instead of surfacing these as application errors to users. 查看处理 Azure Database for MariaDB 的暂时性连接错误,了解有关处理暂时性错误的最佳做法和设计准则。Review Handling of transient connectivity errors for Azure Database for MariaDB for best practices and design guidelines for handling transient errors.
  3. 由于服务器即将达到其资源限制,错误可能看起来像是暂时性连接问题。As a server approaches its resource limits, errors can seem to be transient connectivity issue. 请参阅 Azure Database for MariaDB 中的限制See Limitations in Azure Database for MariaDB.
  4. 如果连接问题继续存在,或者应用程序发生错误的持续时间超过 60 秒或在特定的一天中看到错误多次发生,请通过在 Azure 支持网站上选择“获取支持”提出 Azure 支持请求。If connectivity problems continue, or if the duration for which your application encounters the error exceeds 60 seconds or if you see multiple occurrences of the error in a given day, file an Azure support request by selecting Get Support on the Azure Support site.

排查一再出现的错误Troubleshoot persistent errors

如果应用程序一直无法连接到 Azure Database for MariaDB,通常表示下列其中一项出现了问题:If the application persistently fails to connect to Azure Database for MariaDB, it usually indicates an issue with one of the following:

  • 防火墙配置:Azure Database for MariaDB 服务器或客户端防火墙正在阻止连接。Firewall configuration: The Azure Database for MariaDB server or client-side firewall is blocking connections.
  • 客户端上的网络重新配置:添加了新的 IP 地址或代理服务器。Network reconfiguration on the client side: A new IP address or a proxy server was added.
  • 用户失误:例如,连接参数的键入错误(例如,在连接字符串中键入了服务器名称,或者在用户名中遗漏了 @servername 后缀)。User error: For example, you may have mistyped connection parameters, such as the server name in the connection string or a missing @servername suffix in the user name.

解决永久性连接问题的步骤Steps to resolve persistent connectivity issues

  1. 设置防火墙规则以允许客户端 IP 地址。Set up firewall rules to allow the client IP address. (仅出于临时测试目的)使用 作为起始 IP 地址,使用 作为结束 IP 地址,来设置一个防火墙规则。For temporary testing purposes only, set up a firewall rule using as the starting IP address and using as the ending IP address. 这样会使服务器向所有 IP 地址开放。This will open the server to all IP addresses. 如果这样可以解决连接性问题,请删除此规则,再针对适当限制的 IP 地址或地址范围创建防火墙规则。If this resolves your connectivity issue, remove this rule and create a firewall rule for an appropriately limited IP address or address range.
  2. 在客户端与 Internet 之间的所有防火墙上,确保为出站连接打开端口 3306。On all firewalls between the client and the internet, make sure that port 3306 is open for outbound connections.
  3. 验证连接字符串和其他连接设置。Verify your connection string and other connection settings. 查看如何将应用程序连接到 Azure Database for MariaDBReview How to connect applications to Azure Database for MariaDB.
  4. 在仪表板中检查服务运行状况。Check the service health in the dashboard. 如果你认为发生了区域性服务中断,请参阅有关使用 Azure Database for MariaDB 确保业务连续性的概述,了解恢复到新区域所要执行的步骤。If you think there's a regional outage, see Overview of business continuity with Azure Database for MariaDB for steps to recover to a new region.

后续步骤Next steps