1. 程式人生 > >SQL Server AlwaysOn中445端口使用的調查報告

SQL Server AlwaysOn中445端口使用的調查報告

數據庫 SQL Server

SQL Server AlwaysOn中445端口使用的調查報告


第一部分:來自微軟官方的文檔說明


Microsoft Knowledge Base article 832017: Service overview and network port requirements for Windows


針對我們生產環境SQL Server 2014 AlwaysOn FCI & AG混合部署,基於Active Directory和Cluster Service。


下面信息引用自KB 832017,描述了基於這兩個服務的相關端口要求:


1. Active Directory (Local Security Authority)

Active Directory runs under the Lsass.exe process and includes the authentication and replication engines for Windows domain controllers. Domain controllers, client computers and application servers require network connectivity to Active Directory over specific hard-coded ports. Additionally, unless a tunneling protocol is used to encapsulate traffic to Active Directory, a range of ephemeral TCP ports between 1024 to 5000 and 49152 to 65535 are required.


依賴端口列表:

Application protocol

Protocol

Ports

Active Directory Web Services (ADWS)

TCP

9389

Active Directory Management Gateway Service

TCP

9389

Global Catalog

TCP

3269

Global Catalog

TCP

3268

ICMP


No port number

LDAP Server

TCP

389

LDAP Server

UDP

389

LDAP SSL

TCP

636

IPsec ISAKMP

UDP

500

NAT-T

UDP

4500

RPC

TCP

135

RPC randomly allocated high TCP ports1

TCP

1024 - 5000
49152 - 655352

SMB

TCP

445


2. Cluster Service

The Cluster service controls server cluster operations and manages the cluster database. A cluster is a collection of independent computers that act as a single computer. Managers, programmers, and users see the cluster as a single system. The software distributes data among the nodes of the cluster. If a node fails, other nodes provide the services and data that were formerly provided by the missing node. When a node is added or repaired, the cluster software migrates some data to that node.


System service name: ClusSvc

Application

Protocol

Ports

Cluster Service

UDP

3343

Cluster Service

TCP

3343 (This port is required during a node join operation.)

RPC

TCP

135

Cluster Administrator

UDP

137

Randomly allocated high UDP ports1

UDP

Random port number between 1024 and 65535
Random port number between 49152 and 655352

Note:

Additionally, for successful validation on Windows Failover Clusters on 2008 and above, allow inbound and outbound traffic for ICMP4, ICMP6, and port 445/TCP for SMB.


第二部分:來自微軟Data Platform MVP Mail List的回復


技術分享圖片


第三部分:關於AD和WSFC原理的深入學習


1. AD對445的依賴

各個客戶端開機時,需要訪問AD裏面DC上的一個sysvol共享,下載組策略。每次開機都要訪問,通過這個共享下發組策略。


SYSVOL:

SYSVOL是指存儲域公共文件服務器副本的共享文件夾,它們在域中所有的域控制器之間復制。 Sysvol文件夾是安裝AD時創建的,它用來存放GPO、Script等信息。同時,存放在Sysvol文件夾中的信息,會復制到域中所有DC上。


Netlogon:

Netlogon(網絡登錄)服務為域控制器註冊所有的srv資源紀錄。這些記錄出現在DNS服務器的正向查詢區域你的域名中的_msdcs, _sites, _tcp, and _udp等文件夾中。其他計算機利用這些記錄查詢域活動目錄相關的信息。


2. WSFC對445的依賴

群集數據庫是WSFC的運作的主要概念之一,群集數據庫裏面會記載著群集應用當前的狀態,例如當前節點1運行了一個DHCP角色,狀態是上線,運行了一個文件服務器角色,狀態是離線,以及群集配置,群集成員配置,群集資源的添加,創建,啟動,刪除,停止,下線等狀態變化,群集數據庫就是為了幫助各個節點知道對方上面運行了什麽樣的群集服務,一旦對方宕機之後,將按照群集數據庫裏面的進行的狀態信息連接上共享存儲進行故障轉移上線操作。


WSFC會通過管理共享在復制集群數據庫用到。群集數據庫在各節點C盤和註冊表,當一個節點修改群集信息,會復制到其他節點和見證磁盤。


技術分享圖片

技術分享圖片

一個節點宕機,其他節點參照群集數據庫,訪問共享磁盤,聯機上線該節點承載的應用。日常運行時在各節點同步,確保各節點記錄一致。


第四部分:關於Windows Server 2016和SQL Server 2016/2017相關新功能的學習


1. Domain Independent Availability Groups(a new feature introduced in SQL Server 2016)

https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/domain-independent-availability-groups


在Windows Server 2016 + SQL Server 2016環境下,AlwaysOn AG支持在工作組環境、或跨域環境搭建AG。即便搭建無域AG,AG還是需要WSFC的支持,而WSFC需要開通445端口;FCI到目前為止,仍然需要在域環境下部署。該特性無法消除445端口訪問。


2. Distributed availability groups(a new feature introduced in SQL Server 2016)

https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/distributed-availability-groups


分布式可用性組,可將AlwaysOn AG跨兩個不同的WSFC,來擴展AG。該特性同樣無法消除445端口訪問。


3. Read-scale availability groups(a new feature introduced in SQL Server 2017)

https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/read-scale-availability-groups


在 SQL Server 2016 及更早版本中,所有可用性組都需要群集。 群集用於提供業務連續性,實現高可用性和災難恢復 (HADR)。 此外,配置次要副本以執行讀取操作。 如果目標不是高可用性,配置和運行群集消耗了相當大的運營開銷。 SQL Server 2017 引入了不需要群集的讀取縮放可用性組。


如果業務要求是轉換主要副本上運行的任務關鍵型工作負荷的資源,用戶現在可以使用只讀路由或直接連接到可讀次要副本。 而無需依賴於與任何群集技術的集成。 Windows 和 Linux 平臺上的 SQL Server 2017 支持這些新功能。


這不是高可用性配置。 不需要監視基礎結構、協調故障檢測和進行自動故障轉移。 如果沒有群集,SQL Server 無法提供自動化高可用性解決方案可提供的低恢復時間目標 (RTO)。 如果需要高可用性功能,請使用群集管理器(Windows 上的 Windows Server 故障轉移群集或 Linux 上的 Pacemaker)。


讀取縮放可用性組可提供災難恢復功能。 當只讀副本處於同步提交模式時,可提供恢復點目標 (RPO) 0。 要對讀取縮放可用性組進行故障轉移,請參閱對讀取縮放可用性組上的主要副本進行故障轉移。


總體來說,該特性只有DR功能,不支持HA。該特性適用於只是為了在多個服務器上部署多個只讀副本,分擔讀取壓力。


4. SQL Server 2017 Availability Groups on linux

https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-availability-group-overview


在Linux上配置AG基於Pacemaker。


5. SQL Server 2017 Failover Cluster Instance on linux

https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-shared-disk-cluster-concepts


在Linux上配置FCI官方文檔還很簡陋,從共享存儲來看,目前支持iSCSI、NFS和SMB協議。期待後續支持光纖協議,並與AG混合部署。


第五部分:關於防範蠕蟲病毒的解決方案和建議


分析了下,有如下3個解決方案:

1. 升級相應安全補丁

對於重要的安全補丁建議打上,從Secondary到Primary在維護窗口滾動升級。


2. 修改數據庫服務器共享端口

根據以往經驗,可以修改客戶端和服務器端的445端口,共享能正常運行。但該方案不能阻止對共享的訪問。


3. 將數據庫服務器放入DMZ區域

根據以往經驗,電商公司為了通過PCI國際權威認證,在搭建PCI環境時,會將生產支付和賬號數據庫放入該環境,其實是一個DMZ區域,限制訪問該區域數據庫服務器的IP和端口。


我建議:

1. 打上SMB漏洞的安全補丁。

2. 將數據庫服務器訪問DMZ區域。


SQL Server AlwaysOn中445端口使用的調查報告