Bài giảng Kiến trúc cài đặt cơ sở dữ liệu - Chương 4 Mirroring và log shipping. Chương này trình bày những nội dung chính sau: Khái quát về mirroring, log shipping, kết hợp giữa log shipping và mirroring. Mời các bạn cùng tham khảo.
GV Phi Loan – FIT - UIH N i dung •K ̀ ̀ ̀mirroring –C ̀ ̀ ̀ nh – C ̀ nh mirroring –G ̀ ̀ ̀ ̀ a mirroring • Log shipping •K ̀ ̀ ̀ GV Phi Loan – FIT - UIH ̀ ̀ ̀mirroring High Availability Solutions •C ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ t GV Phi Loan – FIT - UIH ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ C ̀ •́ ̀ p High Availability O ̀F ̀C ̀SQL Server 2012) • Database mirroring • Log shipping GV Phi Loan – FIT - UIH ̀I ̀ ̀ C ̀ ̀ ̀ p • M ̀DB̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀log shipping • Đ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ u destination servers –N ̀ ̀ ̀ ̀ ̀ t ̀ –N ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ i database mirroring GV Phi Loan – FIT - UIH ̀DB ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ Database mirroring • D ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀C̀DL ̀ ̀ ̀ C̀DL̀ ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ng • D ̀ ̀ ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ C̀DL̀ ̀ ̀C̀DL̀ ̀ ̀ ng GV Phi Loan – FIT - UIH ̀ L ̀ ̀ a mirroring • T ̀ ̀ ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ̀ ̀ a CSDL • C ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ̀ ̀ ̀̀QL̀̀ ̀ ̀ ̀ ̀ ̀̀QL̀ ̀ ̀ ̀C ̀ ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ̀ nh • C ̀ ̀ ̀ ̀ ̀ ̀C̀DL̀ ̀ ̀HD̀ ̀̀Ẁ ̀ p GV Phi Loan – FIT - UIH L ̀ ̀ a mirroring •C ̀ ̀ ̀ ̀ GV Phi Loan – FIT - UIH ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ - ̀ ̀ ̀ ̀HD̀ ̀ ̀ ̀ ̀ ̀ c N ̀ ̀ a mirroring • C ̀C̀DL̀ ̀ ̀ ̀ ̀ • C ̀C̀DL̀ ̀ ̀ ̀ ̀ mirror • M ̀ ̀ ̀ ̀ ̀ ̀ c CSDL • M ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀C ̀ ̀ ̀C̀DL̀ ̀̀̀Ì̀ ̀ ̀ ̀ mirror • M ̀ ̀ ̀ ̀ ̀ ̀ C̀DL̀ ̀M ̀C̀DL̀ ̀ GV Phi Loan – FIT - UIH ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ mirror ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀C̀DL̀ ̀ ̀ ̀ ̀ ng tay CSDL ̀ ̀ ̀ ̀ ̀ ̀1 CSDL mirror ̀ ̀ N ̀ ̀ a mirroring • C̀DL̀ ̀ ̀ ̀ • K ̀C̀DL̀ ̀ ̀ ̀ ̀ ̀ ̀C̀DL̀ c GV Phi Loan – FIT - UIH ̀ ̀ ̀C̀DL̀ nh ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ 10 C ̀ ̀ • C ̀ ̀ c lop shipping ̀ ̀ ̀ ̀ ̀ ̀ ̀C ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀̀ ̀ ̀ ̀ ̀ c copy secondary server • T ̀ ̀D ̀ ̀ ̀ ̀H ̀ ̀ c (job) secondary server: –C ̀ ̀ destination –L ̀̀ ̀ ̀ ̀ y GV Phi Loan – FIT - UIH ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀T ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀̀QL̀̀ ̀ ̀ ̀ o folder ̀ ̀ ̀ ̀ ̀ ̀̀ ̀ ̀ ̀ C ̀ ̀ c lop shipping • M ̀ ̀̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀full hay bulk-logged • E ̀ ̀̀QL̀̀ ̀ ̀ ̀ ̀Enterprise, Standard, hay Workgroup • N ̀ ̀ ̀ ̀ ̀ ̀̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ y • N ̀DB̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀NO‘ECOVE‘Ỳ ̀ ̀T́NDBỲ ̀ ̀ ̀ ̀ ̀ p restore transaction log) GV Phi Loan – FIT - UIH Configuring log shipping •H ̀ ̀ p: – D ng SQL Server Management Studio – D ng system stored procedures GV Phi Loan – FIT - UIH Configuring log shipping using Management Studio T P ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀̀DB̀ nlog shipping ̀O ̀ ̀ ̀ ̀ ̀ ̀ ̀DB ̀ ̀ ̀Full hay Bulk- logged ̀ ̀T ̀L ̀̀ ̀ ̀ u checkbox Enable this as a primary database in a log shipping configuration GV Phi Loan – FIT - UIH Configuring log shipping using Management Studio N ̀ ̀ ̀B ̀̀ ̀ nh cho log shipping: – Đ – ̀ server N ̀ ̀ ̀ GV Phi Loan – FIT - UIH ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ c copy sang secondary ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ y ̀ ̀ ̀ GV Phi Loan – FIT - UIH Configuring log shipping using Management Studio L ̀ ̀ ̀ ̀ T ̀ ̀ – C GV Phi Loan – FIT - UIH ̀ ̀̀ ̀ ̀ ̀ ̀̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀̀ ̀ ̀ ̀ ̀ ̀ n) ̀ ̀ ̀ ̀ ̀ ̀ c secondary server ̀ ̀ ̀ ̀ ̀ ̀secondary DB GV Phi Loan – FIT - UIH C ̀ ̀ ̀ ̀ o secondary DB • Đ ̀ ̀DB̀ ̀ ̀ Management Studio restore : – H ̀ ̀ ̀̀ ̀ ̀ ̀ ̀trên secondary server –H ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ‘ ̀O ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀log • N ̀DB̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ N ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀DB ̀ ̀ ̀ ̀ ̀ ̀DB̀ ̀ ̀ ̀ c GV Phi Loan – FIT - UIH T o monitor server •̀ –N –N ̀ ̀ ̀ ̀DB ̀ ̀ ̀ o monitor server ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ c ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ c GV Phi Loan – FIT - UIH ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ Configuring log shipping using Transact-SQL • T ̀ ̀ ̀ ̀ primary server: ̀ ̀ ̀ ̀ ng sau – master.dbo.sp_add_log_shipping_primary_dat abase – msdb.dbo.sp_add_schedule – msdb.dbo.sp_attach_schedule – msdb.dbo.sp_update_job – master.dbo.sp_add_log_shipping_primary_sec ondary GV Phi Loan – FIT - UIH Configuring log shipping using Transact-SQL • T – – – – – – – – ̀ ̀ ̀ ̀ ̀ ̀ ng sau secondary server: master.dbo.sp_add_log_shipping_secondary_primary msdb.dbo.sp_add_schedule msdb.dbo.sp_attach_schedule msdb.dbo.sp_add_schedule msdb.dbo.sp_attach_schedule master.dbo.sp_and_log_shipping_secondary_database msdb.dbo.sp_update_job msdb.dbo.sp_update_job GV Phi Loan – FIT - UIH V̀ : Typical Log Shipping Configuration GV Phi Loan – FIT - UIH V̀ : Typical Log Shipping Configuration • The primary server instance runs the backup job to back up the transaction log on the primary database, then places the log backup into a primary log-backup file, which it sends to the shared backup folder • Each of the three secondary server instances runs its own copy job to copy the primary log-backup file to its own local destination folder • Each secondary server instance runs its own restore job to restore the log backup from the local destination folder onto the local secondary database GV Phi Loan – FIT - UIH K ̀ ̀L • DB̀ ̀ ̀ ̀ ̀ ̀ ̀Mirroring ̀ ̀ ̀ ̀DB̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ i •M ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ o: synchronous hay asynchronous GV Phi Loan – FIT - UIH ̀ ̀ ... Database_Name, mirroring_ state_desc, mirroring_ role_desc, mirroring_ safety_level_desc, mirroring_ partner_name, mirroring_ witness_name, mirroring_ witness_state_desc FROM sys.database _mirroring WHERE mirroring_ state...N i dung •K ̀ ̀ ? ?mirroring –C ̀ ̀ ̀ nh – C ̀ nh mirroring –G ̀ ̀ ̀ ̀ a mirroring • Log shipping •K ̀ ̀ ̀ GV Phi Loan – FIT - UIH ̀ ̀ ? ?mirroring High Availability Solutions... mirroring_ state IS NOT NULL; GV Phi Loan – FIT - UIH View sys.database _mirroring GV Phi Loan – FIT - UIH G ̀ •C ̀ ̀ CSDL ̀ c mirroring CSDL ̀ ̀ ̀ ̀ c mirroring – Database Mirroring Monitor – System Monitor