如何替換Citrix XenDesktop中使用的vCenter server地址

一、問題描述:

客戶重裝Vcenter之後(Hostname與之前保持一致)出現如下報錯:

1.計算機目錄顯示無法聯繫到vCenter server

2.VM電源狀態未知

3.測試connection出現如下錯誤:

 Attempting to connect to the VCenter server failed due to a certificate error.

Check that the appropriate certificates are installed on the VCenter server and on the same machine as all instances of the Host service.

4. 無法在現有計算機目錄中添加刪除虛擬機

二、解決目標:

1.    無需新建Connection,修復現有的連接

2.    所有VM電源處於可管理狀態

3.    現有的計算機目錄(包括MCS)可以正常添加機器

 

三、Workaround:

 根據新的vcenter地址新建新的連接並將現有站點中的機器刪除後已現有的方式通過新的vcenter地址添加到現有站點中進行管理,具體方法可以參考Citrix官方文檔:

Xenserver:

http://support.citrix.com/article/CTX139041

Vmware:

https://support.citrix.com/article/CTX216898


四、根本解決方案

***Note:此方案非citrix官方支持,謹慎使用!

 

問題一:修復現有的連接,修復現有虛擬機電源狀態

 

1. 在每一臺DDC的證書中心中刪除原來的vcenter證書

通過MMC加載證書並瀏覽到路徑:證書>受信任的根證書頒發機構>受信任的人

2.在每一臺DDC中安裝新的vCenter證書(包括根證書)安裝方法有兩種:

方式一:

a.    將vCenter Server證書拷貝到所有DDC中

證書路徑:

vCenter server for Windows:

C:\ProgramData\VMware\vCenterServer\cfg\vmware-vpx\ssl\rui.crt

VCSA:

/etc/vmware-vpx/ssl/rui.crt

b.    導入證書,MMC->Add/Remove Snap-in->Certificates->Add->Computer account->Local computer->Trusted People->Certificates->Import above Certificates

image.png

image.png

方式二:

瀏覽器訪問vCenter Server, 訪問地址如https://server1.domain1.com.

vCenter證書顯示於該路徑中:Accept the security warnings->Click on the address bar

點擊“Install certificate”,選擇“Local Machine”,並點擊繼續

在證書中心中點擊“Place all certificates”,並點擊“瀏覽”

1)    如果你使用的是Windows Server 2008 R2:

a.    選擇Show physical stores checkbox

b.    展開 Trusted People

c.     選擇Local Computer

d.    點擊Next,然後點擊Finish

 

2)    如果你使用的是 Windows Server 2012 或者 Windows Server 2012 R2,則:

a.    選擇Trusted People,  然後點擊 OK.

b.    點擊Next, 直接點擊Finish即可

 

**Note: 證書導入後請務必驗證https訪問不再報證書錯誤,如果還有錯考慮將站點加入到本地信任站點列表。


3.更新在Citrix Virtual Desktop數據庫中更新新證書的指紋,

   a.    通過查看證書詳細信息並下拉到指紋(Thumbprint)選項查看指紋(請將指紋信息拷貝到TXT中去除空格並將字母替換成大寫後備用):

image.png

    b.    Citrix Virtual Desktop數據庫中替換新證書指紋

方法一:直接更新數據庫表格

Update [XDSiteDB].[HostingUnitServiceSchema].[HypervisorConnectionSSLThumbprint]

Set SSLThumbprint = '59548212930111B0E279FDC729D7AF4FDE65C25F'

Where Id = 2

image.png

**Note: Hypervisor ConnectionUid可以在DDC上運行Powershell Get-BrokerHypervisorConnection來查看相關信息


      方法二:通過DDC Powershell更新

a)    $cred = Get-Credential 

b)     Set-Item -LiteralPath "<FullPath_to_connection>" -username $cred.username -Securepassword $cred.password -SslThumbprint "<New ThumbPrint>" -hypervisorAddress <vcenter URL>

image.png

 **Note:證書指紋須大寫!


4. 在Citrix Studio中,編輯現有的hosting connection並更新connection address(如果地址更改的話)


上述四個步驟做完之後,虛擬機電源狀態恢復,同時現有連接也被修復。


問題二:無法向現有計算機目錄中添加機器

我們在完成以上步驟後雖然能夠解決現有環境中的連接問題,但是用戶無法在新的計算機目錄中添加新的計算機。導致問題的根本原因是因爲替換vcenter之後,vcenter管理的network /storage/resouregoup id信息都將改變,而原有的計算機目錄仍然關聯舊的vcenter下面的id.

解決思路是將XD數據庫中相關聯的網絡/存儲/資源組 ID均替換成現有正確的ID.


如何查看當前新的vcenter下的網絡/存儲/資源組 ID?兩種方法:

1. 根據原來的託管主機新建託管主機並使用相同的存儲和網絡,這樣在DB中可以查看到對應的ID

2. 通過vcenter server mob來查看(推薦方式)

瀏覽器訪問vcenter server地址並選擇瀏覽管理對象

image.png

路徑爲:Browse objects managed by vShpere->Content->rootFolder(Datacenters)->ChileEntity(Real Datacenter Name,此目錄下正常可以看到storage ID和network ID)->HostFolder->ChildEntity(此時可以看到cluster名稱或者主機)->點擊進入,頁面爲ManagedObjectReference:ComputeResource(此頁面中能看到看到storage ID和network ID,下拉找到resourcePool可以查詢到對應的ID)

image.png


  1. 網絡ID:

用戶在添加計算機的時候會提示以下錯誤:

Terminating Error:

An unknown error occurred while creating the virtual machines.

Stack Trace:

   at Citrix.Console.PowerShellSdk.ProvisioningSchemeService.BackgroundTasks.ProvisioningSchemeTask.CheckForTerminatingError(SdkProvisioningSchemeAction sdkProvisioningSchemeAction)

   at Citrix.Console.PowerShellSdk.ProvisioningSchemeService.BackgroundTasks.ProvisioningSchemeTask.WaitForProvisioningSchemeActionCompletion(Guid taskId, Action`1 actionResultsObtained)

   at Citrix.Console.PowerShellSdk.ProvisioningSchemeService.BackgroundTasks.MachineProvisioningTask.RunTask()

   at Citrix.Console.PowerShellSdk.BackgroundTaskService.BackgroundTask.Task.Run()

 

DesktopStudio_ErrorId : ProvisioningTaskError

ErrorCategory : NotSpecified

ErrorID : NetworkNotPermitted

TaskErrorInformation : A NIC device is tied to a disallowed network.

InternalErrorMessage : A NIC device is tied to a disallowed network.

 

Machine Failures:

: Failed to create the virtual machine; .

Inner Error:

A NIC device is tied to a disallowed network.

 

ErrorID : System.InvalidOperationException

TaskErrorInformation : System.InvalidOperationException: A NIC device is tied to a disallowed network.

   at Citrix.MachineCreation.NewProvVMSupport.NewProvVMLogic.DoValidation(NewVirtualMachineWorkflow context)

網絡的更改會涉及到數據中的三張表,如下:

[HostingUnitServiceSchema].[HostingUnit]
[HostingUnitServiceSchema].[HostingUnitNetwork]
[DesktopUpdateManagerSchema].[ProvisioningSchemeNetworkMap]


[HostingUnitServiceSchema].[HostingUnit] 主要定義了當前託管主機中對應的RootID/RootPath/NetworkPath/NetworkID等,如果只是替換vcenter(datacenter, cluster沒有變化)則只需要更改networkID即可,如果更換以上路徑則還需要替換出現問題的Hostingunits對應的RootID和Rootpath等。

Update [CitrixXDSiteDB].[HostingUnitServiceSchema].[HostingUnit]

Set RootPath = 'xxxxx', RootID = 'new rootid', NetworkID = 'NewNetworkID'

Where hostingUnitName = 'vcenter'


[HostingUnitServiceSchema].[HostingUnitNetwork]  定義了託管主機中每個網絡對應的名稱和id(有可能用戶的託管中配置了多個網絡,但是每個計算機目錄只會選擇一個網絡)

語句:

Update [HostingUnitServiceSchema].[HostingUnitNetwork]

Set NetworkID= 'Newnetwork id'

where networkpath='networkpath'

  image.png


[DesktopUpdateManagerSchema].[ProvisioningSchemeNetworkMap] 定義了每個計算機目錄對應的scheme中使用的網絡路徑和ID.

語句:

Update [DesktopUpdateManagerSchema].[ProvisioningSchemeNetworkMap] 

Set NetworkId = 'New networkID'

Where ProvsioningSchemeUid='xxxxx-xxxxxx-xxxxxxxxxxxxxx'

image.png

**Note: 如何查看計算機目錄對應的ProvsionningScheme

DDC上運行Powershell: Get-BrokerCatalog


2. Storage ID

用戶在修改爲以上三張表關聯的網絡ID之後再次添加機器仍然提示報錯:

image.png

從以上報錯我們可以明顯看到創建機器過程中找不到對應的存儲,這裏的存儲“datastore-1164"在新的vCenter管理下此存儲的id已經變更爲新的id,我們需要在數據庫中進行替換。

[HostingUnitServiceSchema].[HostingUnitStorageLocation]  此表中記錄了託管存儲中每個存儲對應的路徑和storage ID

語句:

Update [CitrixXDSiteDB].[HostingUnitServiceSchema].[HostingUnitStorageLocation]

set StorageId = 'datastore-15'

Where StorageId = 'datastore-1164'


3. ResouceGroup ID

用戶在更新完storage ID後再次重新添加新虛擬機:

Machine Failures:

Domain\RDVDI21$: Could not locate the master disk image; /VDI-ITUser-Template.vm/ITUserVDA.snapshot/set IE  proxy.snapshot to create the virtual machine; Domain\RDVDI21$

Inner Error:

Attempt to lookup property [parent] failed as the object [resgroup-1162] does not exist

 ErrorID : PluginUtilities.Exceptions.ItemNotFoundException

TaskErrorInformation : PluginUtilities.Exceptions.ItemNotFoundException: Attempt to lookup property [parent] failed as the object [resgroup-1162] does not exist ---> PluginUtilities.Exceptions.ItemNotFoundException: Attempt to lookup property [parent] failed as the object [resgroup-1162] does not exist ---> PluginUtilities.Exceptions.WrappedPluginException: 對象已刪除或未完全創建

 

以上報錯我們可以看到對用的resouregroup-1162已經改變,我們需要更新數據庫中對應的值

[DesktopUpdateManagerSchema].[ProvisioningSchemeVMImageLocation] 此表中記錄了計算機目錄再每個存儲中的Basedisk的信息,如果ResourceGroup信息改變則需要在這裏更改

語句:

Update [DBName][DesktopUpdateManagerSchema].[ProvisioningSchemeVMImageLocation]

Set DiskId= replace (DiskId,'resgroup-35002_old','resgroup-3xxxx_new')

Where ProvsioningSchemeID = XXX

 

還需要更改此表中的StorageID

  Update [DBName].[DesktopUpdateManagerSchema].[ProvisioningSchemeVMImageLocation]

  Set StorageId = 'datastore-15'

  Where StorageId = 'datastore-1164'




再次回到DDC針對有問題的計算機目錄添加計算機,此時可以重新添加!


**Note: 所有針對數據庫的操作請務必先進行數據庫的備份操作

 











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