SQL Server 2016 AlwaysOn搭建

AlwaysOn可用性组信息

 

角色

节点

节点类型

同步方式

支持故障转移类型

Availability Group

 

Primay Replica

SQLC01

 

SQL Cluster

Synchronous-commit

Automatic failover

 

Secondary Replica

A06

Instance

Synchronous -commit

Automatic failover

 

Secondary Replica

A08

Instance

Asynchronous -commit

Forced failover

 

示意图如下,可用性组FrontDBServer由三个节点组成,A06为主副本,A08和SQLC01为从副本,A08为同步提交数据,自动故障转移,可供查询,SQLC01为异步提交数据,手工强制故障转移,只有只读直连时可供查询;[ 客户端通过公共网络进行访问,节点之间通过私有网络进行通信。


1 配置所本支持AlwaysOn

Sql Server Configuration Manager,点SQL Server属性,开AlwaysOn可用性组,重SQL Server Service

注意:AlwaysOn是基于Windows故障转移群集的,所以所有节点必须入同一Windows故障转移群集

 

如果不是群集节点则提示:

This computer is not a node in a failover cluster.

打算用SQL故障转移集群做主本的,可是群集做主副本不支持自动故障转移,只好做罢,改做个只读备份

 

2 用向导创建一AlwaysOn用性组

2.1 打SQL Server Management Studio,连接任一副本,选择菜单AlwaysOn High Availability->Availability Group键选择菜单New Availability Group Wizard…

 

 


2.2 下一步,命名组,勾Database Level Health DetectionDatabase Level Health Detection是开启数据库级别的健康检查,是推荐配置,更多参考https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/sql-server-always-on-database-health-detection-failover-option

 

 

2.3 勾包含的数据库,这些库将成一个可用性组,若出现异常则为一个整体进行故障转移

求数库恢复模式为完全,且已做过完整备份

 

 

无备份则提示

 

若非恢复模式

 


2.4 设置属性

2.4.1 设置转移方式,提交方式及副本的可

Readable Secondary有三种取值,如:No

No

Direct connections are allowed to secondary databases of this replica. They are not available for read access. This is the default setting.

Read-intent only

Only direct read-only connections are allowed to secondary databases of this replica. The secondary database(s) are all available for read access.

Yes

All connections are allowed to secondary databases of this replica, but only for read access. The secondary database(s) are all available for read access.

 

 

2.4.2 设置副本通讯信息

A06A08设置私有网卡的IP,SQLC01是集群,看来只能用实例名,好在只是个只读备份

注意最后一列SQL Server Service Account,要使用域账号,且对数据库有读写权限.

 

2.4.3 设置监听器

设置监听器DNS名和虚拟IP,用于连接可用组.这个是给客户端使用的,所以用公共网卡IP

 

 

使用本地账号则会提示:

 

2.5 副本上数据库的初始化方式

 

 

2.6 下一步 运行验证

 

 

2.7 下一步

 

2.8 下一步,创建成功

 

创建成功后,可用管理器直接连监听器名FrontDBServer,查看副本状态,如有错误,可通过SQL Server错误日志定位问题,如下是有一个SQL Server实例是用本地账户运行导致的.

 

C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Log

ErrorLog

 

2017-07-14 13:32:43.82 Logon       Database Mirroring login attempt by user 'WSW\WIN2012R2A06$.' failed with error: 'Connection handshake failed. The login 'WSW\WIN2012R2A06$' does not have CONNECT permission on the endpoint. State 84.'.  [SERVER: 192.168.187.155]

 

 

连接只读副本时需要指定ApplicationIntent=ReadOnly,下图是SQL Server Managerment Studio连接时的设置,.Net代码连接串也要加这个

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章