1 / 26

DBA 101: 如何做好 DBA 的日常管理工作 (DBA 的基本功 )

DBA 101: 如何做好 DBA 的日常管理工作 (DBA 的基本功 ). 錢曉明 資策會 資深講師 台灣微軟 資深講師. 議程. 資料庫自動化管理組態 設定操作員 設定 Database Mail 建立作業 DBA 的日常管理工作 資料庫維護計畫 建立警示 SQL Server Agent 安全性設定. 資料庫自動化管理. 哪些事件可設定自動化. 定期發生事件或需定期執行工作 如索引維護,資料庫及交易記錄檔備份,系統 DB 備份, 匯入匯出資料,儲存歷史資料。 雖非定期但經常發生事件 交易記錄檔達到某種比例發出警示,不常用的資料表在

ross
Download Presentation

DBA 101: 如何做好 DBA 的日常管理工作 (DBA 的基本功 )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DBA 101: 如何做好DBA 的日常管理工作(DBA 的基本功) 錢曉明 資策會 資深講師 台灣微軟 資深講師

  2. 議程 • 資料庫自動化管理組態 • 設定操作員 • 設定Database Mail • 建立作業 • DBA 的日常管理工作 • 資料庫維護計畫 • 建立警示 • SQL Server Agent 安全性設定

  3. 資料庫自動化管理 哪些事件可設定自動化 • 定期發生事件或需定期執行工作 • 如索引維護,資料庫及交易記錄檔備份,系統DB備份, • 匯入匯出資料,儲存歷史資料。 • 雖非定期但經常發生事件 • 交易記錄檔達到某種比例發出警示,不常用的資料表在 • 製作月報表前重新整理統計數據 哪些事件不必設定自動化 • 只發生一次的事件 • 要花很長的時間自動化 • 常發生無法預期的狀況的事件

  4. What Is SQL Server Agent? • SQL Server 的原件之一,負責自動化管理工作 • 亦是 Windows Service之一 • 若要啟用SQL Server 的相關自動化管理工作, 如 jobs, alerts等,SQL Server Agent 必須保持啟動狀態

  5. SQL Server Agent 組態 • SQL Server Agent service 啟動設定 • 預設SQL Server Agent service 並未設定為自動啟動 • SQL Server Agent service 帳號 • 必須有啟動Windows服務的權限 • SQL Server Agent service 相依服務 • SQL Server service • 要啟動Net Send 通知,必須啟動Messenger service

  6. 設定操作員 • 可接受通知的個人或群組 • 通知可由 job, job step, 或 alert觸發 • 可透過 e-mail, pagers, 或 netsend 通知 • 可定義保全人員(Fail-safe operator)

  7. 建立操作員

  8. SQL Server Agent Mail • Database Mail • 建立 SMTP E-Mail 帳號 • 建立設定檔(Database MailProfile),並指定為Public Default Profile • 在SQL Server Agent 屬性中的Mail Session 要Enable Mail Profile • 必須是MSDB 中DatabaseMailUserRole群組成員才可傳送Database Mail • SQL Mail • MAPI-based • Uses Microsoft Exchange Server • Included for backward compatibility

  9. 建立 SMTP E-Mail 帳號建立設定檔(Database MailProfile)

  10. 建立作業 (Job) • 可執行一系列、日常例行工作 • 可有 Transact-SQL, command-line application, and ActiveX script 等類型 • 可排程執行一次,多次或手動執行

  11. 建立作業--備份Master Database

  12. DBA 的日常管理工作 • 系統及使用者資料庫備份 • 索引維護 • Database 與 Log 使用空間的調整與監控 • 資料匯入匯出

  13. 建立作業--索引重建

  14. 索引重整(Index Rebuild) • SQL 2005 新增DMF sys.dm_db_index_physical_stats SELECT avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats (DB_ID(), OBJECT_ID(N'NewEmployee'),Null,Null,Null) • 取代DBCC Showcontig (NewEmployee) • 新增大量資料會造成資料碎裂 Insert into NewEmployee SELECT * FROM HumanResources.Employee • 索引重整可消除碎裂,提昇效能 Alter Index EmployeeId on NewEmployee Rebuild

  15. 建立索引重整作業

  16. 資料庫維護計畫 • 協助資料庫管理員輕鬆排定例行管理工作 可一次設定多項維護工作 執行結果存入文字檔或寄送E-Mail • 系統內定工具無法設定之工作,亦可透過客製作業完成 (如壓縮資料庫檔案)

  17. 維護計畫 壓縮資料庫

  18. 建立警示 針對特定事件觸發時,如錯誤代碼,嚴重程度,或效能狀態 通知操作員或執行作業

  19. 建立警示--效能狀態

  20. SQL Server Agent 安全性設定 必須是下列內定群組之一的成員才可建立或執行Job • 存在MSDB資料庫中 • SQLAgentUserRole • SQLAgentReaderRole • SQLAgentOperatorRole 由SQL Server 2000升級的Proxy帳號會改為 • UpgradedProxyAccount

  21. SQL Server Agent內定群組權限繼承關係 • 如非下列三個群組成員登入到SQL Server時,SQL Server Agent 節點不會顯示 • SQLAgentUserRole - 只對該User擁有的Job有權限 • SQLAgentReaderRole - 可察看所有的Job • SQLAgentOperatorRole - 可執行/啟動/停止所有Local Job • 三個Role均無Change Job Ownership權限

  22. SQL Server Agent Proxies(代理帳號) • 非T_SQL Job一定要指定透過代理帳號執行 • 透過 credentials 對應到 Windows 帳號 • 在 credential 註明的帳號一定要有 log on as a batch job使用者權限 • 提供細項管理存取 subsystems權限 • 使用者必須有存取Proxy的權限才可於Job中設定使用Proxy,可對下列三種物件設定存取Proxy的權限 • Logins • Fixed server roles • Database roles in the msdb database

  23. 監控工具 • Job Activity Monitor • Dynamic Management View (DMV) • Event Log • Agent Alerts • Agent Notification

  24. What Is the Job Activity Monitor? • SQL Server Management Studio tool • Allows you to: • Start and stop jobs • View job properties • View the history for a specific job • Refresh the information in the Agent Job Activity grid (manual or automatic)

  25. What Is Activity Monitor? • Graphical views of current user connections and locks • Process Info • Locks by Process • Locks by Object

  26. Job Activity monitor

More Related