Deploying the failover cluster

You now use the VM instances to deploy a Windows Server Failover Cluster and SQL Server.

Preparing SQL Server

Create a new user account in Active Directory for SQL Server:

  1. Connect to node-1 by using Remote Desktop. Sign in with your domain user account.
  2. Right-click the Start button (or press Win+X) and click Windows PowerShell (Admin).
  3. Confirm the elevation prompt by clicking Yes.
  4. Create a domain user account for SQL server and the SQL agent and assign a password.

    $Credential = Get-Credential -UserName sql_server -Message 'Enter password'
    New-ADUser `
      -Name "sql_server" `
      -Description "SQL Admin account." `
      -AccountPassword $Credential.Password `
      -Enabled $true -PasswordNeverExpires $true
    

To configure SQL Server, perform the following steps on both node-1 and node-2:

  1. Right-click the Start button (or press Win+X) and click Windows PowerShell (Admin).

    Rename the SQL server instance so that its name matches the hostname.

    $OLD_NAME = Invoke-Sqlcmd -Query "
      select @@SERVERNAME;
      GO" | ConvertTo-Csv | SELECT -Skip 2
    $OLD_NAME = $OLD_NAME.Replace('"', '')
    Invoke-Sqlcmd -Query "
      sp_dropserver '$OLD_NAME';
      GO
      sp_addserver '$env:computername', local;
      GO"
    Restart-Service -Name MSSQLSERVER
    
  2. Open SQL Server Configuration Manager.

  3. In the navigation pane, select SQL Server Services

  4. In the list of services, right-click SQL Server (MSSQLSERVER) and select Properties.

  5. Under Log on as, change the account.

    • Account name: DOMAIN\sql_server where DOMAIN is the NetBIOS name of your Active Directory domain.
    • Password: Enter the password you chose previously.
  6. Click OK.

  7. When prompted to restart SQL Server, select Yes.

SQL Server now runs under a domain user account.