Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 47 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
47
Dung lượng
1,45 MB
Nội dung
201 SQL Server Agent runs on any server that is running instances of Microsoft SQL Server 2000 or earlier versions of SQL Server. SQL Server Agent is the service that allows you to automate administrative tasks. As such, you must start the SQL Server Agent service before your local or multiserver administrative tasks can run automatically. SQL Server Agent is also sup- ported on the Microsoft Windows 98 operating system, but SQL Server Agent cannot be used with Windows Authentication when run on Win- dows 98. Windows Authentication can only be used after a login to the Windows 2000 domain. Existing Windows 2000 users and groups are granted access to SQL Server. SQL Server Authentication requires that logins be created in SQL Server, and you must supply the password with the account. More information on Windows and SQL Server Authentication can be found in Chapter 4, “Establishing Login Security.” SQL Server Agent is responsible for: ■■ Running SQL Server tasks scheduled to occur at specific times or intervals (jobs). Introducing the SQL Server Agent Service CHAPTER 9 CHAPTER ■■ Detecting specific conditions for which administrators have defined an action, such as alerting someone through pages or email, or a task that will address the conditions (operators and alerts). ■■ Running replication tasks defined by administrators (replication). SQL Server Agent is similar to an auxiliary operator responsible for han- dling the repetitive tasks and exception-handling conditions defined through the other SQL Server automation components. This chapter first provides a review of the configuration of the SQL Server Agent service account. Then it moves to an overview of jobs, operators, and alerts. This chapter also addresses specific security concerns related to jobs. The chapter then describes the email integration features of SQL Server. Finally, the chapter addresses replication and its security concerns. SQL Server Agent Service Account The SQL Server Agent is started in and runs as a Windows service. This service appears in the list of installed services in the Services dialogue box. The Services dialogue box is available from the Control Panel. The two most important services to Microsoft SQL Server are the SQL Server service and the SQL Server Agent service. The SQL Server service handles all query processing and server configuration. The SQL Server Agent service manages all the automated processes, which can include jobs, operators, alerts, and replication. For Microsoft SQL Server and SQL Server Agent to run as services in Windows, they must be assigned a Windows user account to use when they start up. This account is necessary for the service to log on to the sys- tem. Typically, both SQL Server and SQL Server Agent are assigned the same user account. However, it is possible to customize the settings for each service. You have two choices for the configuration of the service account: the Local System Account and a Domain User Account. For email, replication, and multiserver jobs to function correctly, the SQL Server Agent service must be configured to start with a domain account. The account should be a local administrator on the SQL Server machine, and all instances of SQL Server should be configured to use the same account. More information about the configuration of the SQL Server Agent account is available in Chapter 3, “Exploring Initial Security Parameters.” You configure the properties of the SQL Server Agent service using SQL Server Enterprise Manager. To configure the general properties of the SQL Server Agent service, you should perform the following steps: 202 Chapter 9 1. Open Enterprise Manager. 2. Click to expand your instance of SQL Server. 3. Click to expand the Management container. 4. Right-click the SQL Server Agent and select Properties, as shown in Figure 9.1. 5. Configure the General, Advanced, and Connection tabs as you deem necessary. The Job System tab is described in more detail later in the section Job Security. The options for configuration are detailed next. In the General tab, you can configure the location of the error log file, enable the recording of execution trace messages (for troubleshooting), and enable the error file to be written as a non-Unicode file (resulting in a smaller log file size). Recording of execution trace messages can generate large files. You can also configure a recipient on the network to receive a Net Send pop-up message notification of errors recorded by the SQL Server Agent service. Configuring a mail session for the SQL Server Agent service is covered later in this chapter in the section Setting Up SQLAgentMail. To configure advanced properties of the SQL Server Agent service, click the Advanced tab in the SQL Server Agent Properties dialogue box as shown in Figure 9.2. Figure 9.1 The SQL Server Agent Properties dialogue box allows for the customization of the SQL Server Agent service. Introducing the SQL Server Agent Service 203 Figure 9.2 The Advanced tab of the SQL Server Agent Properties dialogue box provides additional control over the SQL Agent Service. In the Advanced tab, you can configure the SQL Server Agent service to restart automatically if it stops unexpectedly by selecting the Auto Restart SQL Server Agent if It Stops Unexpectedly checkbox. This feature requires local administrator rights by the SQL Server Agent service account (either by granting them to the domain user account or using the local system account). By default, the SQL Server service is configured to restart automatically. In the SQL Server Event Forwarding group box, you can configure the SQL Server Agent service to forward some or all SQL Server events to another server. You can use this feature to enable centralized alert manage- ment for a group of servers. Plan carefully, because this generates addi- tional network traffic and load on the centralized server, and creates a single point of failure. NOTE When configuring SQL Server Event Forwarding, the server you set for messages to be forwarded to must be a registered server in Enterprise Manager. In the Idle CPU Condition group box, you can also define when the processor is considered idle. You define the idle condition by specifying a percentage below which the average processor usage must fall for a defined length of time. This feature requires local administrator rights granted to the SQL Server Agent service account (either by granting them 204 Chapter 9 Figure 9.3 Jobs can be scheduled for a specific time or based on an event such as the SQL Server Agent service starting or the CPU becoming idle. to the domain user account or using the local system account). Idle condi- tions are used to schedule jobs. One of the options for a job schedule is executing the job when the CPU becomes idle, as shown in Figure 9.3. You configure the Connection properties of the SQL Server Agent service by clicking the Connection tab in the SQL Server Agent Properties dialogue box as shown in Figure 9.4. Figure 9.4 The Connection dialogue box is used to bypass the default connection options for the SQL Server Agent. By default the SQL Server Agent connects to another server using the SQL Server service account. Introducing the SQL Server Agent Service 205 By default, the SQL Server Agent service connects to the local SQL Server 2000 instance using the domain user account specified as the service account. However, in the SQL Server Connection group box, you can specify that all connections to the local instance use a SQL Server login account that is a member of the sysadmin server role. You can also modify the login timeout value from the default of 30 seconds. Finally, if you have config- ured nondefault client Net-Libraries, you might need to specify a SQL Server alias that you previously created using the Client Network Utility. More details on aliasing and the Client Network Utility are addressed in Chapter 7, “Implementing Front-End Application Security.” Jobs, Operators, and Alerts SQL Server Agent is a Windows service that executes jobs, notifies opera- tors of actions on the server, and fires alerts. Jobs, alerts, and operators (which are discussed separately in the sections that follow) run in the secu- rity context of the SQL Server Agent service. Additionally, the full integra- tion of these features depends on email integration with Exchange Server or another compatible email system. Jobs SQL Server Agent jobs automate administrative tasks (such as a backup statement) and run them on a recurring basis. You can run a job manually or schedule it to run in response to schedules and alerts. SQL Server jobs are configured as part of the SQL Server Agent. A job can be created to run on the local machine or as a multiserver job, which can include steps that run on multiple machines. To run jobs on multiple servers, you must set up at least one master server and one or more target servers. The master server is responsible for the job configura- tion and the reporting of the success or failure status of the job. Each target server downloads its list of responsibilities from its master server. Each target server runs its own job steps and reports the status back to its mas- ter server. Multiserver jobs are dependent on the SQL Server Agent service on all SQL Servers being configured to start with the same domain user account. Anyone can create a job, but only its owner or members of the sysadmin role can edit a job. More information about job security and configuration is described later in this chapter in the section Job Security. Jobs can easily be created in Enterprise Manager. As you decide on the job you would like to configure, you should consider the following: 206 Chapter 9 ■■ Jobs are made up of steps. Each job can be configured to have one or more steps. Job steps can be Transact-SQL statements, ActiveX Script tasks, replication-related events, and operating system commands. ■■ Each job has an owner. The ownership of the job determines to some extent the security context the job steps will run in. Ownership of jobs is addressed in more detail later in this section. ■■ Jobs can be scheduled. After you create a job, it can be configured to run immediately or scheduled for a specific time or event. ■■ Jobs can notify operators of the resulting status of the action. The operator notification can be through email, pager notification, or Net Send. To create a job for your instance of SQL Server you should perform the following steps: 1. Open Enterprise Manager. 2. Click to expand your instance of SQL Server. 3. Click to expand the Management container. 4. Click to expand SQL Server Agent. 5. Right-click Jobs and select New Job. 6. The New Job Properties dialogue box will appear as shown in Figure 9.5. 7. On the General tab you will need to give the job a name and select its owner. 8. Steps, Schedules, and Notifications can be configured from their appropriate tab. Figure 9.5 New jobs are created and managed from Enterprise Manager. Introducing the SQL Server Agent Service 207 Defining Alerts Alerts are useful in creating a proactive approach to database administra- tion. In far too many cases administrators spend time running around putting out the fires that result as applications that rely on SQL Server fail. Alerts allow the administrator some control over these errors and allow for a configured action based on the error received. Alerts can either be based on errors that have already occurred or they can be created on a system- based performance condition (threshold). Errors and messages, or events, are generated by Microsoft SQL Server and entered into the Microsoft Win- dows application log. SQL Server Agent constantly reads the application log and compares events to alerts that you have defined. If no alert is defined, then no action is taken. The alert can be configured to notify an operator or execute a job. When an error occurs or a threshold is met, you can fire an alert, which in turn executes a job to take an action to respond to the event. For instance, you may want to define an alert that monitors the percentage of log space used on your production database. When a thresh- old is met, such as 75 percent full, the alert is fired. You could then have the alert execute a job that backs up the log. (The backup log statement trun- cates the inactive portion of the log.) This job immediately responds to the alert, thereby avoiding a bigger problem later on. Alerts are also easily configured through Enterprise Manager. To create an alert you should perform the following series of steps: 1. Open Enterprise Manager. 2. Click to expand your instance of SQL Server. 3. Click to expand the Management container. 4. Click to expand SQL Server Agent. 5. Right-click Alerts and select New Alert. 6. The New Alert Properties dialogue box will appear as shown in Figure 9.6. 7. Configure the General tab to include the name, type of alert (event or performance condition), and historical information. 8. Use the Response tab to configure Operator notification and the execution of jobs as a response to the alert. Operators Operators are objects for notification of job status and alert firing. The operator is a representation or a user or group. An operator can be used for three types of notification: 208 Chapter 9 Figure 9.6 New alerts are created from this dialogue box page to act on SQL Server errors or performance conditions. ■■ Email notification depends on the integration of email services. SQL Agent Mail must be configured to use this option. The details of the email configuration are addressed later in this chapter in the section Setting Up SQLAgentMail. ■■ Pager notification depends on pager integration software. SQL Server and Microsoft Exchange Server do not include pager software. If your organization has a pager software solution, this option can be used. ■■ Net Send notifications are pop-up messages that are configured to pop up on the computer screen. They are beneficial because they interrupt whatever the user is doing. They cannot be relied on as the only notification, because if the machine isn’t on or the user isn’t logged on, the message cannot be received. Operators should be configured using Enterprise Manager. To configure an operator, follow these steps: 1. Open Enterprise Manager. 2. Click to expand your instance of SQL Server. 3. Click to expand the Management container. Introducing the SQL Server Agent Service 209 Figure 9.7 Use the New Operator Properties dialogue box to add a new operator to notify of specified alerts or job status. 4. Click to expand SQL Server Agent. 5. Right-click Operators and select New Operator. 6. The New Operator Properties dialogue box will appear as shown in Figure 9.7. 7. Operators must be given a name and email, pager, and Net Send information. NOTE The primary attributes of an operator are name and contact information. It is recommended that you define operators before you define alerts. If operators are set up first, they are visually available in Enterprise Manager when you create the alerts, so notification configuration of alerts is easy. Job Security Using SQL Server Agent, you can create and schedule jobs that automate routine administrative tasks. In this section, you learn to create simple and 210 Chapter 9 [...]... on the local SQL Server 2000 computer and a MAPI messaging profile A MAPI messaging profile requires the use of a domain user account The SQL Server service and SQL Server Agent services should both be configured to use the domain user account In many cases, SQL Mail and SQLAgentMail use the same domain user account for administrative convenience SQL Mail is the mail service of the SQL Server service... control of flow logic SQL Server Agent is responsible for the management and execution of all jobs SQL Server Agent must be running for jobs to execute Jobs can be created on the local server or on one or more target servers in a multiserver administration configuration Types of Job Steps SQL Server 2000 supports jobs containing operating system commands, CmdExec commands, Transact -SQL statements, Microsoft... SQL Server Agent Service Configuration The SQL Server Agent service (SQLServerAgent) at the client should not use the Local System account It should be configured to use a standard domain account The SQLAgent account is the security context under which the Snapshot Agent, Merge Agent, and Distribution Agent are Introducing the SQL Server Agent Service running by default Replication Agents use the SQL. .. communicate with all servers involved in the replication topology One Introducing the SQL Server Agent Service way to test agent connectivity is to log in to the required server and database using SQL Query Analyzer with the same login that the Replication Agent will be using (or typically the login that SQL Server Agent is using) You must be a SQL Server 2000 system administrator to enable the server for replication... Replication Security Issues SECURITY DESCRIPTION Role Requirements By mapping user logins to specific SQL Server 2000 roles, SQL Server 2000 allows users to perform only those replication and database activities authorized for that role Replication grants certain permission to the sysadmin fixed server role, the db_owner fixed database role, the current login, and the public role Connection to Distributor SQL. .. transactional consistency across servers The chapter then describes the log shipping feature of SQL Server 2000 Log shipping is a feature that allows for the creation and maintenance of a read-only standby server Finally this chapter describes the Federated Database Servers feature of SQL Server Federated Database Servers allows you to partition a database 231 232 Chapter 10 across multiple servers to give the... Setting up SQL Mail After configuring and testing the messaging profile for the SQL Server service domain user account, you are ready to set up SQL Mail You configure SQL Mail by following these steps: 1 Open Enterprise Manager 2 Click to expand your instance of SQL Server 217 218 Chapter 9 3 Click to expand the Support Services container 4 Right-click SQL Mail and select Properties The SQL Mail Configuration... locally (on the same server as the Publisher) is common The Distribution Agent is not used at all during merge replication, and the distribution database on the Distributor stores history and miscellaneous information about merge replication Security Considerations When considering security in Microsoft SQL Server 2000, replication is similar to other applications in SQL Server 2000 Your determining... failed job 215 2 16 Chapter 9 N OT E While viewing a job history, it is beneficial to show the job step details This displays the details for each of the steps taken In many cases, this is the only place an error message is displayed Setting SQL Server Mail Services SQL Server 2000 can connect with Microsoft Exchange Server and other mail services to provide two email options: SQL Mail and SQLAgentMail... Linked Servers Microsoft SQL Server allows you to create links to OLE DB data sources called linked servers Configuring a linked server allows the connection information to be supplied once The supplied connection information is used for the security context between the servers for the initial connection When you run a query that executes against the server you are connected to and a linked server, . services to Microsoft SQL Server are the SQL Server service and the SQL Server Agent service. The SQL Server service handles all query processing and server configuration. The SQL Server Agent service. options for the SQL Server Agent. By default the SQL Server Agent connects to another server using the SQL Server service account. Introducing the SQL Server Agent Service 205 By default, the SQL Server. 201 SQL Server Agent runs on any server that is running instances of Microsoft SQL Server 2000 or earlier versions of SQL Server. SQL Server Agent is the service that