-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workbench using SQL Server cluster based on windows failover cluster …
…with S2D storage. PiperOrigin-RevId: 568367684
- Loading branch information
1 parent
c6b4b05
commit 6f4d215
Showing
23 changed files
with
601 additions
and
14 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...enchmarker/data/relational_db_configs/sqlserver_ha_configs/add_sql_server_second_node.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
try { | ||
$scriptsFolder = 'c:\scripts' | ||
$domainUser = 'perflab\administrator' | ||
$localServerName = [System.Net.Dns]::GetHostName() | ||
$clearPassword = $args[1] | ||
$taskScriptPath = $scriptsFolder + '\fci-cluster-task.ps1' | ||
$clusterIpAddress = $args[0] | ||
|
||
if (-not (Test-Path $scriptsFolder)) { | ||
New-Item -Path $scriptsFolder -ItemType directory | ||
} | ||
|
||
Write-Host 'Install SQL Server' | ||
# SQL Server 2022 needs /PRODUCTCOVEREDBYSA=False | ||
$sql2022InstallParam = '/PRODUCTCOVEREDBYSA=False' | ||
$sql2022InstallParam = '' | ||
$sqlInstallString = [string]::Format('c:\sql_server_install\Setup.exe /Action=AddNode /UpdateEnabled=True {2} /ENU=True /CONFIRMIPDEPENDENCYCHANGE=false /SQLSVCACCOUNT=''perflab\sql_server'' /SQLSVCPASSWORD=''{0}'' /AGTSVCACCOUNT=''perflab\sql_server'' /AGTSVCPASSWORD=''{0}'' /INSTANCENAME=''MSSQLSERVER'' /FAILOVERCLUSTERNETWORKNAME=''sql'' /FAILOVERCLUSTERIPADDRESSES=''IPv4;{1};Cluster Network 1;255.255.240.0'' /FAILOVERCLUSTERGROUP=''SQL Server (MSSQLSERVER)'' /SQLSVCINSTANTFILEINIT=''False'' /FTSVCACCOUNT=''NT Service\MSSQLFDLauncher'' /IAcceptSQLServerLicenseTerms=1 /INDICATEPROGRESS /Q 2>&1 > c:\scripts\sqlsetuplog.log',$clearPassword,$clusterIpAddress,$sql2022InstallParam) | ||
|
||
Out-File -FilePath $taskScriptPath -InputObject $sqlInstallString | ||
|
||
$currentDateTime = Get-Date | ||
|
||
$taskName = 'Run-Cluster-Tasks' | ||
$taskAction = New-ScheduledTaskAction -Execute 'PowerShell.exe' -Argument $taskScriptPath | ||
$taskTrigger = New-ScheduledTaskTrigger -Once -At $currentDateTime.AddMinutes(120).ToString('HH:mm:sstt') | ||
$scheduledTask = New-ScheduledTask -Action $taskAction -Trigger $taskTrigger | ||
|
||
Register-ScheduledTask -TaskName $taskName -InputObject $scheduledTask -User $domainUser -Password $clearPassword | ||
Start-ScheduledTask -TaskName $taskName | ||
|
||
|
||
Write-Host 'Running task' | ||
Write-Host (Get-ScheduledTask -TaskName $taskName).State | ||
|
||
while ((Get-ScheduledTask -TaskName $taskName).State -ne 'Ready') { | ||
Write-Host -Message 'Waiting on scheduled task...' | ||
Start-Sleep -Seconds 10 | ||
} | ||
Start-Sleep -Seconds 10 | ||
Disable-ScheduledTask -TaskName $taskName | ||
|
||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
23 changes: 23 additions & 0 deletions
23
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/clean_disks.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
try { | ||
$scriptsFolder = 'c:\scripts' | ||
$diskpartCmdFile = $scriptsFolder + '\diskpartcmd.txt' | ||
|
||
if (-not (Test-Path $scriptsFolder)) { | ||
New-Item -Path $scriptsFolder -ItemType directory | ||
} | ||
|
||
$physicalDisks = Get-PhysicalDisk | where-object {$_.CanPool -eq $true} | Select-Object -exp DeviceID | ||
|
||
New-Item -Path $diskpartCmdFile -itemtype file -force | OUT-NULL | ||
|
||
foreach($pd in $physicalDisks) { | ||
Add-Content -path $diskpartCmdFile "select disk $pd" | ||
Add-Content -path $diskpartCmdFile 'clean' | ||
} | ||
|
||
diskpart /s $diskpartCmdFile | ||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
8 changes: 8 additions & 0 deletions
8
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/grant_witness_access.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
try { | ||
icacls C:\QWitness\ /grant 'sql-fci$:(OI)(CI)(M)' | ||
Grant-SmbShareAccess -Name QWitness -AccountName 'sql-fci$' -AccessRight Full -Force | ||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
15 changes: 15 additions & 0 deletions
15
...enchmarker/data/relational_db_configs/sqlserver_ha_configs/install_cluster_components.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
try { | ||
$ErrorActionPreference = 'stop' | ||
Write-Host 'Installing cluster components.' | ||
# Install required Windows features | ||
Install-WindowsFeature Failover-Clustering -IncludeManagementTools | ||
Install-WindowsFeature RSAT-AD-PowerShell | ||
|
||
# Open firewall for WSFC | ||
Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled False | ||
|
||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
13 changes: 13 additions & 0 deletions
13
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/set_dns.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$dnsServerIpAddress=$args[0] | ||
|
||
$nic = Get-NetAdapter | ||
|
||
Write-Host "Set DNS Server to $dnsServerIpAddress" | ||
|
||
Set-DnsClientServerAddress -InterfaceIndex $nic[0].ifIndex -ServerAddresses $dnsServerIpAddress | ||
|
||
$dns_server = Get-DnsClientServerAddress -InterfaceIndex $nic[0].ifIndex -AddressFamily IPv4 | ||
|
||
if ($dns_server.ServerAddresses -eq $dnsServerIpAddress) { | ||
Write-Host 'DNS Set completed.' | ||
} |
19 changes: 19 additions & 0 deletions
19
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/set_dns_join_domain.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
$domainUser = 'perflab\administrator' | ||
$dnsServerIpAddress=$args[0] | ||
|
||
$passwordSecureString = (ConvertTo-SecureString -AsPlainText $args[1] -Force) | ||
$nic = Get-NetAdapter | ||
|
||
Write-Host "Set DNS Server to $dnsServerIpAddress" | ||
|
||
Set-DnsClientServerAddress -InterfaceIndex $nic[0].ifIndex -ServerAddresses $dnsServerIpAddress | ||
|
||
$dns_server = Get-DnsClientServerAddress -InterfaceIndex $nic[0].ifIndex -AddressFamily IPv4 | ||
|
||
if ($dns_server.ServerAddresses -eq $dnsServerIpAddress) { | ||
Write-Host 'DNS Set. Joining perflab.local Domain' | ||
$credObject = New-Object System.Management.Automation.PSCredential ($domainUser, $passwordSecureString) | ||
|
||
Add-Computer -DomainName perflab.local -credential $credObject | ||
Write-Host 'Done' | ||
} |
50 changes: 50 additions & 0 deletions
50
...itbenchmarker/data/relational_db_configs/sqlserver_ha_configs/setup_domain_controller.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
$domainName = 'perflab.local' | ||
$netBIOSname = 'perflab' | ||
$mode = 'WinThreshold' | ||
|
||
$scriptsFolder = 'c:\scripts' | ||
|
||
|
||
try { | ||
Write-Host "Pass=$args[0]" | ||
$PasswordSecureString = (ConvertTo-SecureString -AsPlainText $args[0] -Force) | ||
Start-Sleep -Seconds 30 | ||
|
||
New-LocalUser 'adminuser' -Password $PasswordSecureString -FullName 'Admin User' -PasswordNeverExpires | ||
Add-LocalGroupMember -Group 'Administrators' -Member 'adminuser' | ||
|
||
|
||
$AdminUserAccount = Get-LocalUser -Name 'Administrator' | ||
$AdminUserAccount | Set-LocalUser -Password $PasswordSecureString | ||
$AdminUserAccount | Enable-LocalUser | ||
|
||
|
||
|
||
Install-WindowsFeature AD-Domain-Services -IncludeAllSubFeature -IncludeManagementTools | ||
|
||
|
||
|
||
Import-Module ADDSDeployment | ||
|
||
$forestProperties = @{ | ||
|
||
DomainName = $domainName | ||
DomainNetbiosName = $netBIOSname | ||
ForestMode = $mode | ||
DomainMode = $mode | ||
CreateDnsDelegation = $false | ||
InstallDns = $true | ||
DatabasePath = 'C:\Windows\NTDS' | ||
LogPath = 'C:\Windows\NTDS' | ||
SysvolPath = 'C:\Windows\SYSVOL' | ||
NoRebootOnCompletion = $true | ||
SafeModeAdministratorPassword = $PasswordSecureString | ||
Force = $true | ||
} | ||
|
||
Install-ADDSForest @forestProperties | ||
|
||
} | ||
catch { | ||
throw $_.Exception.Message | ||
} |
22 changes: 22 additions & 0 deletions
22
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/setup_fci_cluster.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
try { | ||
$domainUser = 'perflab\administrator' | ||
$localServerName = [System.Net.Dns]::GetHostName() | ||
|
||
$passwordSecureString = (ConvertTo-SecureString -AsPlainText $args[2] -Force) | ||
$node1 = $localServerName + '.perflab.local' | ||
$node2 = $args[0] + '.perflab.local' | ||
$fulldcname = $args[1] + '.perflab.local' | ||
|
||
Write-Host $args[2] | ||
|
||
$domainCredential = New-Object System.Management.Automation.PSCredential ($domainUser, $passwordSecureString) | ||
|
||
Write-Host 'Create failover cluster' | ||
Invoke-Command -ComputerName $fulldcname -Credential $domainCredential -ArgumentList $node1,$node2 -ScriptBlock { | ||
New-Cluster -Name sql-fci -Node $args[0],$args[1] -NoStorage -ManagementPointNetworkType Distributed | ||
} | ||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
54 changes: 54 additions & 0 deletions
54
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/setup_s2d_volumes.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
try { | ||
$domainUser = 'perflab\administrator' | ||
$localServerName = [System.Net.Dns]::GetHostName() | ||
|
||
$passwordSecureString = (ConvertTo-SecureString -AsPlainText $args[0] -Force) | ||
$node1 = $localServerName + '.perflab.local' | ||
|
||
$partVmName = $localServerName.Substring(0, $localServerName.Length - 1) | ||
|
||
$node2 = $partVmName + '2.perflab.local' | ||
$dc = $partVmName + '3.perflab.local' | ||
|
||
$domainCredential = New-Object System.Management.Automation.PSCredential ($domainUser, $passwordSecureString) | ||
|
||
$cacheDiskModel = 'EphemeralDisk' | ||
|
||
$nvme_disks = Get-PhysicalDisk | Where-Object { $_.FriendlyName -like 'nvme_card' } | ||
$scsi_disks = Get-PhysicalDisk | Where-Object { $_.FriendlyName -like 'EphemeralDisk' } | ||
|
||
if ($nvme_disks.count -gt 0) { | ||
$cacheDiskModel = 'nvme_card' | ||
} | ||
if ($scsi_disks.count -gt 0) { | ||
$cacheDiskModel = 'EphemeralDisk' | ||
} | ||
Write-Host $cacheDiskModel | ||
if ([string]::IsNullOrEmpty($cacheDiskModel)) { | ||
Enable-ClusterStorageSpacesDirect -PoolFriendlyName 's2dpool' -Confirm:0; | ||
} | ||
else { | ||
Invoke-Command -ComputerName $node1 -Credential $domainCredential -ArgumentList $cacheDiskModel -ScriptBlock { | ||
Enable-ClusterStorageSpacesDirect -CacheDeviceModel $args[0] -PoolFriendlyName 's2dpool' -Confirm:0; | ||
} | ||
} | ||
Start-Sleep -Seconds 40 | ||
(Get-Cluster).BlockCacheSize = 2048 | ||
|
||
New-Volume -StoragePoolFriendlyName S2D* -FriendlyName 'Data' -FileSystem CSVFS_ReFS ` | ||
-AllocationUnitSize 65536 -ProvisioningType 'Fixed' ` | ||
-UseMaximumSize | ||
|
||
Write-Host 'Test Cluster' | ||
Invoke-Command -ComputerName $dc -Credential $domainCredential -ArgumentList $node1,$node2 -ScriptBlock { | ||
Test-Cluster -Node $args[0],$args[1] -Confirm:0; | ||
} | ||
Write-Host 'Add SQL service account' | ||
Invoke-Command -ComputerName $dc -Credential $domainCredential -ArgumentList $passwordSecureString -ScriptBlock { | ||
New-ADUser -Name 'sql_server' -Description 'SQL Agent and SQL Admin account.' -AccountPassword $args[0] -Enabled $true -PasswordNeverExpires $true | ||
} | ||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
49 changes: 49 additions & 0 deletions
49
...nchmarker/data/relational_db_configs/sqlserver_ha_configs/setup_sql_server_first_node.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
try { | ||
$scriptsFolder = 'c:\scripts' | ||
$domainUser = 'perflab\administrator' | ||
$localServerName = [System.Net.Dns]::GetHostName() | ||
$clearPassword = $args[1] | ||
$taskScriptPath = $scriptsFolder + '\fci-cluster-task.ps1' | ||
$clusterIpAddress = $args[0] | ||
|
||
if (-not(Test-Path $scriptsFolder)) { | ||
New-Item -Path $scriptsFolder -ItemType directory | ||
} | ||
|
||
Write-Host 'Install SQL Server' | ||
# SQL Server 2022 needs /PRODUCTCOVEREDBYSA=False | ||
$sql2022InstallParam = '/PRODUCTCOVEREDBYSA=False' | ||
$sql2022InstallParam = '' | ||
$sqlInstallString = [string]::Format('c:\sql_server_install\Setup.exe /Action=InstallFailoverCluster /UpdateEnabled=True {2} /ENU=True /SQLSVCACCOUNT=''perflab\sql_server'' /SQLSVCPASSWORD=''{0}'' /SAPWD=''{0}'' /AGTSVCACCOUNT=''perflab\sql_server'' /AGTSVCPASSWORD=''{0}'' /FEATURES=SQLENGINE,REPLICATION,FULLTEXT,DQ /INSTANCEID=''MSSQLSERVER'' /INSTANCENAME=''MSSQLSERVER'' /INSTALLSHAREDDIR=''C:\Program Files\Microsoft SQL Server'' /INSTANCEDIR=''C:\Program Files\Microsoft SQL Server'' /FAILOVERCLUSTERDISKS=''Cluster Virtual Disk (Data)'' /FAILOVERCLUSTERNETWORKNAME=''sql'' /FAILOVERCLUSTERIPADDRESSES=''IPv4;{1};Cluster Network 1;255.255.240.0'' /FAILOVERCLUSTERGROUP=''SQL Server (MSSQLSERVER)'' /SQLSVCINSTANTFILEINIT=''True'' /SQLSYSADMINACCOUNTS=''perflab\domain admins'' /IACCEPTSQLSERVERLICENSETERMS=1 /INSTALLSQLDATADIR=''C:\ClusterStorage\Data\'' /SQLUSERDBLOGDIR=''C:\ClusterStorage\Data\MSSQL\Log'' /SQLTEMPDBDIR=''C:\ClusterStorage\Data\MSSQL\Temp'' /FTSVCACCOUNT=''NT Service\MSSQLFDLauncher'' /INDICATEPROGRESS /SECURITYMODE=SQL /Q 2>&1 > c:\scripts\sqlsetuplog.log',$clearPassword, $clusterIpAddress,$sql2022InstallParam) | ||
|
||
Out-File -FilePath $taskScriptPath -InputObject $sqlInstallString | ||
Add-Content $taskScriptPath 'Add-ClusterResource -Name fci-dnn -ResourceType ''Distributed Network Name'' -Group ''SQL Server (MSSQLSERVER)''' | ||
Add-Content $taskScriptPath 'Get-ClusterResource -Name fci-dnn | Set-ClusterParameter -Name DnsName -Value fcidnn' | ||
Add-Content $taskScriptPath 'Start-ClusterResource -Name fci-dnn' | ||
|
||
$currentDateTime = Get-Date | ||
|
||
$taskName = 'Run-Cluster-Tasks' | ||
$taskAction = New-ScheduledTaskAction -Execute 'PowerShell.exe' -Argument $taskScriptPath | ||
$taskTrigger = New-ScheduledTaskTrigger -Once -At $currentDateTime.AddMinutes(120).ToString('HH:mm:sstt') | ||
$scheduledTask = New-ScheduledTask -Action $taskAction -Trigger $taskTrigger | ||
|
||
Register-ScheduledTask -TaskName $taskName -InputObject $scheduledTask -User $domainUser -Password $clearPassword | ||
Start-ScheduledTask -TaskName $taskName | ||
|
||
|
||
Write-Host 'Running task' | ||
Write-Host (Get-ScheduledTask -TaskName $taskName).State | ||
|
||
while ((Get-ScheduledTask -TaskName $taskName).State -ne 'Ready') { | ||
Write-Host -Message 'Waiting on scheduled task...' | ||
Start-Sleep -Seconds 10 | ||
} | ||
Start-Sleep -Seconds 25 | ||
Disable-ScheduledTask -TaskName $taskName | ||
|
||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
25 changes: 25 additions & 0 deletions
25
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/setup_witness.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
try { | ||
|
||
Install-WindowsFeature FS-FileServer | ||
|
||
# Open firewall for WSFC | ||
Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled False | ||
|
||
$local_name = [System.Net.Dns]::GetHostName() | ||
$joined_computers = (Get-AdComputer -filter "Name -NotLike '$local_name'" | Select-Object Name) | ||
|
||
New-Item 'C:\QWitness' -type directory | ||
|
||
New-SmbShare -Name QWitness -Path 'C:\QWitness' -Description 'SQL File Share Witness' -FullAccess $env:username | ||
|
||
foreach ($comp in $joined_computers) { | ||
$node = $comp.Name + '$' | ||
Write-Host $node | ||
icacls C:\QWitness\ /grant '$($node):(OI)(CI)(M)' | ||
Grant-SmbShareAccess -Name 'QWitness' -AccountName $node -AccessRight Full -Force | ||
} | ||
} | ||
catch { | ||
Write-Host $_.Exception.Message | ||
throw $_.Exception.Message | ||
} |
7 changes: 7 additions & 0 deletions
7
perfkitbenchmarker/data/relational_db_configs/sqlserver_ha_configs/update_sql_server.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$url = 'https://download.microsoft.com/download/6/e/7/6e72dddf-dfa4-4889-bc3d-e5d3a0fd11ce/SQLServer2019-KB5027702-x64.exe' | ||
$dest = 'c:\scripts\SQLServer2019-KB5027702-x64.exe' | ||
|
||
# Download the file | ||
(New-Object System.Net.WebClient).DownloadFile($url, $dest) | ||
|
||
c:\scripts\SQLServer2019-KB5027702-x64.exe /q /IAcceptSQLServerLicenseTerms /Action=Patch /InstanceName=MSSQLSERVER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.