Automating SQL Server Management

Slides:



Advertisements
Similar presentations
Week 6: Chapter 6 Agenda Automation of SQL Server tasks using: SQL Server Agent Scheduling Scripting Technologies.
Advertisements

Module 5: Performing Administrative Tasks. Overview Configuration Tasks Routine SQL Server Administrative Tasks Automating Routine Maintenance Tasks Creating.
Module 20 Troubleshooting Common SQL Server 2008 R2 Administrative Issues.
Module 5: Creating and Configuring Group Policy
AGENDA Tools used in SQL Server 2000 Graphical BOL Enterprise Manager Service Manager CLI Query Analyzer OSQL BCP.
1 Chapter Overview Transferring and Transforming Data Introducing Microsoft Data Transformation Services (DTS) Transferring and Transforming Data with.
Configuring Task Scheduler Lesson 9. Skills Matrix Technology SkillObjective Domain SkillDomain # Understanding Task Scheduler Configure and manage the.
Today’s Agenda Chapter 12 Admin Tasks Chapter 13 Automating Admin Tasks.
Module 13 Automating SQL Server 2008 R2 Management.
Overview What is SQL Server? Creating databases Administration Security Backup.
Module 7: Fundamentals of Administering Windows Server 2008.
Informix IDS Administration with the New Server Studio 4.0 By Lester Knutsen My experience with the beta of Server Studio and the new Informix database.
Learningcomputer.com SQL Server 2008 – Administration, Maintenance and Job Automation.
IT 456 Seminar 5 Dr Jeffrey A Robinson. Overview of Course Week 1 – Introduction Week 2 – Installation of SQL and management Tools Week 3 - Creating and.
Module 14 Configuring Security for SQL Server Agent.
Module 6: Configuring User Environments Using Group Policy.
Module 9 Configuring Messaging Policy and Compliance.
Module 1: Exploring Replication. Overview Understanding SQL Server Replication Setting Up Replication Understanding Agents in Replication Securing Replication.
Module 16: Performing Ongoing Database Maintenance
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
Module 15 Monitoring SQL Server 2008 R2 with Alerts and Notifications.
Overview Managing a DHCP Database Monitoring DHCP
Module 3 Managing Recipient Objects. Module Overview Managing Mailboxes Managing Other Recipients Configuring Address Policies Configuring Address.
Module 5: Creating and Configuring Group Policies.
1 Chapter Overview Defining Operators Creating Jobs Configuring Alerts Creating a Database Maintenance Plan Creating Multiserver Jobs.
Module 4 Planning for Group Policy. Module Overview Planning Group Policy Application Planning Group Policy Processing Planning the Management of Group.
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
Module 1 Introduction to SQL Server® 2008 R2 and its Toolset.
Maintenance Practices. Goal  Automate the necessary DBA chores to put organizations on the path of having healthier, consistent and more trustworthy.
Microsoft ® Official Course Module 6 Managing Software Distribution and Deployment by Using Packages and Programs.
SSMS SQL Server Management System. SQL Server Microsoft SQL Server is a Relational Database Management System (RDBMS) Relational Database Management System.
1 Chapter Overview Using Standby Servers Using Failover Clustering.
Introduction to SQL Server  Working with MS SQL Server and SQL Server Management Studio.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
Software Version: DSS ver up45 Presentation updated: September 2010 Backup of data residing on Open-E Data Storage Software with Backup Exec.
SQL Database Management
The Consolidation Process The Intercompany Integration Solution for SAP Business One Version 2.0 for SAP Business One 9.1 Welcome to the course on the.
Core LIMS Training: Project Management
Automating Business Processes
Installation The Intercompany Integration Solution for SAP Business One Version 2.0 for SAP Business One 9.1 Welcome to the course on the installation.
Project Management: Messages
SQL Replication for RCSQL 4.5
Creating Oracle Business Intelligence Interactive Dashboards
Working in the Forms Developer Environment
Implementing Update Management
Introduction to Microsoft SQL Server 2016
Implementing an Azure SQL Data Warehouse
Deploying and Configuring SSIS Packages
20761A 10: Using Subqueries Module 10   Using Subqueries.
Using Window Ranking, Offset, and Aggregate Functions
Installation The Intercompany Integration Solution for SAP Business One Version 2.0 for SAP Business One 9.1 Welcome to the course on the installation.
The Consolidation Process The Intercompany Integration Solution for SAP Business One Version 2.0 for SAP Business One 9.1 Welcome to the course on the.
20761B 12: Using Set Operators Module 12   Using Set Operators.
Global Catalog and Flexible Single Master Operations (FSMO) Roles
Planning High Availability and Disaster Recovery
Module 13: Creating Data Visualizations with Power View
Module 12: Implementing an Analysis Services Tabular Data Model
Using JDeveloper.
Module 7: Working with Measures and Measure Groups
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Module 3: Supporting Self Service Reporting
Why Background Processing?
Introduction to Medisoft
Using DML to Modify Data
Michelle Haarhues Keeping up with SSMS.
Ch 10. Maintaining and Automating SQL Server
Module 5: Creating Multidimensional Databases
Module 4: Managing Report Execution and Delivery
Designing and Implementing User- Defined Functions
Module 14: Performing Predictive Analysis with Data Mining
Presentation transcript:

Automating SQL Server Management Module 8 The 20764A-MIA-SQL virtual machine used in the lab for this module includes software services that can take a while to start. For the best experience, have students start the 20764A-MIA-DC and 20764A-MIA- SQL virtual machines at the beginning of the module so that the services are ready before they start the lab. Automating SQL Server Management

Multi-Server Management Module Overview 8: Automating SQL Server Management Multi-Server Management  

Lesson 1: Automating SQL Server Management Demonstration: SQL Server Agent  

Benefits of Automating SQL Server Management Reduce administrative workload by automating and scheduling regular tasks Execute routine tasks reliably and consistently Proactive management: Monitor performance Recognize and respond to potential problems Talk the students through the benefits of automation, using the examples and scenarios in the student notes.

Available Options for Automating SQL Server Management SQL Server Agent Maintenance Plans PowerShell System Center Operations Manager Explain that there are many ways to automate the management of SQL Server. In this module, you will be focusing on SQL Server Agent as the primary method of automation.

Overview of SQL Server Agent 8: Automating SQL Server Management Runs as a Windows Service By default this is set to be manually started Jobs are able to perform a number of tasks Schedules can be defined to run one or more jobs Alerts can be used to respond to system events Operators can be notified by jobs or alerts  

Demonstration: SQL Server Agent 8: Automating SQL Server Management In this demonstration, you will see how to: Create a simple job, and step Run a job, and review the output SQL Server Agent should be running in the virtual machines by default; if you are unable to expand it, click Refresh in the Object Explorer. Preparation Steps Start the 20764A-MIA-DC and 20764A-MIA-SQL virtual machines. Demonstration Steps Create a Job Ensure that the 20764A-MIA-DC and 20764A-MIA-SQL virtual machines are running, and then log on to 20764A-MIA-SQL as AdventureWorks\Student with the password Pa$$w0rd. In Windows Explorer, navigate to D:\Demofiles\Mod08, right-click Setup.cmd, and then click Run as administrator. In the User Account Control dialog box, click Yes. On the taskbar, click Microsoft SQL Server Management Studio. In the Connect to Server dialog box, in Server name box, type MIA-SQL and then click Connect. In Object Explorer, expand SQL Server Agent, and then expand Jobs. Note that there are existing jobs on the server. Right-click the Jobs folder, click New Job. In the New Job dialog box, in the Name box, type Manual AdventureWorks Backup, and in the Category list, select Database Maintenance. On the Steps page, click New. In the New Job Step dialog box, in the Step name box, type Backup AdventureWorks, and in the Database list, select AdventureWorks. (More notes on the next slide)

Lesson 2: Working with SQL Server Agent 8: Automating SQL Server Management Demonstration: Scripting Jobs  

Defining Jobs, Job Types, and Job Categories 8: Automating SQL Server Management Jobs consist of a series of steps Job step types include: Command-line script, batch of commands or application Transact-SQL statement PowerShell script SSIS and SSAS commands and queries Jobs can be assigned to categories Explain that a job is a specified series of operations performed sequentially by SQL Server Agent. Talk through the job step types on the slide, and then the code sample in the student manual.

Write to Application Log Creating Job Steps 8: Automating SQL Server Management Backup Database Transfer Data Execute App Success Job Succeeded Notify Operator Job Failed Write to Application Log Failed Job Started Explain how a job consists of individual steps that can be of different types. Review the arguments in the table and show the same properties of a job step in SSMS. Discuss the graphic shown on the slide associated with this topic, noting the different actions taken, depending on the step outcome.

Scheduling Jobs for Execution 20764A Scheduling Jobs for Execution 8: Automating SQL Server Management Recurrence: One time When SQL Server Agent starts Whenever the CPU is idle One job can have multiple schedules Multiple jobs can share one schedule Explain the different types of schedules and point out that they can be shared. Use the graphic on the slide to explain that one job may have more than one schedule. Point out that only one instance of a job can run at any one time.

Script a database task to a job Generate scripts for existing jobs Scripting Jobs 8: Automating SQL Server Management Script a database task to a job Generate scripts for existing jobs  

Demonstration: Scripting Jobs 8: Automating SQL Server Management In this demonstration, you will see how to: Script a task to a job Generate scripts for existing jobs Preparation Steps Complete the previous demonstration. Demonstration Steps Script a Task to a Job In SSMS, in Object Explorer, expand Databases, right-click AdventureWorks, point to Tasks, and then click Back Up. In the Back Up Database - AdventureWorks dialog box, in the Destination section, click the existing backup destination, and then click Remove. Click Add and in the Select Backup Destination dialog box, in the File name box, type D:\Demofiles\Mod08\Backups\AdventureWorksScript.bak, and then click OK. In the Back Up Database - AdventureWorks dialog box, on the toolbar, in the Script drop-down list, select Script Action to Job. In the New Job dialog box, on the General page, note the default name for the job (Back Up Database - AdventureWorks). On the Steps page, note that the job includes one Transact-SQL step named 1. On the Schedules page, click New. In the New Job Schedule dialog box, in the Name box, type Week Days. In the Frequency section, select Monday, Tuesday, Wednesday, Thursday, and Friday, and then click OK. In the New Job dialog box, click OK. In the Back Up Database - AdventureWorks dialog box, click Cancel so that the job is saved, but not yet run. Verify that the job appears in the Jobs folder in Object Explorer. (More notes on the next slide)

Lesson 3: Managing SQL Server Agent Jobs 8: Automating SQL Server Management Demonstration: Viewing Job History and Resolving Failed Jobs  

20764A Viewing Job History 8: Automating SQL Server Management Information about job history is written to tables in the msdb database Can be viewed via a Transact-SQL query Can be viewed in SSMS by using the Log File Viewer Optionally the information can be written to log files SSMS also has the Job Activity Monitor that shows the current job activity, and the schedules for active jobs Explain that SQL Server Agent keeps track of job and job step outcomes in system tables in msdb and that writing to the Windows Application and SQL Server log files is an optional extra. Mention that querying the system tables will be discussed in the next topic. Explain that students can configure the retention policy, based on time or size, in the property window of SQL Server Agent.

Querying SQL Server Agent-related System Tables and Views 8: Automating SQL Server Management Configuration and history information is stored in msdb.dbo schema Use history tables to automate collection of job history over several systems The dbo.sysjobhistory table contains a row for each job with a step_id = 0. This contains the result for the whole job Talk students through the example in the student manual, and briefly show the SQL Server Agent Tables (Transact-SQL) page online to detail the variety of tables available. Be sure to point out that the step_id <> 0 limits the result set to the job steps only.

Troubleshooting Failed Jobs 8: Automating SQL Server Management SQL Server Agent status: Is the service account valid? Is the msdb database online? Job history: Job outcome identifies the last step to execute Job step outcome identifies why the step failed Job execution: Is the job enabled? Is the job scheduled? Is the schedule enabled? Access to dependencies: Are all dependent objects available? Talk the students through the key troubleshooting steps for job issues.

Demonstration: Viewing Job History and Resolving Failed Jobs 8: Automating SQL Server Management In this demonstration, you will see how to: Run jobs Troubleshoot a failed job Preparation Steps Complete the previous demonstrations. Demonstration Steps Run Jobs In SQL Server Management Studio, in Object Explorer, right-click Back Up Database – AdventureWorks, and then click Start Job at Step. When the job has completed successfully, click Close. In Object Explorer, right-click Check AdventureWorks DB, and then click Start Job at Step. Note that this job does not start automatically because it has more than one job step. In the Start Job on 'MIA-SQL' dialog box, in the Start execution at step table, click 1, and then click Start. Note that the job fails, and then click Close. Troubleshoot a Failed Job In Object Explorer, right-click Back Up Database – AdventureWorks, and then click View History. In the Log File Viewer - MIA-SQL dialog box, expand the date for the most recent instance of the job, note that all steps succeeded, and then click Close. In Object Explorer, right-click Check AdventureWorks DB, and then click View History. In the Log File Viewer - MIA-SQL dialog box, expand the date for the most recent failed instance of the job, and note that the step 3 failed. Select the step that failed, and in the pane at the bottom of the dialog box, view the message that was returned. You may have to scroll to the bottom. Then click Close. In Object Explorer, double-click Check AdventureWorks DB. In the Job Properties - Check AdventureWorks DB dialog box, on the Steps page, in the Job step list table, select step 3, and then click Edit. (More notes on the next slide)

Lesson 4: Multi-Server Management 8: Automating SQL Server Management Automating Multi-Server Maintenance Question Which of the following statements is false? ( )Option 1: A master server can have multiple target servers. ( )Option 2: A high-load master server won’t have any adverse performance impact by having a number of target servers. ( )Option 3: Each target server can only connect to a single master server. ( )Option 4: Changing the name of a target server requires it to be registered with the master server. Answer (√) Option -2: A high-load master server won’t have any adverse performance impact by having a number of target servers.

Multi-Server Management Concepts 8: Automating SQL Server Management Master server (MSX) Holds central copy of job definitions Distributes jobs to target servers Receives messages and alerts from target servers Target servers (TSX) Assigned to one master server Connect to master server to update schedules of jobs Downloads new jobs from master server  

Considerations for Multi-Server Management 8: Automating SQL Server Management The master server service can impact performance Each target server can link to only one master server Cannot change a target server name while enlisted SQL Server Agent and SQL Server services must use domain accounts  

Demonstration: Configuring Master and Target Servers 8: Automating SQL Server Management In this demonstration, you will see how to: Use the Master Server Wizard Use Transact-SQL to register target servers Emphasize that, to use Transact-SQL to register target servers, the command must be run on the target server’s database engine. Preparation Steps Complete the previous demonstrations. Demonstration Steps Use the Master Server Wizard In SQL Server Management Studio, in Object Explorer, under MIA-SQL, right-click SQL Server Agent, point to Multi Server Administration, and then click Make this a Master. In the Master Server Wizard – MIA-SQL dialog box, on the Welcome to the Master Server Wizard page, click Next. On the Master Server Operator page, in the E-mail address box, type student@adventureworks.com, and then click Next. On the Target Servers page, expand Database Engine, expand Local Server Groups. Click mia-sql\sql2, click the >, and then click Next. In the Checking Server Compatibility dialog box, click Close. On the Master Server Login Credentials page, click Next. On the Complete the Wizard page, click Finish. When configuration is complete, click Close. Use Transact-SQL to Register a Target Server In Object Explorer, on the toolbar, click Connect, and then click Database Engine. In the Connect to Server dialog box, in the Server name list, select MIA-SQL\SQL3, and then click Connect. In Object Explorer, under MIA-SQL\SQL3, expand Databases, expand System Databases, right- click msdb, and then click New Query. (More notes on the next slide)

Running Jobs on Target Servers 8: Automating SQL Server Management Two methods to distribute jobs to target servers Using SSMS, choose the target servers on the Target page Using Transact-SQL command: sp_add_jobserver If jobs are updated they need to be pushed to target servers Transact-SQL command: sp_post_msx_operation Emphasize that if you modify the steps or schedule for a job, you have to post the change to the download list.

Automating Multi-Server Maintenance 8: Automating SQL Server Management Maintenance plans support creating SQL Server Agent jobs that can run on master and target servers The execution and monitoring is all undertaken on the master server The Maintenance Plan Wizard can create simple maintenance plans  

Lab: Automating SQL Server Management Exercise 4: Configure Master and Target Servers Exercise 1: Create a SQL Server Agent Job The HumanResources database must be backed up every day. Additionally, after the backup has been created, the backup file must be copied to a folder, which is automatically replicated to a cloud service for offsite storage of various backup files. Exercise 2: Test a Job You plan to test the new backup job before you schedule it to execute in a production environment. Through the process of testing, you identify a defect in the job. You must resolve the defect and ensure the backup is copied to the correct folder location. Exercise 3: Schedule a Job You have created a job to back up the HumanResources database. Now you must schedule the job to run automatically each day. Exercise 4: Configure Master and Target Servers You have been tasked with backing up all the system databases within your company. You have decided to utilize the ability to create a maintenance plan and run this plan across all the company’s servers. Logon Information Virtual machine: 20764A-MIA-SQL User name: ADVENTUREWORKS\Student Password: Pa$$w0rd Estimated Time: 75 minutes

20764A Lab Scenario 8: Automating SQL Server Management You are a database administrator (DBA) at Adventure Works Cycles, with responsibility for databases on the MIA-SQL instance of SQL Server. Routine tasks that must be performed on this instance have previously been performed manually, but you now plan to automate these tasks using SQL Server Agent.

Module Review and Takeaways 8: Automating SQL Server Management Best Practice Best Practice: When using a large number of target servers, avoid defining your master server on a production server because the target server traffic may impact performance on the production server.