iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 24
0
Security

資安動手做系列 第 24

SQL-2

  • 分享至 

  • xImage
  •  

Google MSSQL LAB 找到 Hands-on Labs 這個連結,搜尋 always on有兩種作業系統可選
https://www.microsoft.com/handsonlabs/SelfPacedLabs
https://ithelp.ithome.com.tw/upload/images/20181030/20077752wnd8G5v8vP.jpg

開啟後右邊可以選擇虛機,帳密顯示在旁邊
https://ithelp.ithome.com.tw/upload/images/20181030/200777526FlwyZNQp6.jpg

依照PDF教學架構如下
https://ithelp.ithome.com.tw/upload/images/20181030/200777526Eud11D4WI.jpg

先連至Domain Controller,使用SSMS連WIN-AGNODE01
https://ithelp.ithome.com.tw/upload/images/20181030/20077752CQk3MpbN7Q.jpg
建立Abailability Group
https://ithelp.ithome.com.tw/upload/images/20181030/20077752OZ1M7GPEMg.jpg
照著精靈 =>選Windows Server Failover Cluster
https://ithelp.ithome.com.tw/upload/images/20181030/20077752AP2Aycm5QI.jpg
選擇Databases加入Group
https://ithelp.ithome.com.tw/upload/images/20181030/20077752PQbA3yeErY.jpg
建立副本(replicas)
https://ithelp.ithome.com.tw/upload/images/20181030/20077752dB6cbv6tWS.jpg
選Add將02,03加入
https://ithelp.ithome.com.tw/upload/images/20181030/20077752mGcL4UdJOe.jpg
將Automatic Failover勾選, Availability Mode選Synchronous commit, Readable Secondary選Yes
https://ithelp.ithome.com.tw/upload/images/20181030/200777523jYYvkZzW7.jpg
Backup Preferences 副本的備份優先
https://ithelp.ithome.com.tw/upload/images/20181030/20077752f70pUiaqoC.jpg
下一步選自動
https://ithelp.ithome.com.tw/upload/images/20181030/20077752VQqhOZsps5.jpg
檢查,listener configuration功能之前沒勾選,這個教學再後面建完再來做
https://ithelp.ithome.com.tw/upload/images/20181030/20077752FLmHPNIaIz.jpg
建好後,右鍵選show Dashboard
https://ithelp.ithome.com.tw/upload/images/20181030/20077752zXmb6cMvpl.jpg
服務狀態
https://ithelp.ithome.com.tw/upload/images/20181030/20077752RTKBTl5vnk.jpg

建立之前沒做的listener,點選Add Listener
https://ithelp.ithome.com.tw/upload/images/20181030/20077752hXflGqNTzw.jpg
依步驟建立1433偵測
https://ithelp.ithome.com.tw/upload/images/20181030/20077752ltPmrzLgsb.jpg
完成後在Availability Group Listeners看到剛建立的監控
https://ithelp.ithome.com.tw/upload/images/20181030/20077752X298vCTgbg.jpg
DNS增加前面步驟的IP
https://ithelp.ithome.com.tw/upload/images/20181030/20077752uxzS9SUWxn.jpg

DEMO

來開始測試
開visual studio code 選open folder 到C:\HOL Files\AlwaysonAg\MyExpense.Web
https://ithelp.ithome.com.tw/upload/images/20181030/200777520cGj7sg4zY.jpg
CTRL+SHIFT+P
Tasks: Run Task
編譯好後到Server>Server.config.js改一下DB的DNS
https://ithelp.ithome.com.tw/upload/images/20181030/20077752PdrbzCrV7O.jpg
按F5執行,網頁開8000 port
https://ithelp.ithome.com.tw/upload/images/20181030/20077752rz0vmrrxRw.jpg
有數字表示從DB撈取資料成功
https://ithelp.ithome.com.tw/upload/images/20181030/20077752tkuVomw8xL.jpg

手動failover

右鍵Connect到win-agnode03(確保進到03,可以Disconnect01)點New Query,輸入指令
指令意思:將MyExpenseAG可用性組故障轉移到已連接的輔助節點

ALTER AVAILABILITY GROUP MyExpenseAG FAILOVER;
GO

https://ithelp.ithome.com.tw/upload/images/20181030/20077752jb2z9UUM9W.jpg
03轉成Primary,回去刷新網頁確定可行
https://ithelp.ithome.com.tw/upload/images/20181030/20077752N4Gyklvfww.jpg

最後PDF教學手冊沒寫,不過當然還是要測試一下斷網~
把01跟03的網路關掉,02轉成primary,網頁可以正常查詢
https://ithelp.ithome.com.tw/upload/images/20181030/20077752WVSJyKhRG6.jpg

再把02也關掉,做到這邊剛好到2個小時的Lab時間,被斷掉了...
https://ithelp.ithome.com.tw/upload/images/20181030/20077752TogaebEfQn.jpg

必要條件、限制和建議 - AlwaysOn 可用性群組
https://docs.microsoft.com/zh-tw/sql/database-engine/availability-groups/windows/prereqs-restrictions-recommendations-always-on-availability?view=sql-server-2017
可用性模式 (AlwaysOn 可用性群組)
https://docs.microsoft.com/zh-tw/sql/database-engine/availability-groups/windows/availability-modes-always-on-availability-groups?view=sql-server-2017
容錯移轉及容錯移轉模式 (AlwaysOn 可用性群組)
https://docs.microsoft.com/zh-tw/sql/database-engine/availability-groups/windows/failover-and-failover-modes-always-on-availability-groups?view=sql-server-2017
執行可用性群組的強制手動容錯移轉 (SQL Server)
https://docs.microsoft.com/zh-tw/sql/database-engine/availability-groups/windows/perform-a-forced-manual-failover-of-an-availability-group-sql-server?view=sql-server-2017
从0开始搭建SQL Server AlwaysOn
http://www.cnblogs.com/lyhabc/p/4678330.html
基於SQL Server AlwaysOn跨機房切換項目
https://kknews.cc/zh-tw/tech/jv442ne.html


上一篇
23. SQL-1
下一篇
SQL-3
系列文
資安動手做34
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言