Home Database Mysql Tutorial 一件关于数据库日志log的无聊事情

一件关于数据库日志log的无聊事情

Jun 07, 2016 pm 03:42 PM
log about database log

为何说是无聊的记录呢? 因为事先把问题想复杂了,事后发现的时候觉得更是无聊的行为。还是写下来,毕竟很少弄这么无聊的事情。 事情起因是需要给服务器做性能基数(baseline),用sqldiag提取了大量的log信息,当然这里的数据库日志并不是指ldf文件。当我打

    为何说是无聊的记录呢?

    因为事先把问题想复杂了,事后发现的时候觉得更是无聊的行为。还是写下来,毕竟很少弄这么无聊的事情。

 

    事情起因是需要给服务器做性能基数(baseline),用sqldiag 提取了大量的log信息,当然这里的数据库日志并不是指ldf文件。当我打开SQL 2005或2008的对象资源管理器-->管理-->SQL Server 日志察看发现日志大约有百万行,当然原因我就不说了。

    日志log数据太大怎么办?

    先查看日志log如何被调用的,在TSQL中执行

       

    显示结果为

    一件关于数据库日志log的无聊事情

 

    有了存档号,接着查看某一个日志文件异常大的log内容(图中的异常日志已经被清除了,所以这里记录的时候暂且认为存档#为4的日志是异常大文件)

    接下来看看存档4的log内容,在TSQL中执行

   

    通常结果会返回如下图的内容

    一件关于数据库日志log的无聊事情

 

    话说到这儿,才开始我那愚蠢且无聊的做法。(直到现在我仍然认为这个做法相当怪异)

    因为这个日志log内容非常大,大约为数百万行,导致用sqldiag提取的__sp_sqldiag_Shutdown.OUT文件大小有近2G。于是有清除这个日志的想法,因为已经备档(备档的方式是将内容存为文本),所以可以清除日志。

    于是我就想找到这个log内容是存放在数据库MASTER的哪个表中,以便于干掉它。找来找去,只让我看到xpstar.dll 和xpstar90.dll这些信息。既然是调用动态链接库,我也要看看这个dll的内容,于是从网上下载Reflector 和Depends 进行反编译,接着反编译出错。

    到这里,其实GOD已经提醒我该走出去呼吸一下新鲜空气再回来思考,结果我没有那样做。这段过程大约花费近3个小时时间,用《 Becoming a Technical Leader 》里的话说,我已经进入了神游状态,当然我自己丝毫没有发觉。

    隔日清晨,来到办公室,当我下意识的打开系统中下面路径时,“密码”被破译了。其实只要删除log目录下ERRORLOG以及一系列ERRORLOG.1文件即可。

    X:/Program Files/Microsoft SQL Server/MSSQL10.MSSQLSERVER/MSSQL/Log

    其实我可以对自己说一句“神啊”,从结果看过程原来一切都是那么简单。

 

    当然,为了清除这个日志log内容,也有问一些朋友,不过他们都误以为我要清除ldf日志文件。写下来也是告诉自己:方向错了,停下来就是前进!!

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How to connect to remote database using Golang? How to connect to remote database using Golang? Jun 01, 2024 pm 08:31 PM

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Performance optimization tips for logging mechanism in Java functions? Performance optimization tips for logging mechanism in Java functions? May 02, 2024 am 08:06 AM

Logging optimization tip: Disable debug logging to eliminate the impact. Batch log messages to reduce overhead. Use asynchronous logging to offload logging operations. Limit log file size to improve application startup and processing performance.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

How to handle database connections and operations using C++? How to handle database connections and operations using C++? Jun 01, 2024 pm 07:24 PM

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.

See all articles