Tải bản đầy đủ (.pdf) (82 trang)

Optimizing And Troubleshooting SQL Server

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.86 MB, 82 trang )

LESSON: 3B
OPTIMIZING AND
TROUBLESHOOTING SQL
SERVER
Objectives

Optimizing and Troubleshooting SQL Server

Objectives
In this section, you will learn about:
• Optimizing hardware resource usage
• Monitoring hardware resources
• Resolving system bottlenecks
• Monitoring SQL Server 2000 system activity
• Optimizing SQL Server 2000 system activity
• Troubleshooting SQL Server 2000 system activity

©NIIT

3B.1

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 1 of 51

Administering and Troubleshooting SQL Server 2000


In this lesson, you will learn about:


 Optimizing hardware resource usage
 Monitoring hardware resources
 Resolving system bottlenecks
 Monitoring SQL Server 2000 system activity
 Optimizing SQL Server 2000 system activity
 Troubleshooting SQL Server 2000 system activity

Optimizing and Troubleshooting SQL Server

Pre-Assessment Questions

©NIIT

1.

Which component of the SQL Server 2000 do you need to configure to
send messages to pagers?
a)
SQLMail
b)
SQLAgentMail
c)
Linked Server
d)
SQL Server XML support in IIS

2.

Which of the following component of SQL Server 2000 enables you to
retrieve and use data from an Oracle database?

a)
SQL Server XML support in IIS
b)
Linked Server
c)
SQLAgentMail
d)
SQLMail

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 2 of 51

Administering and Troubleshooting SQL Server 2000

3B.2


Optimizing and Troubleshooting SQL Server

Pre-Assessment Questions

©NIIT

3B.3

3.

Which option do you need to select to verify the local login id with the

login id on the linked server?
a)
Impersonate
b)
Local Login
c)
Remote password
d)
Remote User

4.

Which option is used to execute queries in
“http://iisserver/vdir/myquery.xml “to retrieve information from a
database?
a)
Allow template queries
b)
Allow URL queries
c)
Allows XPATH
d)
Allow Post

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 3 of 51

Administering and Troubleshooting SQL Server 2000



Optimizing and Troubleshooting SQL Server

Pre-Assessment Questions
5.

©NIIT

Which of the following options of the Linked Server provides the product
name for the OLEDB data source that you want to add as a linked
server?
a)
Provider name
b)
Data source
c)
Provider string
d)
Product name

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 4 of 51

Administering and Troubleshooting SQL Server 2000

3B.4



Optimizing and Troubleshooting SQL Server
Solutions to Pre-assessment Questions:
Ans 1. a. SQLMail
Ans 2. b. Linked Server
Ans 3. a. Impersonate
Ans 4. a. Allow template queries
Ans 5. d. Product name

©NIIT

3B.5

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 5 of 51

Administering and Troubleshooting SQL Server 2000


INSTRUCTOR NOTES
Start the session by telling the students about the need to optimize the hardware
usage in SQL Server 2000. Also discuss the different functional areas that need to be
optimized. Then tell the students that SQL Server 2000 optimizes its hardware
resources using the following techniques:

„Placing data on multiple disks
„Configuring SQL Server 2000
„Resolving system


disk subsystem

bottlenecks

Explain each technique in detail. Tell the students about the advantages of placing
data on multiple disks. Also tell the students about the various RAID levels used in
SQL Server 2000. Then discuss the SCSI and IDE disk subsystems in detail. Also tell
the students that SCSI disk subsystem is used to store the following types of files of
SQL Server 2000:

„Data files
„Transaction log files
„Tempdb system

database

Then discuss about bottlenecks and methods that can be used to resolve bottlenecks
in SQL Server 2000.

Administering and Troubleshooting SQL Server 2000

3B.6


OPTIMIZING HARDWARE
RESOURCES

Optimizing and Troubleshooting SQL Server


Optimizing Hardware Resource Usage
in SQL Server 2000



©NIIT

3B.7

It is essential to optimize usage of hardware resources, such as CPU
and memory so that SQL Server 2000 functions properly and provides
the required output.
Optimizing hardware resource usage in SQL Server 2000 allows you to
identify:
• Hardware utilization
• Task scheduling
• Load balancing

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 6 of 51

Administering and Troubleshooting SQL Server 2000


Optimizing and Troubleshooting SQL Server

Optimizing Hardware Resource Usage
in SQL Server 2000 (Contd.)



©NIIT

SQL Server 2000 enables you to optimize its hardware resource usage
using the following techniques:
• Placing data on multiple disks
• Configuring SQL Server 2000 disk subsystem
• Resolving system bottlenecks

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 7 of 51

You need to optimize the usage of hardware resources, such as CPU, processor power,
disks, network subsystem, and memory so that SQL Server 2000 functions properly
and provides the required output. Optimizing hardware resource usage in SQL Server
2000 allows you to identify:

„Hardware utilization: You can identify the time range when the hardware
resources are fully utilized. This time range is called the Peak time.

„Task scheduling: You can identify the time range when the hardware resources
are partially utilized or not utilized at all.

„Load balancing: Depending on the level of utilization of hardware resources, you

can schedule the tasks to be performed so that the hardware resources,
especially the CPU is neither over-burdened with tasks nor is idle. You can

implement load balancing so that the memory is neither over-utilized nor underutilized.

Administering and Troubleshooting SQL Server 2000

3B.8


SQL Server 2000 enables you to optimize its hardware resource usage using the
following techniques:

„Placing data on multiple disks
„Configuring SQL Server 2000 disk subsystem
„Resolving system

bottlenecks

Placing Data on Multiple Disks
Optimizing and Troubleshooting SQL Server

Placing Data on Multiple Disks


You can place database files on multiple disks to optimize database

.

performance along with hardware resource usage






©NIIT

3B.9

Using multiple disks to store data provides the following advantages:
• Data recoverability
• Increased system performance and efficiency
• Fault tolerance
A RAID system consists of two or more disk drives that are used to
store the database and the transaction log files.

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 8 of 51

Administering and Troubleshooting SQL Server 2000


Optimizing and Troubleshooting SQL Server

Placing Data on Multiple Disks
(Contd.)
• A RAID system can be classified into two categories, Hardware RAID and
Software RAID

• RAID system provides the following levels that enable SQL Server 2000 to
place database files on multiple disks:

•RAID level 0
•RAID level 1
•RAID level 5
•RAID level 10

©NIIT

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 9 of 51

You can place database files on multiple disks to optimize database performance along
with hardware resource usage. Using multiple disks to store data provides the
following advantages:

„

Data recoverability

„

Increased system performance and efficiency

„

Fault tolerance

To place database files on multiple disks, SQL Server 2000 uses Redundant Array of
Independent Disk (RAID) system. A RAID system consists of two or more disk drives

that are used to store the database and the transaction log files. Since RAID consists
of multiple disk drives, it provides increased performance with respect to data access
and retrieval and fault tolerance to the computer system than a single disk drive. A
RAID system can be classified in the two categories, Hardware RAID and Software
RAID. When the Windows operating system provides the RAID support, it is called the
Software RAID and when the disk storage system provides the RAID support, it is
known as the Hardware RAID.

Administering and Troubleshooting SQL Server 2000

3B.10


RAID system provides the following levels that enable SQL Server 2000 to place
database files on multiple disks:

„RAID level 0: The write operation in this level, writes data in blocks that are

spread evenly across all the disks. This accelerates the read operation and the
write operation. This level provides 100% utilization of the disk capacity but is
not fault tolerant.

„RAID level 1: The write operation writes the data completely on all the disks

used. The read operation is faster than the write operation. This level utilizes
only 50% of the disk capacity but is fault tolerant.

„RAID level 5: The write operation writes data in blocks across all the disks. This
level provides faster read operation as compared to the write operation. This
level efficiently utilizes the disk space as compared to the other levels and is

fault tolerant.

„RAID level 10: The read and write operations are fastest at this level as

compared to the other levels. This level uses only 50% of the disk capacity but
is fault tolerant.

Since software RAID requires SQL Server 2000 to share processor
resources with the RAID system that decreases system
performance, hardware RAID is commonly used.

3B.11

Administering and Troubleshooting SQL Server 2000


Configuring SQL Server 2000 Disk Subsystem
Optimizing and Troubleshooting SQL Server

Configuring SQL Server 2000 Disk
Subsystem

©NIIT



You can configure the disk subsystem to optimize the usage of memory
resources.




The disk subsystems are of the following two standards:
•Small Computer System Interface (SCSI)
•Integrated Drive Electronics (IDE)



The following are the reasons to use SCSI disk subsystem:

•It is used to increase the performance of the memory resources.
•It is used to provide fault tolerance to the system.
•It is used to provide fast read and write operations.
•It is used to enable fast and accurate data recoverability.
Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 10 of 51

Administering and Troubleshooting SQL Server 2000

3B.12


Optimizing and Troubleshooting SQL Server

Configuring SQL Server 2000 Disk
Subsystem (Contd.)


©NIIT


The SCSI subsystem is used for the following three files in SQL Server
2000:
• Data files
• Transaction log files
• Tempdb system database

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 11 of 51

You can also optimize the hardware resource usage of SQL Server 2000 using the disk
subsystem. For this you need to configure the disk subsystem. The disk subsystems
are of the following two standards:

„Small Computer System Interface (SCSI): The hard disk using this standard

follows the bus architecture. Using this standard the disk subsystem can be
connected to maximum of 15 other devices. These 15 devices can include
storage, input, and output devices. This subsystem provides reduced access and
execution time. It also provides fault tolerance to the system and can coordinate
slow devices with the fast devices.

„Integrated Drive Electronics (IDE): The hard disk

using this standard also
follows the bus architecture. Using this standard, the disk subsystem can be
connected to maximum 2 other storage devices. This disk subsystem is slow as
compared to SCSI disk subsystem and does not provide connections to any

other devices other than storage devices.

The following are the reasons to use SCSI disk subsystem:

x
x
x
x

3B.13

It increases the performance of the memory resources.
It provides fault tolerance to the system.
It provides fast read and write operations.
It enables fast and accurate data recoverability.

Administering and Troubleshooting SQL Server 2000


The SCSI subsystem is used for the following three files in SQL Server 2000:

x
x
x

Data files
Transaction log files
Tempdb system database

Using SCSI Disk Subsystem for Data Files

You can use SCSI disk subsystem to store data files in SQL Server 2000. A separate
disk subsystem is used to store data files to prevent data loss and to reduce access
time. It is essential to store data files on a separate disk subsystem so that CPU
operations do not conflict with the input/output operations. Storing data files and
transaction log files on separate disk subsystems also improves the performance of
input/output operations by reducing bottlenecks. The performance of input/output
operations improves because SQL Server 2000 has the ability to perform multiple
scans on data that is spread across multiple disks.

Using SCSI Disk Subsystem for Transaction Log Files
SCSI disk subsystem is used to store transaction log files also. Storing transaction log
files on a separate disk subsystem provides fast and efficient recoverability of data
because transaction log files are used for recovering and restoring databases. The disk
subsystem stores the data of transaction log files in sequential order because this data
is used for transactional rollbacks, transactional commits, and database backups.

Using SCSI Disk Subsystem for Tempdb System Database
A separate SCSI disk subsystem is used to store Tempdb database because this
database stores intermediate results of complex Transact-SQL queries and DBCC
operations. Optimizing the storage of Tempdb system database enables it to handle
large number of read and write operations. Tempdb database is stored on a separate
disk subsystem so that it does not interfere with other databases to access the
memory resource.
Data recoverability is not considered with the Tempdb database
because it is rebuilt every time the SQL Server 2000 starts.

Administering and Troubleshooting SQL Server 2000

3B.14



Resolving System Bottlenecks

Optimizing and Troubleshooting SQL Server

Resolving System Bottlenecks





©NIIT

Bottlenecks are defined as a situation when multiple databases are competing
for a single resource at one instance.
A bottleneck is caused due to inadequate hardware resources, such as processor
or memory.
Bottlenecks cause under utilization of databases and database objects.
Putting additional resources, such as increasing the storage capacity and
incorporating additional processors, can resolve hardware as well as
performance bottlenecks.

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 12 of 51

Bottlenecks are defined as a situation when multiple databases are competing for a
single resource at one instance. Occasionally bottlenecks are also caused when there
is an excessive demand for a database object. A bottleneck is caused due to

inadequate hardware resources, such as processor or memory. Bottlenecks cause
under utilization of databases and database objects. This happens because multiple
databases and database objects compete for a single resource and finally none of the
competing databases gets the resource and the resource remains idle. You can detect
a hardware bottleneck when a hardware resource is being excessively utilized.
Similarly, you can detect a performance bottleneck when the request response time is
low. These bottlenecks have to be resolved to optimize system performance. Putting
additional resources, such as increasing the storage capacity and incorporating
additional processors, can resolve hardware as well as performance bottlenecks.

3B.15

Administering and Troubleshooting SQL Server 2000


INSTRUCTOR NOTES
Next, tell the students about monitoring hardware resources and their usage in SQL
Server 2000. Prior to discussing the methods to monitor the hardware resource usage,
tell the students about the reasons to monitor hardware resource usage in SQL Server
2000. Then, tell the students that to monitor the performance of hardware resources,
you need to identify the following types of problem objects of these resources and
their values:

„Memory

objects and counters

„Input/Output objects and counters
„Processor objects and counters
Discuss each type of object and counters in detail, explaining the different objects in

each type.
Finally, tell the students about monitoring the hardware resources using the Task
Manager, explaining each step in detail.

Administering and Troubleshooting SQL Server 2000

3B.16


MONITORING HARDWARE
RESOURCES

Optimizing and Troubleshooting SQL Server

Monitoring Hardware Resources



©NIIT

3B.17

You need to monitor the working of hardware resources of SQL Server 2000
to analyze and increase their performance.
The following are the reasons to monitor the hardware resources of SQL
Server 2000:
• Inadequate hardware resources may be over-loading SQL Server 2000
unnecessarily, for example insufficient memory resource may lead to
loss of important data.
• Additional server applications, such as Internet Information Server

may be consuming excessive resources.
• Malfunctioning of the hardware resources, such as the hard disk
containing bad sectors resulting in loss of important data.

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 13 of 51

Administering and Troubleshooting SQL Server 2000


Optimizing and Troubleshooting SQL Server

Monitoring Hardware Resources
(Contd.)







Uneven usage of hardware resources, for example one storage device
is overused and another storage device is underused
Excessive network traffic that results in network congestion
Incorrect usage of queries
Transferring large amount of data between the client and the server.
Excessive use of locks on resources that result in under-utilization of
these resources

Poor database design that results in redundancy of data

©NIIT

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 14 of 51

You need to monitor the working of hardware resources of the system to analyse and
increase their performance. The following are the reasons to monitor the hardware
resources of the system:

„Inadequate hardware resources may

be over-loading SQL Server 2000
unnecessarily, for example insufficient memory resource may lead to loss of
data.

„Additional server applications, such as Internet Information Server may
consuming excessive resources.

„Malfunctioning of the hardware resources, such as the hard disk
sectors resulting in loss of important data.

be

containing bad

„Uneven usage of hardware resources, for example one storage device is

overused and another storage device is underused.

„Excessive network

traffic that results in network congestion.

„Incorrect usage of queries results in the wastage of resources utilized during the
execution of the queries, for example executing a query resulting in a syntax
error wastes the resources utilized during the execution of that query.

Administering and Troubleshooting SQL Server 2000

3B.18


„Transferring large amount of data between the client and the server.
„Excessive use of locks on resources that result in under-utilization of these
resources.

„Poor database design results in redundancy of data. This results in wastage of
resources utilized by the database.

Monitoring Resource Usage
Optimizing and Troubleshooting SQL Server

Monitoring Resource Usage


©NIIT


3B.19

These objects are categorized in to the following three categories:
• Memory objects and counters
• Input/Output objects and counters
• Processor objects and counters

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 15 of 51

Administering and Troubleshooting SQL Server 2000


Optimizing and Troubleshooting SQL Server

Monitoring Resource Usage (Contd.)


Memory objects and counters
You need to monitor the available memory resource and determine
whether it is adequate for the processes that are running.
• The following table lists the memory objects, their functions, and their
values:



Memory Object


This Object determines

Value and its Interpretation

Memory \ Available
Mbytes

Megabytes of memory
presently available for
use

A low value indicates inadequate
memory or memory blocked by a
process

Memory \ Pages/sec

Number of pages
accessed from disk or
written to disk due to
page faults

A value more than 20 indicates
excessive hard disk paging
because of inadequate memory

©NIIT

Optimizing and troubleshooting
SQL server


Lesson 3B/ Slide 16 of 51

Administering and Troubleshooting SQL Server 2000

3B.20


Optimizing and Troubleshooting SQL Server

Monitoring Resource Usage (Contd.)
Memory Object

This Object determines

Value and its Interpretation

Physical Disk \ Average
Disk Queue Length

Average numbers of both
read and write requests
in queue

An increase in disk queue that is
not accompanied by decrease in
memory paging indicates
inadequate memory

Memory \ Page

Faults/sec

The rate at which the
processor handles the
faulty pages

A high value indicates inadequate
memory

Process \ Page
faults/sec for SQL
Server instance

The rate at which the
faulty pages occur
because of a SQL server
process of a SQL Server
instance

A high value for overall page
faults/sec indicates shortage of
memory

©NIIT

3B.21

Optimizing and troubleshooting
SQL server


Lesson 3B/ Slide 17 of 51

Administering and Troubleshooting SQL Server 2000


Optimizing and Troubleshooting SQL Server

Monitoring Resource Usage (Contd.)
Memory Object

This Object determines

Value and its Interpretation

SQL Server: Memory
Manager \ Total Server
Memory (KB)

The total amount of
dynamic memory
currently used by SQL
Server for its memory
buffer

If this value is close to the total
amount of physical memory of the
computer, it indicates shortage of
memory

SQL server: Buffer

Manager \ Total Pages

Total number of pages in
the buffer

A low value indicates inadequate
memory for the buffer

©NIIT

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 18 of 51

Administering and Troubleshooting SQL Server 2000

3B.22


Optimizing and Troubleshooting SQL Server

Monitoring Resource Usage (Contd.)


Input/Output Object

This Object determines

Value and its Interpretation


PhysicalDisk \ %Disk
Time

Percentage of time during
which the hard disk was
processing a read or write
request

A low rate of disk paging
accompanied with a high rate of
disk usage and disk queuing
indicates a disk bottleneck

PhysicalDisk \ Average
Disk Queue Length

Average numbers of both
read and write requests
that were in queue

A low rate of disk paging
accompanied with a high rate of
disk usage indicates a disk
bottleneck

©NIIT

3B.23


Input/Output Objects and Counters
• Small Computer System Interface (SCSI)
• The following table lists the input/output objects, their functions,
and their values:

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 19 of 51

Administering and Troubleshooting SQL Server 2000


Optimizing and Troubleshooting SQL Server

Monitoring Resource Usage (Contd.)
Input/Output Object

This Object determines

Value and its Interpretation

PhysicalDisk \
Current Disk Queue
Length

Instantaneous numbers
of both read and write
requests that are
queued


Used along with PhysicalDisk \
Average Disk Queue Length

PhysicalDisk \
Average disk/sec
Write

Average time to write
data to disk, also
known as disk latency

A value above 20 milliseconds
indicates a disk bottleneck

PhysicalDisk \ Disk
Writes/sec

Rate of write operations
per second

If the rate of disk writes is not
close to the hard disk capacity
and the disk latency is high, it
indicates a faulty disk

PhysicalDisk \ Disk
Reads/sec

Rate of read operations

per second

If the rate of disk reads is not
close to the hard disk capacity
and the disk latency is high, it
indicates a faulty disk

©NIIT

Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 20 of 51

Administering and Troubleshooting SQL Server 2000

3B.24


Optimizing and Troubleshooting SQL Server

Monitoring Resource Usage (Contd.)


Processor Objects and Counters
• To monitor the processor resources, SQL Server 2000 provides you
with processor objects.
• The following table lists the processor objects, their functions, and
their values:


Processor Object

This Object determines

Value and its Interpretation

Processor \ %
Processor Time

Percentage of time the
processor spent executing
non-idle processes

If the rate is more than 75%, it
indicates a processor bottleneck

System \ processor
Queue Length

Number of processes in the
processor queue

A processor queue containing more
than two threads indicates a
processor bottleneck

©NIIT

3B.25


Optimizing and troubleshooting
SQL server

Lesson 3B/ Slide 21 of 51

Administering and Troubleshooting SQL Server 2000


×