In these articles, we’ll look at how to set up high availability on one or more databases with the AlwaysOn feature, using the « dbatools » PowerShell library.
To do this, we’ll need to install and configure an active directory and two SQL server instances on two different servers, using Failover Clustering.

In this article you will learn :

  • How to install and configure the Active Directory on WIndows Server
  • How to configure the IP address on our Windows Server for the Active Directory
  • how to create a domain administrator account and a SQL server service account

Installation and configuration of the Active Directory

Let’s now install and configure an active directory !

To install the active directory on our server, go to « Server manager » and click on « Add Roles and Feature ».

On the first page of the Wizard, click on « Next ».
Then select « Rôle-based or feature-based installation ».

In « Server Selection », click directly on « Next ».

Then add the two features, « Active Directory Domain Services » and « DNS Server ».

Click on « Next », until you can click on « Install ».

WARNING : Once installation is complete, do not close the window. Click on « Promote this server to a domain controller ».

Select « Add a forest » and specify a domain name

Enter a password for the domain administrator.

Then click on « Next » to « Prerequisites Check » and click on « Install ».

The virtual machine will then reboot, and you’ll log back in as the domain’s Administrator.

Configuration of the IP address for our Active Directory

We want to install and configure an active directory so let’s now configure it.

We’re now going to configure a fixed IP address for our Active directory, because by default the IP address of a virtual machine is dynamic, so it changes every time we change network.

To configure our fixed IP address, let’s go to « Network Status » and then « Change adapter options »:

Right-click on « Ethernet » and « Properties ».

Select « Internet Protocol Version 4 (TCP/IPv4) » and right-click to select « Properties ».
Fill in the fields as shown in the screenshot, or set your own IP address, then confirm.

Create a domain administrator account and a SQL server service account

We’re now going to create a domain administrator account for our use, as well as a SQL server service account so that we can perform tasks on all domain instances. To do this you can exeute the powershell command :

 

Import-Module ActiveDirectory 
New-ADOrganizationalUnit -Name "Administrateur"
$userPassword = ConvertTo-SecureString "Password123" -AsPlainText -Force
New-ADUser -Name "perso_adm" -SamAccountName "perso_adm" -GivenName "perso_adm" -Surname "perso_adm" -DisplayName "perso_adm" -Enabled $true -AccountPassword $userPassword -PassThru -ChangePasswordAtLogon $false
Add-ADGroupMember -Identity "Domain Admins" -Members "perso_adm"
Get-ADUser -Filter "name -like 'perso_adm'" | Move-ADObject -TargetPath (Get-ADOrganizationalUnit -Filter "Name -like 'Administrateur'")
New-ADUser -Name "SQLSAV" -SamAccountName "SQLSAV" -GivenName "SQLSAV" -Surname "SQLSAV" -DisplayName "SQLSAV" -Enabled $true -AccountPassword $userPassword -PassThru -ChangePasswordAtLogon $false
Add-ADGroupMember -Identity "Domain Admins" -Members "SQLSAV"
Get-ADUser -Filter "name -like 'SQLSAV'" | Move-ADObject -TargetPath (Get-ADOrganizationalUnit -Filter "Name -like 'Administrateur'")

Or, go to Server Manager and select Active Directory Users and Computers:

Create a new « Organizational Unit ».

Name this « OR » « Administrators ».

Right-click on the « Administrator » OU just created, click on « New » and « User ».

Fill in the fields below for your administrator account.

Click on « Next », then enter the password and uncheck « User must change password at next logon ».

Right-click on the « User » you’ve just created, click on « Properties » and go to the « MemberOf » tab.

Select « Add », enter « Domain Admin » in the text field and click on « Check Names ». Close the windows by selecting « OK ».

You’ve just added the user to the domain administrators. Now for correctly install and configure an active directory do the same for the SQL server system account. Simply replace « perso_adm » with « SQLSAV ».

Conclusion

You now have correctly install and configure an active directory on a virtual machine with a personal domain administrator account and a SQL service account.
In part three, we’ll look at how to install and configure our two VMs so that they appear in our domain and host our two SQL server instances.