* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Javier Villegas – DBA | MCP | MCTS
Survey
Document related concepts
Serializability wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Oracle Database wikipedia , lookup
Concurrency control wikipedia , lookup
Microsoft Access wikipedia , lookup
Tandem Computers wikipedia , lookup
Team Foundation Server wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Database model wikipedia , lookup
Clusterpoint wikipedia , lookup
Relational model wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Transcript
SQL Advanced Monitoring Using DMV, Extended Events and Service Broker • Javier Villegas – DBA | MCP | MCTS Speaker Bio Picture Here Javier Villegas Buenos Aires, Argentina. Database Administrator Since 1997 – SQL 6.0 -> SQL 2016 MCP - MCTS DBA at Mediterranean Shipping Company @javier_vill Since 2006 https://ar.linkedin.com/in/javiervillegas PASS Member Since 2008 http://sql-javier-villegas.blogspot.com.ar/ 2 Agenda Analyzing SQL activity Continuous monitoring with Extended Events (XEvents) Proactive monitoring(DMV / Powershell) Auditing using Service Broker 3 Analyzing SQL Server Activity dbo.SP_DBA_CurrentlyExec http://1drv.ms/1j9es6f • Allow us to quickly see all the SQL Activity • Each row represents an active sessions • We can see below: • SPID, CPU usage, Status, Start Time, Elapsed time, Read/Write times, SQL Statement, Database name and it’s transaction log usage, Object Name, Wait Stat, Login, Host and Application name • If detects a blocking situation it will show a second result set with all the sessions involved • Useful to quickly detect performance problems 4 dbo.SP_DBA_CurrentlyExec Example Blocks 5 5 dbo.SP_DBA_CurrentlyExec dbo.SP_DBA_CurrentlyExec @info=1 dbo.SP_DBA_CurrentlyExec @Filter_Name=‘App_Name’, @Filter_Value=‘SSIS’ dbo.SP_DBA_CurrentlyExec @Filter_Name=‘Host_Name’, @Filter_Value=‘WORKSTS01’ 6 6 dbo.SP_WhoIsActive 7 7 sp_server_diagnostics • Captures diagnostic information and health data from SQL to detect possible system failures. • This process is running in background constantly and periodically updates the results for the output 8 8 sp_server_diagnostics • Create_Time Timestamp • Component_Type Indicates whether the row contains information for the SQL Server instance level component or for an AlwaysOn availability group • Component_Name system , resource , query_processing , io_subsystem , events , <name of the availability group> • State 0, 1, 2 or 3 • State_Desc “Unknown”, “Clean”, “Warning”, “Error” • Data XML 9 9 sp_server_diagnostics • System CPU, Dumps, Pages, etc. • Resource Memory • Query_processing Tasks, Wait Stats, bloques, etc. • IO_subsystem I/O info • Events Server events • Availability Group 10 10 sp_server_diagnostics Examples 11 11 Analyzing SQL Server Activity Other Tools • Performance Monitor • Activity Monitor • SQL Server Performance Dashboard https://www.microsoft.com/en-us/download/details.aspx?id=29063 • SQL Profiler * • Extended Events 12 12 Continuous monitoring with Extended Events • Extended Events • • • • • • General events control system Correlates database and operating system events Follow-up tool(Performance Monitor / SQL Trace) Configurable with T-SQL Useful to troubleshoot without performance impact (minimal extra load) Collects data from: • • • • • I/O Waits Query Parameters Execution Plans Lock 13 13 Continuous monitoring with Extended Events • Extended Events - Components • Session • Definition of what is going to collected as well as when to start and where to store the collected data • Target • Memory (Ring Buffer) • File • Package • Logical containers • SQLOS, SQLSERVER, SecAudit, SQLCLR, etc. • Events • Data collection 14 14 Continuous monitoring with Extended Events • Extended Events • We can collect same events as with SQL Profiler (Even more since MS keep updating them) • Lighter than SQL Profiler. • Easy to work with (T-SQL , XML) 15 15 DEMO • Analyzing SQL Server Activity • SP_DBA_CurrentlyExec • SP_Server_Diagnostics • Extended Events • SQL Errors • Deadlocks • Long running SQL Statements 16 16 Proactive monitoring(DMV / Powershell) • Continuously collecting key data and vital signs from the SQL Instance • • • • • • • • • • SQL Server and Windows Version and Edition MAXDOP Cluster Database Mirroring/AlwaysOn Network Active Transactions Transactions per second Active connections Performance Monitor counters related to I/O using PowerShell I/O Latency 17 17 Proactive monitoring(DMV / Powershell) • Also… • SQL Job running every minute that perform below tasks • Runs “currently executing”. Storing the results just if detects blocks or if there is an statement running for over X minutes • Sends email with the blocking reports • The table used to keep data from “Currently Executing” is very useful when we have to investigate performance issues from the past • Check transaction log usage for all the databases (Sends emails with reports) • Disks Usage Used vs Free Space (Sends email when there is less than 1 GB or 7% from total – This can be configurable) • Detects open transactions for more than X minutes • Detects SQL Dumps • Detects critical errors from SQL Error Log • Disks Usage and performance info using PerfMon • Disks latencies reports 18 18 Auditing • We can create a system using Service Broker to help us to audit objects manipulation within an user database • Table with rows identifying every CREATE , DROP or ALTER • Each row contains below: • Event Timestamp • Event type • • • • • • • CREATE_PROCEDURE, DROP_TABLE, etc. Login used for the event Schema and object name Object type Session ID for the event HostName (*) XML with the details 19 19 Proactive monitoring(DMV / Powershell) 20 20 Proactive monitoring(DMV / Powershell) 21 21 Proactive monitoring(DMV / Powershell) 22 22 Proactive monitoring(DMV / Powershell) 23 23 Proactive monitoring(DMV / Powershell) 24 24 DEMO • Proactive monitoring • Audit 25 25 Questions? @javier_vill https://ar.linkedin.com/in/javiervillegas http://sql-javier-villegas.blogspot.com.ar/