Common logs used to diagnose sqlserver Problems

Source: Internet
Author: User
Tags time zones
Common logs used to diagnose sqlserver Problems

There are two main points:

(1) Windows Event Log

(2) sqlserver errorlog

1. Windows Event Log

As a service enabled and managed by WindowsProgram, Windows will record in its system log

The startup, normal shutdown, and abnormal shutdown information of the sqlserver service.

Sqlserver also records some of its summary information in the application log of windows.

Windows logs can reflect the health status of the operating system and whether there are any software or hardware exceptions.

If Windows itself cannot work normally, SQL Server's operation will be affected.

When Microsoft's after-sales engineers need to solve some problems, Windows event logs are a good tool to define the nature of the problem.

In Windows, click "start"-"Run-" and enter:EventvwrClick OK.Event Viewer

In windows7, windows2008, and windows2008r2, the interface is different, but the main content is similar.

 

Windows mainly has three types of logs: application, security, and system (my system is Windows 7)

The main concern for sqlserverApplicationsLogs andSystemLogs. When dealing with some connection authentication problems, you may occasionally useSecurityLogs.

Each record in the log belongsInformation,Warning,Error.

Each record indicates the date, time, source, and event ID.

If the source name of the records generated from sqlserver in the application log isMSSQLServer

Double-click a record. In windows, a dialog box is displayed, showing the specific record content.

 

The memory I encountered is insufficient, which causes sqlserver to replace the memory with the hard disk, leading to slow response of sqlserver.

The information displayed in the Event Viewer is the one shown above:Insufficient system memory

My machine status:

 

8 GB memory is not used up. Because of the 32-bit operating system, I plan to change it to 64-bit Windows 7 later.

 

So when you look at the event viewer or when you encounter problems, you should first look at the event viewer to find some clues

In the event viewer, you can save logs as *. EVT files or *. txt files for DBA to open analysis on other machines.

Open an *. EVT file by right-clicking the "Event Viewer (local)" tree structure --- "to open the saved log.

In this way, DBA can analyze the log files stored from other machines just like the logs on the local machine.

You can save a single event or an event of the entire category.

Finally, the time of the log opened in the Event Log Viewer is related to the time zone,

When a *. EVT file is opened on a machine set in different time zones, the display time varies.

For example, if an error message occurs in the daytime in the United States, it will be displayed at night when the machine in China is enabled.

If you search for data by U.S. time, you will not be able to find the data. However, this problem does not occur if the file is saved as a *. TXT text file.

 

2. sqlserver errorlog File

After checking the basic status of windows, you can start to check the health status of sqlserver.

No matter what problems you encounter, we recommend that you check sqlserver's firstErrorlogFile

When sqlserver is started, a"Errorlog"File

By default, sqlserver retains 7 errorlog files, which are sequentially named. 1,. 2,. 3,...,. 6 in chronological order.

Each time the service is restarted, the file extension is added and the earliest one is deleted.

 

The default log file path is the c: \ Program Files \ Microsoft SQL Server \ mssql.1 \ MSSQL \ log subdirectory under the installation path.

C: \ Program Files is the installation path of my machine. This path is selected when you install sqlserver.

Of course, DBA can also modify its settings (in the Configuration Manager, double-click SQL Service-> advanced-> dump directory)

I found that Windows is called a dump for error logs or directories, such as some software, such as QQ. youdao dictionary also seems to be a dump file in DMP format.

 

Answer question O (answer _ Answer) O

If you want to analyze a strange server, you can find the errorlog path in many ways.

One simple method is to select SQL service in the sqlserver Configuration Manager and find an advanced attribute of "Startup parameter" in its properties-> advanced.

The attribute string contains a "-e" parameter. It is followed by the location of the errorlog file.

 

Or you can simply see the dump directory above.

The errorlog file is recorded in text and can be opened in any file editor, including notepad and SSMs.

Generally, the size of the errorlog file is not large. Use these tools to fully meet your needs

However, errorlog is very important. It records the entire SQL enabling, running, and terminating process.

If sqlserver encounters a serious problem, it will be displayed in errorlog.

Errorlog displays the following content:

(1) SQL version and basic information about windows and processor

(2) SQL startup parameters, Authentication mode, and memory allocation mode

(3) Whether each database can be opened normally. If not, why?

(4) database corruption errors

(5) database backup and recovery action records

(6) DBCC checkdb records

(7) memory-related errors and warnings

(8) warning when an exception occurs during SQL scheduling. General server hang server death opportunities are accompanied by these warnings

(9) Warning of long latency in SQL I/O operations

(10) other high-level SQL errors encountered during running

(11) access violation)

(12) SQL Service Shutdown Time

When you check SQL server problems, you always start with errorlog and check whether the errorlog is clean.

If there are some errors or warnings in the errorlog, check the time when these errors and warnings occur and whether the front-end feels the problem.

If the time is correct, analyze it.

If you enable some settings, you can also see the following useful information in errorlog:

(1) logon successful or failed by all users

(2) deadlock and participant information: the tracking mark 1222 or 1204 must be enabled.

 
1 DBCCTraceon (1222)2 3 DBCCTraceon (1204)

Sometimes errorlog is not omnipotent? He cannot reflect the following problems:

(1) blocking problem. As long as blocking has not seriously affected SQL Server thread scheduling, errorlog will not be reflected

(2) common performance problems and timeout problems. If the performance problem is not caused by memory usage exceptions, thread scheduling exceptions, or the I/O subsystem is very slow,

It is caused by table or statement design that is not reflected in errorlog.

(3) Windows exceptions. If the job is abnormal on Windows or the server does not respond, it is difficult for sqlserver to determine its own

The above three problems are generally not reflected in errorlog. This is why we need to check the event log in the first step.

The following is an explanation of errorlog.

You can click the following link.

 Sqlserver errorlog

I have finished writing. Thank you!

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.