Muokkaa

Jaa


Deploy a Pacemaker cluster for SQL Server on Linux

Applies to: SQL Server - Linux

This tutorial documents the tasks required to deploy a Linux Pacemaker cluster for a SQL Server Always On availability group (AG) or failover cluster instance (FCI). Unlike the tightly coupled Windows Server / SQL Server stack, Pacemaker cluster creation and availability group (AG) configuration on Linux, can be done before or after installation of SQL Server. The integration and configuration of resources for the Pacemaker portion of an AG or FCI deployment is done after the cluster is configured.

Important

An AG with a cluster type of None does not require a Pacemaker cluster, nor can it be managed by Pacemaker.

  • Install the high availability add-on and install Pacemaker.
  • Prepare the nodes for Pacemaker (RHEL and Ubuntu only).
  • Create the Pacemaker cluster.
  • Install the SQL Server HA and SQL Server Agent packages.

Prerequisites

Install SQL Server on Linux.

Install the high availability add-on

Use the following syntax to install the packages that make up the high availability (HA) add-on for each distribution of Linux.

  1. Register the server using the following syntax. You're prompted for a valid username and password.

    sudo subscription-manager register
    
  2. List the available pools for registration.

    sudo subscription-manager list --available
    
  3. Run the following command to associate RHEL high availability with the subscription

    sudo subscription-manager attach --pool=<PoolID>
    

    where PoolId is the pool ID for the high availability subscription from the previous step.

  4. Enable the repository to be able to use the high availability add-on.

    sudo subscription-manager repos --enable=rhel-ha-for-rhel-7-server-rpms
    
  5. Install Pacemaker.

    sudo yum install pacemaker pcs fence-agents-all resource-agents
    

Prepare the nodes for Pacemaker (RHEL and Ubuntu only)

Pacemaker itself uses a user created on the distribution named hacluster. The user gets created when the HA add-on is installed on RHEL and Ubuntu.

  1. On each server that will serve as a node of the Pacemaker cluster, create the password for a user to be used by the cluster. The name used in the examples is hacluster, but any name can be used. The name and password must be the same on all nodes participating in the Pacemaker cluster.

    sudo passwd hacluster
    
  2. On each node that will be part of the Pacemaker cluster, enable and start the pcsd service with the following commands (RHEL and Ubuntu):

    sudo systemctl enable pcsd
    sudo systemctl start pcsd
    

    Then execute the following command to ensure that pcsd is started.

    sudo systemctl status pcsd
    
  3. Enable the Pacemaker service on each possible node of the Pacemaker cluster.

    sudo systemctl start pacemaker
    

    On Ubuntu, you see an error:

    pacemaker Default-Start contains no runlevels, aborting.
    

    This error is a known issue. Despite the error, enabling the Pacemaker service is successful, and this bug will be fixed at some point in the future.

  4. Next, create and start the Pacemaker cluster. There's one difference between RHEL and Ubuntu at this step. While on both distributions, installing pcs configures a default configuration file for the Pacemaker cluster, on RHEL, executing this command destroys any existing configuration and creates a new cluster.

Create the Pacemaker cluster

This section documents how to create and configure the cluster for each distribution of Linux.

  1. Authorize the nodes

    sudo pcs cluster auth <Node1 Node2 ... NodeN> -u hacluster
    

    where NodeX is the name of the node.

  2. Create the cluster

    sudo pcs cluster setup --name <PMClusterName Nodelist> --start --all --enable
    

    where PMClusterName is the name assigned to the Pacemaker cluster and Nodelist is the list of names of the nodes separated by a space.

Install the SQL Server HA and SQL Server Agent packages

Use the following commands to install the SQL Server HA package and SQL Server Agent, if they aren't installed already. Installing the HA package after installing SQL Server requires a restart of SQL Server for it to be used. These instructions assume that the repositories for the Microsoft packages are already set up, since SQL Server should be installed at this point.

  • If you won't use SQL Server Agent for log shipping or any other use, it doesn't have to be installed, so package mssql-server-agent can be skipped.

  • The other optional packages for SQL Server on Linux, SQL Server Full-Text Search (mssql-server-fts) and SQL Server Integration Services (mssql-server-is), aren't required for high availability, either for an FCI or an AG.

sudo yum install mssql-server-ha mssql-server-agent
sudo systemctl restart mssql-server

Next step

In this tutorial, you learned how to deploy a Pacemaker cluster for SQL Server on Linux. You learned how to:

  • Install the high availability add-on and install Pacemaker.
  • Prepare the nodes for Pacemaker (RHEL and Ubuntu only).
  • Create the Pacemaker cluster.
  • Install the SQL Server HA and SQL Server Agent packages.

To create and configure an availability group for SQL Server on Linux, see: