Microsoft Windows Server AppFabric Cookbook
上QQ阅读APP看书,第一时间看更新

Starting a Caching service

Windows PowerShell plays an extremely important role in the overall management of Windows Server AppFabric. There are hundreds of cmdlets and functions available that allow administrators (and developers alike) to perform day-to-day management tasks on AppFabric. As Caching is one of the biggest features in Windows Server AppFabric, it is no surprise that AppFabric Caching has a dedicated set of PowerShell cmdlets that allow developers and administrators to interact with the distributed Cache environments in an interactive and streamlined manner.

In this recipe, we will look at how to use PowerShell cmdlets to interact with the AppFabric Caching service.

Note

There are two ways that you can configure your Windows Server AppFabric installation/environment. One option is to use the Windows Server AppFabric Configuration wizard (that we have extensively used in this chapter) and another option is to use the Windows Server AppFabric PowerShell cmdlets. Using PowerShell to manage AppFabric Caching introduces a number of useful possibilities, including but not limited to automating build and deployment scenarios, and enabling command line monitoring and troubleshooting.

Getting ready

Assuming that you have the Windows Server AppFabric administration feature installed, you can launch the AppFabric PowerShell console via Administrative tools (available under Start | Control Panel | Administrative Tools) or by going to the Windows Server AppFabric folder under Program Files and selecting Caching Administration Windows PowerShell:

Getting ready

Note

On Windows 7 and Windows Server 2008, you must run Caching Administration Windows PowerShell with administrative privileges, otherwise some commands will not work.

How to do it...

After starting the Caching Administration Windows Powershell console with administrative privileges, we can start our Cache Cluster for the first time:

  1. To set the context of the Windows PowerShell session, we will execute the use-CacheCluster command first.

    Note

    The Use-CacheCluster command sets the context for Windows PowerShell. Considering that this is being executed on the host computer, we do not need to provide the configuration, as the parameters are extracted from the local computer.

  2. Once the context has been set, we will execute the start-CacheCluster command. This should result in a status that shows that the Caching Service is up and running:
    How to do it...

    Note

    The Start-CacheCluster commandlet starts the caching service on all the servers that are part of the cluster with the lead hosts starting before non-lead hosts.

  3. Once the Caching Service is up and running, we can query it for the caches that are available in this cluster by using the Get-Cache command.
    How to do it...

    Note

    This shows that the cluster is up and running and there is a default cache instance running on the cluster.

How it works...

The Caching Administration PowerShell commandlets give us complete control for managing an AppFabric Cache Cluster. When starting PowerShell sessions and running on a non-host computer, you must provide the -Provider (xml or System.Data.SqlClient) and ConnectionString (file path for XML or connection string for database).

Note that Cache services do not automatically start after a system reboot, so the Start-CacheCluster command must be invoked. We can also use the Start-CacheHost command with HostName and Port parameters to start a particular host in the cluster.

We will see much more on each of these PowerShell commands in the following chapters of this book.