in perfkitbenchmarker/sqlserver_iaas_relational_db.py [0:0]
def ConfigureSQLServerHaFci(self):
"""Create SQL server HA deployment for performance testing."""
server_vm = self.server_vm
client_vm = self.client_vm
controller_vm = self.controller_vm
replica_vms = self.replica_vms
win_password = vm_util.GenerateRandomWindowsPassword(
vm_util.PASSWORD_LENGTH, "*!@#%^+="
)
ip_address = self.CreateIpReservation()
perf_domain = "perf" + FLAGS.run_uri[:6]
# Install and configure AD components.
self.PushAndRunPowershellScript(
controller_vm, "setup_domain_controller.ps1",
[win_password, perf_domain, self.spec.cloud])
controller_vm.Reboot()
self.PushAndRunPowershellScript(
controller_vm, "add_user_to_domain_groups.ps1",
[win_password, perf_domain])
# Remove volumes and partitions created on the attached disks.
# Disks will be initialized by S2D.
self.PushAndRunPowershellScript(
server_vm, "clean_disks.ps1")
server_vm.Reboot()
self.PushAndRunPowershellScript(
server_vm, "set_dns_join_domain.ps1",
[controller_vm.internal_ip, win_password, perf_domain])
server_vm.Reboot()
self.PushAndRunPowershellScript(
replica_vms[0], "clean_disks.ps1")
replica_vms[0].Reboot()
self.PushAndRunPowershellScript(
replica_vms[0], "set_dns_join_domain.ps1",
[controller_vm.internal_ip, win_password, perf_domain])
replica_vms[0].Reboot()
self.PushAndRunPowershellScript(
client_vm, "set_dns.ps1", [controller_vm.internal_ip])
# Install all components needed to create and configure failover cluster.
self.PushAndRunPowershellScript(
controller_vm, "install_cluster_components.ps1")
controller_vm.Reboot()
self.PushAndRunPowershellScript(
server_vm, "install_cluster_components.ps1")
server_vm.Reboot()
self.PushAndRunPowershellScript(
replica_vms[0], "install_cluster_components.ps1")
replica_vms[0].Reboot()
# Setup cluster witness.
self.PushAndRunPowershellScript(
controller_vm, "setup_witness.ps1")
self.PushAndRunPowershellScript(
server_vm, "setup_fci_cluster.ps1",
[replica_vms[0].hostname, win_password, perf_domain])
# Ensure all nodes in the cluster have access to the witness share
self.PushAndRunPowershellScript(
controller_vm, "grant_witness_access.ps1")
# Uninstall existing SQL server.
# FCI cluster requires different installation to what comes with the image.
self.PushAndRunPowershellScript(
server_vm, "uninstall_sql_server.ps1")
server_vm.Reboot()
self.PushAndRunPowershellScript(
replica_vms[0], "uninstall_sql_server.ps1")
replica_vms[0].Reboot()
server_vm.Reboot()
if self.spec.high_availability_type == "FCIMW":
# Configure MW cluster disks.
self.PushAndRunPowershellScript(
server_vm, "setup_mw_volume.ps1",
[win_password, replica_vms[0].hostname, perf_domain])
else:
# Configure S2D pool and volumes.
# All available storage (both PD and local SSD) will be used
self.PushAndRunPowershellScript(
server_vm, "setup_s2d_volumes.ps1",
[win_password, replica_vms[0].hostname, perf_domain])
# install SQL server into newly created cluster
self.PushAndRunPowershellScript(
server_vm, "setup_sql_server_first_node.ps1",
[ip_address, win_password, perf_domain]
)
self.PushAndRunPowershellScript(
replica_vms[0], "add_sql_server_second_node.ps1",
[ip_address, win_password, perf_domain],
)
# Install SQL server updates.
# Installation media present on the system is very outdated and it
# does not support DNN connection for SQL.
# Fetch the SQL server update link from MS site.
sql_srv_vms = [server_vm, replica_vms[0]]
sql_srv_updates_windows = {
"2022": "KB5032679",
"2019": "KB5031908",
"2017": "KB5016884",
"2016": "KB5029186",
"2014": "KB5029185",
}
# for each database vm, fetch sql server update link and execute update
for sql_srv_vm in sql_srv_vms:
sql_server_version = self.GetSQLServerVersion(sql_srv_vm)
if (sql_srv_updates_windows.get(sql_server_version) is not None):
kb_number = sql_srv_updates_windows[sql_server_version]
if (kb_number is not None and kb_number):
self.PushAndRunPowershellScript(
sql_srv_vm, "update_sql_server.ps1", [kb_number]
)
sql_srv_vm.Reboot()
self.PushAndRunPowershellScript(
server_vm, "check_sql_role_status_after_upgrade.ps1")
# Update variables user for connection to SQL server.
self.spec.database_password = win_password
self.spec.endpoint = "fcidnn.{}.local".format(perf_domain)
self.ReleaseIpReservation()