• SharePoint 2013配置分布式缓存


    在配置和使用SharPoint Farm的分布式缓存时,首先需要检查服务器上各参数运行正常,然后在进行cache cluster的配置。下面是各检查步骤:

       

    一、 检查服务器场中需要启用Distributed Cache服务的每台服务器上的注册表中的AppFabric注册表配置信息,注册表路径:"HKLM:SOFTWAREMicrosoftAppFabricV1.0"

    1. 检查Configuration节点下的ConnectionString和Provider属性的值是否正常。如果为空,则需要补全属性值。具体值信息可以从DistributedCacheService.exe.config中找到

      其中修复节点属性的PS脚本:

         

      $registryHive = "HKLM:SOFTWAREMicrosoftAppFabricV1.0Configuration"

      $connectionStringValueName = "ConnectionString"

      $connectionStringValue= "数据库连接字符串"

      $providerValueName = "Provider"

      $providerValue= "SPDistributedCacheClusterProvider"

      if ((Test-Path $registryHive) -eq $false) {New-Item $registryHive -Force | Out-Null}

      Set-ItemProperty $registryHive -Name $connectionStringValueName -Value  $connectionStringValue| Out-Null

      Set-ItemProperty $registryHive -Name $providerValueName -Value $providerValue| Out-Null

         

    2. 检查Providers/AppFabricCaching/SPDistributedCacheClusterProvider 节点是否存在,且其中属性DisplayName和Type是否有值。如果节点不存在则补全节点,如果节点中属性无值,则补全属性值,其中:

      DisplayName:Microsoft SharePoint AppFabric Caching Service Configuration Store Provider

      Type:Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterCustomProvider, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

       

    二、检查SPDistributedCacheClusterInfoManager对象与Get-CacheHost命令行查看到的服务器信息是否一致。

    #1. 查看SPDistributedCacheClusterInfoManager中的cache host 状态

    $Farm = Get-SPFarm

    $Name = "SPDistributedCacheCluster_" + $Farm.Id.ToString()

    $Manager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local

    $Info = $Manager.GetSPDistributedCacheClusterInfo($Name);

    $info.CacheHostsInfoCollection

       

    #2. 查看 Get-CacheHost中的 host状态

    Use-CacheCluster

    Get-CacheHost

    如果host状态不一致,则删除不一致的host信息,如果是重建分布式缓存,则删除所有host信息。删除host前,先检查所有cache服务实例状态,如果已经处于disable状态的,直接delete,如果处于online状态的,则先Unprovision ,然后在delete.

    #3 获取所有缓存服务实例

    get-SPServiceInstance | ? {($_.service.tostring()) -eq "SPDistributedCacheService Name=AppFabricCachingService"} | % { $_.Server; $_.Status; $_.Id }|Format-Table

    #获取单独服务实例,然后删除

    $s = Get-SPServiceInstance guid

    $s.Unprovision()

    $s.Delete()

       

    删除SPDistributedCacheClusterInfoManager中对象的方法:

    $info.CacheHostsInfoCollection.Remove(GUID)

    删除Cachehost中host的方法

    Unregister-CacheHost -ComputerName CQS-APP2-SP20.hanhua.com -ProviderType "SPDistributedCacheClusterProvider" -ConnectionString "Data Source=sp_db_content1;Initial Catalog=SharePoint_Config;Integrated Security=True;Enlist=False"

       

    三、检查防火墙,确保下面的进站出站规则均已启动:

    Firewall rule named 'AppFabric Caching Service (TCP-In)' --如果是中文,改为此英文名称。

    Firewall rule named 'AppFabric Caching Service (TCP-Out)' --如果是中文,改为此英文名称。

    Firewall rule named 'Remote Service Management (RPC)'

    Firewall rule named 'Remote Service Management (RPC-EPMAP)'

    Firewall rule named 'Remote Service Management (NP-In)'

       

    在重新配置缓存服务前,确保上述检查均已验证并处理完毕,上述配置调整完成后重启服务器。

       

    重新配置方式:

    1. 在需要运行缓存服务的服务器上,运行命令Add-SPDistributedCacheServiceInstance命令行
    2. 运行完成后,进行上述的第"二"步检查
      1. 确保SPDistributedCacheClusterInfoManager对象与Get-CacheHost命令行查看到的host一致。
      2. 确保服务实例已添加。
    3. 正常情况下,host应该自动启动并处于UP状态,如果处于DONW状态,则导出并检查配置文件

      Import-CacheClusterConfig -Path X: estAF.txt

      主要检查配置文件中hosts节点下的Account和hostid。Account为farm账号或"NT AUTHORITYNETWORK SERVICE",不能包含$符号。hostid最好与DistributedCacheService.exe.config中的一致。

      检查完成后,将配置文件重新导入 :

      Export-CacheClusterConfig -Path C: emAF1.txt

      启动缓存服务:

      Start-CacheHost -ComputerName computername -CachePort 22233

      启动后,在每台服务器上重新构建缓存实例:

      Remove-SPDistributedCacheServiceInstance

      Add-SPDistributedCacheServiceInstance

    运行缓存集群命令常见问题,及解决方案:

    1. Use-CacheCluster : ErrorCode<ERRPS001>:SubStatus<ES0001>:读取提供程序和连接字符串值时发生错误。请手动提供这些值。

    如果是缓存集群中的主服务器,则检查DistributedCacheService.exe.config中connectionstring是否正常。

    如果是其他加入farm的服务器,则在运行命令行的时候,补充ConnectionString和ProviderType的值,如:Use-CacheCluster -ConnectionString "" -ProviderType "SPDistributedCacheClusterProvider"

    下面是修改配置信息的PS命令行:

    registryHive = "HKLM:SOFTWAREMicrosoftAppFabricV1.0Configuration"

    $connectionStringValueName = "ConnectionString"

    $connectionStringValue= ""

    $providerValueName = "Provider"

    $providerValue= "SPDistributedCacheClusterProvider"

    if ((Test-Path $registryHive) -eq $false) {New-Item $registryHive -Force | Out-Null}

    Set-ItemProperty $registryHive -Name $connectionStringValueName -Value  $connectionStringValue| Out-Null

    Set-ItemProperty $registryHive -Name $providerValueName -Value $providerValue| Out-Null

    2.

    ps> $s= Get-SPServiceInstance GUID

    ps> $s.Delete()

    使用“0”个参数调用“Delete”时发生异常:“无法删除 SharePoint 管理框架中的对象“SPDistributedCacheServiceInstance”,因为其他对象依赖于该对象。请更新所有这些依赖对象,使其指向空对象或其他对象,然后重试此操作。这些依赖对象包括: 

    SPServiceInstanceJobDefinition Name=job-service-instance-XXXX

    所在位置 行:1 字符: 1

    + $s.Delete()

    + ~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

        + FullyQualifiedErrorId : InvalidOperationException

    解决方法:

    先删除对应的定时任务

    ps> $jobToDelete = Get-SPTimerJob | ? { $_.name -eq "job-service-instance-4XXX" }

    ps> $jobToDelete.Delete()

    3. 

    ps> Unregister-CacheHost -HostName computername -ProviderType 

    Unregister-AFCacheHost : 缺少参数“ProviderType”的某个参数。请指定一个类型为“System.String”的参数,然后再试一次。

    所在位置 行:1 字符: 58

    + Unregister-CacheHost -HostName computername -ProviderType

    +                                                          ~~~~~~~~~~~~~

        + CategoryInfo          : InvalidArgument: (:) [Unregister-AFCacheHost],ParameterBindingException

        + FullyQualifiedErrorId : MissingArgument,Microsoft.ApplicationServer.Caching.Configuration.Commands.UnregisterAFCacheHostCommand

    解决方法

    导出cachecluster配置文件,将hosts节点下所有信息删除。hosts配置节点需要为空才能执行unregister操作。

    <hosts></hosts>

    PS C:Windowssystem32> Export-CacheClusterConfig -Path D:softAF.XML

    PS C:Windowssystem32> Import-CacheClusterConfig D:softAF1.XML

    4.

    ps> Start-CacheHost -ComputerName "" -CachePort 22233

    HostName : CachePort            Service Name            Service Status Version Info

    --------------------            ------------            -------------- ------------

    computername:22233 AppFabricCachingService DOWN           3 [3,3][1,3]

    Start-CacheHost : 无法启动计算机“”上的服务 AppFabricCachingService。

    所在位置 行:1 字符: 1

    + Start-CacheHost -ComputerName "" -CachePort 22233

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [Start-AFCacheHost], InvalidOperationException

        + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.ApplicationServer.Caching.Commands.StartAFCacheHostCommand

    解决方法

    a. 参考上述注册表配置参数设置,检查配置参数是否完整。

    b. 检查上述“第二步”中的各对象中的host信息是否一致。

    c. 导出cachecluster配置文件,与DistributedCacheService.exe.config进行对比,检查其中的hostid,account等信息与DistributedCacheService.exe.config完全一致。然后重新创建SPDistributedCacheServiceInstance

    Export-CacheClusterConfig -Path D:softAF.XML

    Import-CacheClusterConfig D:softAF.XML

    ps> Remove-SPDistributedCacheServiceInstance

    ps>  Add-SPDistributedCacheServiceInstance

    5. ps >Add-SPDistributedCacheServiceInstance

    Add-SPDistributedCacheServiceInstance : ErrorCode<HostAlreadyPresent>:SubStatus<ES0001>:主机名 CQS-APP1-SP20 已经存在于群集配置中。

     解决方法

     使用上述第二步检查并修复各对象中HOST状态

    参考资料:

    SharePoint 2013: Claims Infrastructure – Part I

    SharePoint 2013: Claims Infrastructure – Part II

    SharePoint 2013 Distributed Cache service

    SharePoint 2013 : How I fixed my corrupted AppFabric Cache Service

    Fixing the AppFabric Cache Cluster in SharePoint 2013

    SharePoint 2013: AppFabric and Distributed Cache Service

    Administering Distributed Cache in SharePoint 2013

    SharePoint 2016: Distributed Cache error (ERRS001 & ES0001)

    SharePoint 2013 Distributed Cache Service错误和解决办法

       

  • 相关阅读:
    Grails
    Grails
    Grails
    Grails
    Grails
    Grails
    PG
    TopShelf安装多实例
    Js 实现自定义事件
    HttpContext未null处理
  • 原文地址:https://www.cnblogs.com/snailJuan/p/12485712.html
Copyright © 2020-2023  润新知