alwayson只读副本失效问题 AlwaysOn 可用性组配置疑难解答 (SQL Server)Troubleshoot Always On Availability Groups Configuration (SQL Server)
测试环境上安装了AlwaysOn,但是发现只读连接后数据还是连接到主库,没有连接到只读库,经检查发现是因为只读副本库的端口没有配置为1433,后通过只读库的SQl Server配置管理器-Sql Server网络配置-MSSQLSERVER的协议-TCP/IP中将TCP/IP属性-IP地址-IPAll的TCP DynamicPorts设置为1433,问题解决。
以下是微软的针对AlwaysOn的常见问题解答
Troubleshoot Always On Availability Groups Configuration (SQL Server)
- 帐户
- 端点
- System Name
- Network Access
- 端点访问(SQL Server 错误 1418)
- 联接数据库失败(SQL Server 错误 35250)
- 只读路由未正确工作
- 相关任务
- 相关内容
- 另请参阅
SQL ServerAzure SQL 数据库
Azure SQL 数据仓库
并行数据仓库SQL Server
Azure SQL Database
Azure SQL Data Warehouse
Parallel Data Warehouse
Always On availability groups is disabled, accounts are incorrectly configured, the database mirroring endpoint does not exist, the endpoint is inaccessible (SQL Server Error 1418), network access does not exist, and a join database command fails (SQL Server Error 35250).
备注
Prerequisites, Restrictions, and Recommendations for Always On Availability Groups (SQL Server).
In This Topic:
Section | Description |
---|---|
Always On Availability Groups Is Not Enabled | Always On availability groups, the instance does not support availability group creation and cannot host any availability replicas. |
Accounts | SQL Server is running. |
Endpoints | Discusses how to diagnose issues with the database mirroring endpoint of a server instance. |
System name | Summarizes the alternatives for specifying the system name of a server instance in an endpoint URL. |
Network access | Documents the requirement that each server instance that is hosting an availability replica must be able to access the port of each of the other server instances over TCP. |
Endpoint Access (SQL Server Error 1418) | SQL Server error message. |
Join Database Fails (SQL Server Error 35250) | Discusses the possible causes and resolution of a failure to join secondary databases to an availability group because the connection to the primary replica is not active. |
Read-Only Routing is Not Working Correctly | |
Related Tasks | SQL Server 2017 Books Online that are particularly relevant to troubleshooting an availability group configuration. |
Related Content | SQL Server Books Online. |
Always On Availability Groups Is Not Enabled
Enable and Disable Always On Availability Groups (SQL Server).
Accounts
SQL Server is running must be correctly configured.
-
Do the accounts have the correct permissions?
-
This simplifies the security configuration the database and is recommended.
-
Set Up Login Accounts for Database Mirroring or Always On Availability Groups (SQL Server).
-
-
Use Certificates for a Database Mirroring Endpoint (Transact-SQL).
Endpoints
Endpoints must be correctly configured.
-
Allow a Database Mirroring Endpoint to Use Certificates for Outbound Connections (Transact-SQL).
-
Check that the port numbers are correct.
Transact-SQL statement:
SELECT type_desc, port FROM sys.tcp_endpoints; GO
-
Always On availability groups setup issues that are difficult to explain, we recommend that you inspect each server instance to determine whether it is listening on the correct ports.
-
Transact-SQL statement:
SELECT state_desc FROM sys.database_mirroring_endpoints
sys.database_mirroring_endpoints (Transact-SQL).
Transact-SQL statement:
ALTER ENDPOINT Endpoint_Mirroring STATE = STARTED AS TCP (LISTENER_PORT = <port_number>) FOR database_mirroring (ROLE = ALL); GO
ALTER ENDPOINT (Transact-SQL).
-
Transact-SQL statement:
SELECT 'Metadata Check'; SELECT EP.name, SP.STATE, CONVERT(nvarchar(38), suser_name(SP.grantor_principal_id)) AS GRANTOR, SP.TYPE AS PERMISSION, CONVERT(nvarchar(46),suser_name(SP.grantee_principal_id)) AS GRANTEE FROM sys.server_permissions SP , sys.endpoints EP WHERE SP.major_id = EP.endpoint_id ORDER BY Permission,grantor, grantee; GO
System Name
Specify the Endpoint URL When Adding or Modifying an Availability Replica (SQL Server).
Network Access
This is especially important if the server instances are in different domains that do not trust each other (untrusted domains).
Endpoint Access (SQL Server Error 1418)
SQL Server message indicates that the server network address specified in the endpoint URL cannot be reached or does not exist, and it suggests that you verify the network address name and reissue the command.
Join Database Fails (SQL Server Error 35250)
This section discusses the possible causes and resolution of a failure to join secondary databases to the availability group because the connection to the primary replica is not active.
Resolution:
-
Check the firewall setting to see if whether allows the endpoint port communication between the server instances that host primary replica and the secondary replica (port 5022 by default).
-
Check whether the network service account has connect permission to the endpoint.
Read-Only Routing is Not Working Correctly
Verify the following configuration values settings and correct them if necessary.
On… | Action | Comments | Link | |
---|---|---|---|---|
Current primary replica | Ensure that the availability group listener is online. | To restart an offline listener:ALTER AVAILABILITY GROUP myAG RESTART LISTENER 'myAG_Listener'; |
ALTER AVAILABILITY GROUP (Transact-SQL) | |
Current primary replica | Ensure that the READ_ONLY_ROUTING_LIST contains only server instances that are hosting a readable secondary replica. | To change a read-only routing list: ALTER AVAILABILITY GROUP | ALTER AVAILABILITY GROUP (Transact-SQL) | |
Every replica in the read_only_routing_list | Ensure that the Windows firewall is not blocking the READ_ONLY_ROUTING_URL port. | — | Configure a Windows Firewall for Database Engine Access | |
Every replica in the read_only_routing_list | The IP addresses are configured correctly. | — | Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager) | |
Every replica in the read_only_routing_list | Ensure that the READ_ONLY_ROUTING_URL (TCP://system-address:port) contains the correct fully-qualified domain name (FQDN) and port number. | — | ALTER AVAILABILITY GROUP (Transact-SQL) | |
Client system | 确认客户端驱动程序支持只读路由。 |
---恢复内容结束---
---恢复内容结束---