אתם משתמשים בקובץ אימג' של SQL Server Premium שבו מותקן מראש SQL Server 2022.
כדי לספק הצבעה מכריעה ולהשיג קוורום בתרחיש של מעבר לגיבוי, צריך לפרוס מכונה וירטואלית שלישית שתשמש כעדות לשיתוף קבצים.
- חוזרים לסשן הקיים של Cloud Shell.
יוצרים סקריפט מיוחד לצמתי האשכול. הסקריפט מתקין את התכונה הנדרשת של Windows ויוצר כללי חומת אש עבור אשכול יתירות הכשל ו-SQL Server.
cat << "EOF" > specialize-node.ps1 $ErrorActionPreference = "stop" # Install required Windows features Install-WindowsFeature Failover-Clustering -IncludeManagementTools Install-WindowsFeature RSAT-AD-PowerShell # Open firewall for availability group listener netsh advfirewall firewall add rule name="Allow SQL Server Listener health check" dir=in action=allow protocol=TCP localport=59997 # Open firewall for the Failover Cluster netsh advfirewall firewall add rule name="Allow SQL Server health check" dir=in action=allow protocol=TCP localport=59998 # Open firewall for SQL Server netsh advfirewall firewall add rule name="Allow SQL Server" dir=in action=allow protocol=TCP localport=1433 # Open firewall for SQL Server replication netsh advfirewall firewall add rule name="Allow SQL Server replication" dir=in action=allow protocol=TCP localport=5022 # Format data disk Get-Disk | Where partitionstyle -eq 'RAW' | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel 'Data' -Confirm:$false # Create data and log folders for SQL Server md d:\Data md d:\Logs EOF
יוצרים את המכונות הווירטואליות. ב-2 המכונות הווירטואליות שמשמשות כצמתי אשכול, מחברים דיסק נתונים נוסף ומפעילים את Windows Server Failover Clustering (העברה אוטומטית לגיבוי ב-Windows Server) על ידי הגדרת מפתח המטא-נתונים
enable-wsfcלערךtrue.REGION=$(gcloud config get-value compute/region) ZONE1=$(gcloud config get-value compute/zone) ZONE2=$(gcloud config get-value compute/zone) ZONE3=$(gcloud config get-value compute/zone) PD_SIZE=200 MACHINE_TYPE=n2-standard-8 gcloud compute instances create node-1 \ --zone $ZONE1 \ --machine-type $MACHINE_TYPE \ --subnet $SUBNET_NAME \ --image-family sql-ent-2022-win-2022 \ --image-project windows-sql-cloud \ --tags wsfc,wsfc-node \ --boot-disk-size 50 \ --boot-disk-type pd-ssd \ --boot-disk-device-name "node-1" \ --create-disk=name=node-1-datadisk,size=$PD_SIZE,type=pd-ssd,auto-delete=no \ --metadata enable-wsfc=true \ --metadata-from-file=sysprep-specialize-script-ps1=specialize-node.ps1 gcloud compute instances create node-2 \ --zone $ZONE2 \ --machine-type $MACHINE_TYPE \ --subnet $SUBNET_NAME \ --image-family sql-ent-2022-win-2022 \ --image-project windows-sql-cloud \ --tags wsfc,wsfc-node \ --boot-disk-size 50 \ --boot-disk-type pd-ssd \ --boot-disk-device-name "node-2" \ --create-disk=name=node-2-datadisk,size=$PD_SIZE,type=pd-ssd,auto-delete=no \ --metadata enable-wsfc=true \ --metadata-from-file=sysprep-specialize-script-ps1=specialize-node.ps1 gcloud compute instances create "witness" \ --zone $ZONE3 \ --machine-type n2-standard-2 \ --subnet $SUBNET_NAME \ --image-family=windows-2022 \ --image-project=windows-cloud \ --tags wsfc \ --boot-disk-size 50 \ --boot-disk-type pd-ssd \ --metadata sysprep-specialize-script-ps1="add-windowsfeature FS-FileServer"
כדי לצרף את 3 המכונות הווירטואליות ל-Active Directory, מבצעים את הפעולות הבאות לכל אחת מ-3 המכונות הווירטואליות.
כדי לעקוב אחרי תהליך האתחול של המכונה הווירטואלית, אפשר לצפות בפלט של היציאה הטורית שלה.
gcloud compute instances tail-serial-port-output
NAMEמחליפים את
NAMEבשם של מופע המכונה הווירטואלית.מחכים כ-3 דקות עד שרואים את הפלט
Instance setup finished, ואז מקישים על Ctrl+C. בשלב הזה, מופע המכונה הווירטואלית מוכן לשימוש.יוצרים שם משתמש וסיסמה למכונה הווירטואלית.
מתחברים למכונה הווירטואלית באמצעות שולחן עבודה מרוחק ונכנסים באמצעות שם המשתמש והסיסמה שנוצרו בשלב הקודם.
לוחצים לחיצה ימנית על Start (או מקישים על Win+X) ואז לוחצים על Windows PowerShell (Admin).
- לוחצים על כן כדי לאשר את ההודעה על העלאת הרשאות.
מצטרפים לדומיין של Active Directory במחשב ומפעילים אותו מחדש.
Add-Computer -Domain
DOMAIN -Restartמחליפים את
DOMAINבשם ה-DNS של דומיין Active Directory.מזינים את פרטי הכניסה לחשבון שיש לו הרשאות להצטרף למכונה וירטואלית בדומיין. ממתינים כדקה עד שההפעלה מחדש תסתיים.