本文主要是從:http://support.microsoft.com/kb/970759/zh-cn,直接轉載,稍作修改裁剪而來,其中紅色粗體部分,是我特別要說明的
若要配置 IIS 7.0 和 7.5 Web 服務器使用故障轉移群集的高可用性,請按照下列步驟。下面更詳細地介紹步驟 3 到步驟 7。本文內下文中的示例腳本可以用作任務的示例 IIS 7.0、 IIS 7.5 和 IIS 8.0。 其實應該還有DNS,AD,iscsi target 服務配置
- 在所有群集節點上安裝 Web 服務器角色。有關詳細信息,請訪問下面的 Microsoft 網站:
http://technet.microsoft.com/en-us/library/cc771752.aspx() http://technet.microsoft.com/en-us/library/cc771752.aspx
- 在所有群集節點上安裝的故障轉移群集功能,並創建群集。有關詳細信息,請訪問下面的 Microsoft 網站:
http://technet.microsoft.com/en-us/library/dd197477.aspx() http://technet.microsoft.com/en-us/library/dd197477.aspx
- 設置將用於 IIS 共享配置文件共享。
- 在所有群集節點上配置 IIS 共享的配置。
- 在所有群集節點上配置 IIS 脫機配置文件的共享。 這一步可以不做,我就沒做
- 配置 Web 站點 (包括關聯的應用程序池),並且一個群集節點上指定其內容的位置。
- 通過創建一個通用腳本,在故障轉移群集中配置您的 Web 站點的高可用性。
設置將用於 IIS 共享配置文件共享
- 創建一個將訪問 IIS 共享的配置將使用該共享的用戶。
- 創建文件共享。此共享將用於存儲 IIS 共享的配置將所有群集節點上的 IIS 之間共享。有多個選項(選擇其中之一即可):
- 在獨立服務器上,不是任何故障轉移群集的一部分,創建一個文件共享。
- 在另一台 Windows 服務器故障轉移群集中,創建一個高可用性的文件共享。有關詳細信息,請訪問下面的 Microsoft 網站:
http://technet.microsoft.com/en-us/library/cc731844.aspx() http://technet.microsoft.com/en-us/library/cc731844.aspx
- 在承載高可用性 Web 站點相同的故障轉移群集,創建高可用性的文件共享。有關詳細信息,請訪問下面的 Microsoft 網站:
- 在您在步驟 2 中創建的共享上設置的權限。為您在步驟 1 的文件共享的完全控制權限和 NTFS 權限的用戶。
- 請確認所有群集節點都都可以瀏覽到該文件共享。文件共享的路徑 \\ < 文件服務器 > \ < 共享 >。
在所有群集節點上配置 IIS 共享的配置
注意:沒有與 IIS 共享服務器上配置 Windows 2008 因為缺少權限應用程序主機幫助器服務的問題。為共享配置工作,您必須執行以下步驟,Windows 2008 服務器上的 IIS 共享配置設置時。
- 打開管理的命令提示符。
- 運行以下命令:
net stop apphostsvc
- 運行以下命令:
sc privs apphostsvc SeImpersonatePrivilege/SeChangeNotifyPrivilege/SeTcbPrivilege 這一行命令,原始的中文文檔有問題,我改過
- 運行以下命令:
net start apphostsvc 這一行命令,原始的中文文檔有問題,我改過
完成這些步驟在群集中的每個 Windows 2008 服務器后,請在本節中繼續設置 IIS 共享的配置,如所述。
在其中一個群集節點上的文件共享導出共享的配置:
- 導航到管理工具,然后單擊Internet Information Services (IIS) 管理器。
- 在左窗格中,單擊服務器名稱節點。
- 雙擊共享配置圖標。
- 在共享配置頁中,單擊導出配置導出配置文件操作窗格 (右窗格) 中從本地計算機到另一個位置。
- 在將配置導出對話框中,鍵入文件共享的路徑 (\\ < 文件服務器 > \ < 共享 >) 中的物理路徑框。
- 單擊連接,然后鍵入用戶名和密碼的用戶帳戶具有訪問該共享的共享的配置存儲,然后單擊確定。此帳戶將用於訪問共享資源。您應使用受限的 Active Directory 帳戶不是域管理員。
- 在將配置導出對話框中,鍵入一個密碼,用以保護加密密鑰,然后單擊確定。
- 在共享配置頁中,單擊以選中啟用共享的配置復選框。
- 鍵入物理路徑、 用戶帳戶,以及以前,您輸入的密碼,然后單擊操作窗格中的應用。
- 在加密密鑰密碼對話框中,鍵入加密密鑰密碼的更早版本,將設置,然后單擊確定。
- 在共享配置對話框中,單擊確定。
- 單擊確定。
在每個其他群集節點,請使用您剛導出的文件共享的共享的配置:
假如你這個共享存儲是同一個故障轉移集群中做的,必須要將相關的資源,切換到這台機器上,才能做
- 導航到管理工具,然后單擊Internet Information Services (IIS) 管理器。
- 單擊服務器名稱節點。
- 雙擊共享配置圖標。
- 在共享配置頁中,單擊以選中啟用共享的配置復選框。
- 鍵入該文件共享的物理路徑 (\\ < 文件服務器 > \ < 共享 >),該用戶帳戶,並且密碼之前,輸入然后在操作窗格中單擊應用。
- 在加密密鑰密碼對話框中,鍵入加密密鑰密碼的更早版本,將設置,然后單擊確定。
- 在共享配置對話框中,單擊確定。
- 單擊確定。
注意:有關如何設置共享配置 IIS 中的詳細信息,請訪問下面的 Microsoft 網站:
在所有群集節點上配置 IIS 脫機文件共享配置(似乎這一步不做也是可以的,我就沒做)
在每個群集節點上,啟用脫機文件:
- 安裝桌面體驗
- 導航到管理工具,然后單擊服務器管理器。
- 在左窗格中,單擊功能。
- 在右窗格中,單擊添加功能。
- 單擊以選中桌面體驗復選框。
- 單擊安裝以安裝桌面體驗。
- 重新啟動計算機。
- 在控制面板中,打開脫機文件。
- 單擊啟用脫機文件。不要不重新啟動計算機,請稍后。
- 確保將高速緩存設置為只讀。若要執行此操作,可提升的cmd窗口中運行以下命令:
REG ADD "HKLM\System\CurrentControlSet\Services\CSC\Parameters" /v ReadOnlyCache /t REG_DWORD /d 1 /f
- 重新啟動計算機。
- 從該計算機瀏覽到文件服務器。用鼠標右鍵單擊包含 IIS 共享的配置中,該共享,然后單擊始終脫機可用。
注意如果要將相同的故障轉移群集上具有高可用性的文件共享設置時,它承載 IIS 節點,始終脫機可用選項時不會出現您,請右鍵單擊該共享上承載高可用文件服務器所使用的群集節點。 您需要移動到另一個節點的高可用文件服務器應用程序。
- 在控制面板中,打開脫機文件。單擊打開同步中心,然后單擊日程安排。
- 對每一天或根據要求安排在脫機文件同步。您還可以配置脫機同步運行每隔幾分鍾。.即使您未設置上一個計划程序,Applicationhost.config 文件中的某些內容更改時,更改將會反映在 Web 服務器上。
注意:有關如何在 IIS 中配置共享配置為脫機文件的詳細信息,請訪問下面的 Microsoft 網站:
配置 Web 站點 (包括關聯的應用程序池),並且一個群集節點上指定其內容的位置
查找擁有群集磁盤資源的群集節點的 Web 站點的內容文件所在的位置:
- 導航到管理工具,然后單擊故障轉移群集管理器。
- 連接到群集。如果您是在一個群集節點上,群集將自動顯示在列表中。
- 在存儲下查找網頁內容將駐留在其的磁盤資源。若要執行此操作,展開存儲樹中的磁盤資源。請確保存儲未由任何其他高可用性應用程序在群集上。您會發現在可用存儲下的存儲。
- 注意群集節點的該資源處於聯機狀態。您將在該群集節點上配置 IIS。
- 注意群集磁盤資源名稱。您將使用此內容的文件。
在群集節點上的資源處於聯機狀態,Web 服務器配置為使用 Web 站點的內容的共享的磁盤:
- 導航到管理工具,然后單擊Internet Information Services (IIS) 管理器。
- 在左窗格中,展開服務器節點。
- 展開網站,然后單擊站點下的正在配置的站點。
- 在右窗格中,選擇管理 Web 站點下的高級設置。
- 找到的物理路徑屬性在常規設置,然后鍵入在 Web 站點的內容文件的位置的位置。這是您在前一過程的第 5 步中記下的群集磁盤資源的位置。♢其實這個群集磁盤資源,有安全方面的要求,域賬號有讀寫權限,包括以后新建的虛擬應用程序,使用新的群集磁盤資源,也要設置域賬號有讀寫權限。♢ 對於ASP.NET 應用程序,還要設置該域賬號對C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files 有讀寫的權限 ♢ 應用程序的物理路徑憑據,也要設置為該域賬號
- 單擊確定。
創建故障轉移群集管理器中的一個通用腳本來配置您的 Web 站點的高可用性
若要配置高可用性的 IIS Web 服務器中的最后一步,設置可用於監視的 Web 站點和網站應用程序池通用腳本資源:
- 在每個群集節點上,Windows\System32\inetsrv\Clusweb7.vbs 將這篇文章的末尾此腳本。 注意這個腳本不能保存帶有編碼格式的
- 默認情況下,腳本監視網站名為"默認 Web 站點"和名為"默認應用程序池"應用程序池。如果這不是正確的 Web 站點和應用程序池,更改網站名稱和APP_POOL_NAME變量。請確保所有群集節點上存在相同的 Web 站點和應用程序池腳本中。請注意名稱區分大小寫。
- 導航到管理工具,然后單擊故障轉移群集管理器。
- 連接到群集。如果您是在一個群集節點上,群集將自動顯示在列表中。
- 用鼠標右鍵單擊該群集,然后單擊配置服務或應用程序。向導將創建高可用性的工作負荷。
- 單擊通用腳本。
- 從以下路徑中選擇腳本文件: %systemroot%\System32\Inetsrv\clusweb7.vbs
- 客戶端將用於連接到高可用性的 Web 站點的 Web 站點名稱設置的客戶端訪問點 (CAP) 的名稱。指定靜態的 Ip 用於首字下沉的網站。如果您使用的 DHCP,則將不顯示此選項。
- 在選擇存儲步驟中,選擇 Web 站點內容文件駐留在其的群集共享的磁盤。存儲類型應為未使用任何其他高可用性應用程序在群集上。請注意是否用於 IIS 共享配置文件共享同一個群集上,此處應能使用不同的磁盤資源。
- 確認這些設置后,該向導將創建群集組,群集資源和資源之間的依賴關系,然后使資源聯機。
注意:若要承載相同的故障轉移群集上的多個高可用性的 Web 站點,請按照與上述相同的步驟。但是,為每個 Web 站點和其他群集的共享的存儲使用一個不同的腳本文件。例如,%systemroot%\system32\inetsrv 中使用的第一個網站的第三個,第二,clweb7 3.vbs clweb7-2.vbs clusweb7.vbs 等。每個腳本文件用於監測站點不同的站點和應用程序池。
重要:下面的腳本僅用於示例並不顯式支持通過 Microsoft。使用此腳本在群集環境中的 IIS 7.0,IIS 7.5 或 IIS 8.0 是需要您自擔風險。
'<begin script sample> 'This script provides high availability for IIS websites 'By default, it monitors the "Default Web Site" and "DefaultAppPool" 'To monitor another web site, change the SITE_NAME below 'To monitor another application pool, change the APP_POOL_NAME below 'More thorough and application-specific health monitoring logic can be added to the script if needed Option Explicit DIM SITE_NAME DIM APP_POOL_NAME Dim START_WEB_SITE Dim START_APP_POOL Dim SITES_SECTION_NAME Dim APPLICATION_POOLS_SECTION_NAME Dim CONFIG_APPHOST_ROOT Dim STOP_WEB_SITE 'Note: 'Replace this with the site and application pool you want to configure high availability for 'Make sure that the same web site and application pool in the script exist on all cluster nodes. Note that the names are case-sensitive. SITE_NAME = "Default Web Site" APP_POOL_NAME = "DefaultAppPool" START_WEB_SITE = 0 START_APP_POOL = 0 STOP_WEB_SITE = 1 SITES_SECTION_NAME = "system.applicationHost/sites" APPLICATION_POOLS_SECTION_NAME = "system.applicationHost/applicationPools" CONFIG_APPHOST_ROOT = "MACHINE/WEBROOT/APPHOST" 'Helper script functions 'Find the index of the website on this node Function FindSiteIndex(collection, siteName) Dim i FindSiteIndex = -1 For i = 0 To (CInt(collection.Count) - 1) If collection.Item(i).GetPropertyByName("name").Value = siteName Then FindSiteIndex = i Exit For End If Next End Function 'Find the index of the application pool on this node Function FindAppPoolIndex(collection, appPoolName) Dim i FindAppPoolIndex = -1 For i = 0 To (CInt(collection.Count) - 1) If collection.Item(i).GetPropertyByName("name").Value = appPoolName Then FindAppPoolIndex = i Exit For End If Next End Function 'Get the state of the website Function GetWebSiteState(adminManager, siteName) Dim sitesSection, sitesSectionCollection, siteSection, index, siteMethods, startMethod, executeMethod Set sitesSection = adminManager.GetAdminSection(SITES_SECTION_NAME, CONFIG_APPHOST_ROOT) Set sitesSectionCollection = sitesSection.Collection index = FindSiteIndex(sitesSectionCollection, siteName) If index = -1 Then GetWebSiteState = -1 End If Set siteSection = sitesSectionCollection(index) GetWebSiteState = siteSection.GetPropertyByName("state").Value End Function 'Get the state of the ApplicationPool Function GetAppPoolState(adminManager, appPool) Dim configSection, index, appPoolState set configSection = adminManager.GetAdminSection(APPLICATION_POOLS_SECTION_NAME, CONFIG_APPHOST_ROOT) index = FindAppPoolIndex(configSection.Collection, appPool) If index = -1 Then GetAppPoolState = -1 End If GetAppPoolState = configSection.Collection.Item(index).GetPropertyByName("state").Value End Function 'Start the w3svc service on this node Function StartW3SVC() Dim objWmiProvider Dim objService Dim strServiceState Dim response 'Check to see if the service is running set objWmiProvider = GetObject("winmgmts:/root/cimv2") set objService = objWmiProvider.get("win32_service='w3svc'") strServiceState = objService.state If ucase(strServiceState) = "RUNNING" Then StartW3SVC = True Else 'If the service is not running, try to start it response = objService.StartService() 'response = 0 or 10 indicates that the request to start was accepted If ( response <> 0 ) and ( response <> 10 ) Then StartW3SVC = False Else StartW3SVC = True End If End If End Function 'Start the application pool for the website Function StartAppPool() Dim ahwriter, appPoolsSection, appPoolsCollection, index, appPool, appPoolMethods, startMethod, callStartMethod Set ahwriter = CreateObject("Microsoft.ApplicationHost.WritableAdminManager") Set appPoolsSection = ahwriter.GetAdminSection(APPLICATION_POOLS_SECTION_NAME, CONFIG_APPHOST_ROOT) Set appPoolsCollection = appPoolsSection.Collection index = FindAppPoolIndex(appPoolsCollection, APP_POOL_NAME) Set appPool = appPoolsCollection.Item(index) 'See if it is already started If appPool.GetPropertyByName("state").Value = 1 Then StartAppPool = True Exit Function End If 'Try To start the application pool Set appPoolMethods = appPool.Methods Set startMethod = appPoolMethods.Item(START_APP_POOL) Set callStartMethod = startMethod.CreateInstance() callStartMethod.Execute() 'If started return true, otherwise return false If appPool.GetPropertyByName("state").Value = 1 Then StartAppPool = True Else StartAppPool = False End If End Function 'Start the website Function StartWebSite() Dim ahwriter, sitesSection, sitesSectionCollection, siteSection, index, siteMethods, startMethod, executeMethod Set ahwriter = CreateObject("Microsoft.ApplicationHost.WritableAdminManager") Set sitesSection = ahwriter.GetAdminSection(SITES_SECTION_NAME, CONFIG_APPHOST_ROOT) Set sitesSectionCollection = sitesSection.Collection index = FindSiteIndex(sitesSectionCollection, SITE_NAME) Set siteSection = sitesSectionCollection(index) if siteSection.GetPropertyByName("state").Value = 1 Then 'Site is already started StartWebSite = True Exit Function End If 'Try to start site Set siteMethods = siteSection.Methods Set startMethod = siteMethods.Item(START_WEB_SITE) Set executeMethod = startMethod.CreateInstance() executeMethod.Execute() 'Check to see if the site started, if not return false If siteSection.GetPropertyByName("state").Value = 1 Then StartWebSite = True Else StartWebSite = False End If End Function 'Stop the website Function StopWebSite() Dim ahwriter, sitesSection, sitesSectionCollection, siteSection, index, siteMethods, startMethod, executeMethod, autoStartProperty Set ahwriter = CreateObject("Microsoft.ApplicationHost.WritableAdminManager") Set sitesSection = ahwriter.GetAdminSection(SITES_SECTION_NAME, CONFIG_APPHOST_ROOT) Set sitesSectionCollection = sitesSection.Collection index = FindSiteIndex(sitesSectionCollection, SITE_NAME) Set siteSection = sitesSectionCollection(index) 'Stop the site Set siteMethods = siteSection.Methods Set startMethod = siteMethods.Item(STOP_WEB_SITE) Set executeMethod = startMethod.CreateInstance() executeMethod.Execute() End Function 'Cluster resource entry points. More details here: 'http://msdn.microsoft.com/en-us/library/aa372846(VS.85).aspx 'Cluster resource Online entry point 'Make sure the website and the application pool are started Function Online( ) Dim bOnline 'Make sure w3svc is started bOnline = StartW3SVC() If bOnline <> True Then Resource.LogInformation "The resource failed to come online because w3svc could not be started." Online = False Exit Function End If 'Make sure the application pool is started bOnline = StartAppPool() If bOnline <> True Then Resource.LogInformation "The resource failed to come online because the application pool could not be started." Online = False Exit Function End If 'Make sure the website is started bOnline = StartWebSite() If bOnline <> True Then Resource.LogInformation "The resource failed to come online because the web site could not be started." Online = False Exit Function End If Online = true End Function 'Cluster resource offline entry point 'Stop the website Function Offline( ) StopWebSite() Offline = true End Function 'Cluster resource LooksAlive entry point 'Check for the health of the website and the application pool Function LooksAlive( ) Dim adminManager, appPoolState, configSection, i, appPoolName, appPool, index i = 0 Set adminManager = CreateObject("Microsoft.ApplicationHost.AdminManager") appPoolState = -1 'Get the state of the website if GetWebSiteState(adminManager, SITE_NAME) <> 1 Then Resource.LogInformation "The resource failed because the " & SITE_NAME & " web site is not started." LooksAlive = false Exit Function End If 'Get the state of the Application Pool if GetAppPoolState(adminManager, APP_POOL_NAME) <> 1 Then Resource.LogInformation "The resource failed because Application Pool " & APP_POOL_NAME & " is not started." LooksAlive = false Exit Function end if ' Web site and Application Pool state are valid return true LooksAlive = true End Function 'Cluster resource IsAlive entry point 'Do the same health checks as LooksAlive 'If a more thorough than what we do in LooksAlive is required, this should be performed here Function IsAlive() IsAlive = LooksAlive End Function 'Cluster resource Open entry point Function Open() Open = true End Function 'Cluster resource Close entry point Function Close() Close = true End Function 'Cluster resource Terminate entry point Function Terminate() Terminate = true End Function '<end script sample>