SQL Server AlwaysOn中445端口使用的調查報告node
第一部分:來自微軟官方的文檔說明linux
Microsoft Knowledge Base article 832017: Service overview and network port requirements for Windowssql
針對咱們生產環境SQL Server 2014 AlwaysOn FCI & AG混合部署,基於Active Directory和Cluster Service。數據庫
下面信息引用自KB 832017,描述了基於這兩個服務的相關端口要求:windows
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.sass
依賴端口列表:安全
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 ports¹ |
TCP |
1024 - 5000 |
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 ports¹ |
UDP |
Random port number between 1024 and 65535 |
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)
在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)
分佈式可用性組,可將AlwaysOn AG跨兩個不一樣的WSFC,來擴展AG。該特性一樣沒法消除445端口訪問。
3. Read-scale availability groups(a new feature introduced in SQL Server 2017)
在 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. 將數據庫服務器放入核心隔離區域
根據以往經驗,電商公司爲了經過PCI國際權威認證,在搭建PCI環境時,會將生產支付和帳號數據庫放入該環境,實際上是一個核心隔離區域,限制訪問該區域數據庫服務器的IP和端口。
我建議:
1. 打上SMB漏洞的安全補丁。
2. 將數據庫服務器訪問核心隔離區域。