Commit logs (clogs) in OceanBase Database are similar to redo logs in a conventional database. They persist the transaction data when transactions are committed. The transaction data is the record of transaction modifications to the database. log_tool parses and prints clog files. This topic describes how to use log_tool.
log_tool is equivalent to clog_tool in earlier versions and is updated for adaptation in OceanBase Database V4.x. Specifically, some command formats are modified and some features are deleted.
log_tool commands
log_tool is integrated into ob_admin. You can run the ob_admin command to call log_tool. The following table describes the general commands of log_tool.
| Command | Description |
|---|---|
dump_log |
Parses and prints the specified clog file. |
dump_tx_format |
Parses the specified clog file and prints the file in a format that is similar to SQL statements. |
dump_filter |
Parses the specified clog file and prints the log records that meet the specified conditions. |
stat |
Parses the specified clog file and prints the statistics of the file. |
dump_log
ob_admin log_tool dump_log <clog_file_name>
Usage notes:
You can run the
dump_logcommand to parse and print the specified clog file. If you want to parse multiple files, separate the file names with spaces.You must replace the
clog_file_namestring with the actual file name. The path of the file can be included inclog_file_name. Examples:To parse and print a single clog file that is named
101and located in the current directory, run the following command:ob_admin log_tool dump_log 101To parse and print multiple clog files that are named
101and103and located in the current directory, run the following command:ob_admin log_tool dump_log 101 103To parse and print multiple clog files that are consecutively named
101,102,103, and104and located in the current directory, run the following command:ob_admin log_tool dump_log {101..104}
dump_filter
ob_admin log_tool dump_filter '<filter_name>' <clog_file_name>
Usage notes:
You can use
dump_filterto print the transaction-related content in clog files based on conditions.For more information about
<clog_file_name>, see dump_log.You can filter log records by specifying filter conditions in the
filter_namefield. The following table describes the valid values of filter_name.Value Description tablet_idThe ID of a data table. tx_idThe ID of a transaction. You can specify one or multiple filter conditions in the
filter_namefield. If you specify multiple filter conditions, separate the conditions with semicolons (;). Examples:Assume that
tablet_idis set to123, and the clog file is named101and located in the current directory. Run the following command to parse and print this clog file.ob_admin log_tool dump_filter 'tablet_id=123' 101Assume that
tablet_idis set to123,tx_idis set to26058724, and the clog file to be parsed is named101and located in the current directory. Run the following command to parse and print this clog file.ob_admin log_tool dump_filter 'tablet_id=123;tx_id=26058724' 101
stat
ob_admin log_tool stat <clog_file_name>
Usage notes:
You can use the
statcommand to obtain statistics of the specified clog file, including the file size, number of records, and number of transactions.Note
By using the
CLOG_TOOL_BREAK_ON_FAILenvironment variable, clog_tool can control whether to directly exit or ignore errors and continue. WhenCLOG_TOOL_BREAK_ON_FAILis set to true, clog_tool directly exits. WhenCLOG_TOOL_BREAK_ON_FAILis set to false, clog_tool ignores errors and continues parsing the specified clog file.For more information about
<clog_file_name>, see dump_log.