2015-04-23 18 views
1

最近我們對AppFabric配置數據庫進行了移動和重命名。移動和重命名AppFabric配置數據庫

重命名來自

DistirbutedCacheService.exe.config與新的數據庫和服務器名稱

<clusterConfig provider="System.Data.SqlClient" connectionString="Data Source=NEWSERVER;Initial Catalog=AppFabricPreOrdersConfiguration;Integrated Security=True" /> 

和服務改變了默認名稱「AppFabricConfigurationDatabase」到「AppFabricPreOrdersConfiguration」成功地啓動。

但是從「緩存管理powershell」的這一點不再啓動,因爲當use-cachecluster被調用時,它仍然嘗試連接到舊的服務器/數據庫。

測試連接失敗ConnectionString數據源= OLDSERVER;初始目錄 = AppFabricCacheConfigurationDatabase;

Use-CacheCluster:ErrorCode:SubStatus:無效的提供程序和讀取的連接字符串。

powershell從哪裏讀取這些值?顯然不是從服務的配置文件,但在那裏呢?

+0

嘗試使用程序'procmon'。 –

+0

它沒有出現。我開始認爲這是一個硬編碼的值 – Laurijssen

+0

您是否在每臺主機上重新啓動AppFabricCachingService? – SomeShinyObject

回答

1

你需要調用Remove-CacheAdmin,然後Add-CacheAdmin改變每個管理主機

This Microsoft Powershell script上的緩存管理連接 - (.EXE下載,下面的腳本轉載) - 集羣中的變化上的所有主機的連接字符串。

param ([string] $provider, [string] $newConnectionString) 

function Main { 

    if ((! $provider) -or (! $newConnectionString)) 
    { 
     Write-Host "Usage: ChangeConnString.ps1 <provider> <newConnectionString>" 
     exit(1) 
    } 

    Import-Module "DistributedCacheAdministration" 
    Import-Module "DistributedCacheConfiguration" 

    Use-CacheCluster 

    Write-Host "Stop the cache cluster if it is running" 
    $clusterRunnig=$true 
    &{ 
     Stop-CacheCluster -EA Stop 
    } 
    trap [DataCacheException] { 
     #'Error Category {0}, Error Type {1}, ID: {2}, Message: {3} {4}' -f $_.CategoryInfo.Category, $_.Exception.GetType().FullName, $_.FullyQualifiedErrorID, $_.Exception.Message, $_.Exception.ErrorCode; 
     #12008: ErrorCode<ERRCAdmin008>:SubStatus<ES0001>:No hosts running in cluster 
     if ($_.Exception.ErrorCode -eq 12008) 
     { 
      write-host "Cluster is not running" 
      $clusterRunnig=$false 
      continue 
     } 
    } 

    [Reflection.Assembly]::LoadWithPartialName('Microsoft.ApplicationServer.Caching.Management') | Out-Null 
    [Reflection.Assembly]::LoadWithPartialName('System.Management.Automation') | Out-Null 
    [Reflection.Assembly]::LoadWithPartialName('System.Management.Automation.Runspaces') | Out-Null 

    SetCacheConnectionString $provider $newConnectionString 

    Write-Host "Connection string is altered on all the cache hosts. Now changing the connection string for cache admin" 
    Remove-CacheAdmin 
    Add-CacheAdmin -Provider $provider -ConnectionString $newConnectionString 

    if ($clusterRunnig -eq $true) 
    { 
     Write-Host "Starting the cache cluster..." 
     Start-CacheCluster 
    } 
} 

function SetCacheConnectionString { 

    param ([string] $provider, [string] $newConnectionString) 

    Write-Host "Parameters: " $provider " " $newConnectionString 
    $powerShell = [System.Management.Automation.PowerShell]::Create() 
    # Import the admin cmdlets module 
    $powerShell.AddCommand("Import-Module", $true); 
    $powerShell.AddParameter("Name", "DistributedCacheAdministration") 

    # Call the Invoke method to run the commands 
    $powerShell.Invoke(); 

    $powerShell.Commands.AddCommand("Use-CacheCluster") 
    $powerShell.Commands.AddCommand("Get-CacheHost") 
    $commandResults = $powerShell.Invoke() 
    $powerShell.Dispose() 

    Write-Host "Number of hosts in the cluster " $commandResults.Count 
    foreach ($cacheHost in $commandResults) 
    { 
     Write-Host "Configuring the host " $cacheHost.HostName 

     Invoke-Command -ComputerName $cacheHost.HostName -ScriptBlock {param ($provider, $newConnectionString) Import-Module DistributedCacheConfiguration;Remove-CacheHost;Add-CacheHost -Provider $provider -ConnectionString $newConnectionString -Account 'NT Authority\NETWORK SERVICE'} -ArgumentList $provider, $newConnectionString 
    } 
} 

# 
# Entry 
# 
Main 
+0

很好回答!我會嘗試當主機可以停止:) – Laurijssen

2

既然不能停止集羣,我想看看如果連接字符串將無需重新啓動被改變,基本上只是調用remove-CacheAdmin和附加CacheAdmin ....它的工作! 當然劇本將不得不在每臺主機所以不適合大型系統中良好運行,但不是真的需要重新啓動顯然

param ([string] $provider, [string] $newConnectionString) 

function Main { 

    if ((! $provider) -or (! $newConnectionString)) 
    { 
     Write-Host "Usage: ChangeConnString.ps1 <provider> <newConnectionString>" 
     exit(1) 
    } 

    Import-Module "DistributedCacheAdministration" 
    Import-Module "DistributedCacheConfiguration" 
    [Reflection.Assembly]::LoadWithPartialName('Microsoft.ApplicationServer.Caching.Management') | Out-Null 
    [Reflection.Assembly]::LoadWithPartialName('System.Management.Automation') | Out-Null 
    [Reflection.Assembly]::LoadWithPartialName('System.Management.Automation.Runspaces') | Out-Null 

    Remove-CacheAdmin 
    Add-CacheAdmin -Provider $provider -ConnectionString $newConnectionString 

} 
1

由其他用戶提供的腳本我沒有工作。我遇到了異常。我能夠通過編輯每臺主機上的註冊表並重新啓動服務來解決此問題。

連接字符串存儲在這裏:HKEY_LOCAL_MACHINE \ SOFTWARE \微軟\的AppFabric \ V1.0 \配置

值命名爲 「的ConnectionString」

根據用戶蜂巢,有連接的另一個實例串。我不知道你是否需要改變這個,但我做到了。 HKEY_CURRENT_USER \ Software \ Microsoft \ AppFabric \ V1.0 \ Temp

這對我很有用。不要忘了,您還需要在C:\ Program Files \ AppFabric 1.1下的DistributedCacheService.exe.config下編輯ClusterConfig ConnectionString for Windows Server