Overview of MariaDB logs

You are viewing an old version of this article. View the current version here.

MariaDBには、何をログに出すか、いつログに出すかを定義する、たくさんの変数があります。

この記事では、さまざまなログの概要を述べ、どのようにログを有効・無効にするかを説明します。

ストレージエンジンも独自のログを持っていることがあるのに注意しましょう。例えばInnoDBは、ロールバックやクラッシュリカバリに使うための、UndoログやRedoログを保持します。このページでは、MariaDBサーバのログのみを取り上げます。

エラーログ

  • 常に有効
  • 基本的にはデータディレクトリ内のファイルに記録されますが、ディストリビューションによっては場所が変わっていることがあります
  • 全ての致命的エラーはここに記録されます
  • log_warningsを設定することで、警告レベルのログも記録できます
  • mysqld_safe--syslogオプションで、システムのsyslogにもメッセージを出すことができます

一般クエリログ

スロークエリログ

バイナリログ

  • Enabled by starting mysqld with --log-bin
  • Normally only used on machines that are, or may become, replication masters.
  • Binary log files are mainly used by replication and can also be used with mysqlbinlog to apply on a backup to get the database up to date.
  • One can decide what to log with --binlog-ignore-db=database_name or --binlog-do-db=database_name.
  • The super user can disable logging for a connection by setting SQL_LOG_BIN to 0. However while this is 0, no changes done in this connection will be replicated to the slaves!
  • For examples, see Using and Maintaining the Binary Log.
  • --log-binを付けてmysqldを起動すると有効になります
  • 基本的には、レプリケーションのマスタになるマシンで有効にします
  • 主にレプリケーションのために使われ、mysqlbinlogによって、バックアップからの復旧時にデータベースを最新にするのにも使います
  • なにをログに記録するかを指定するのに、--binlog-ignore-db=database_name--binlog-do-db=database_nameを指定することもできます - super権限のあるユーザは、 setting SQL_LOG_BINを0にすることで、コネクション単位でログを無効にできます。これが0だと、そのコネクションで行われた変更はスレーブに複製されません。 - Using and Maintaining the Binary Logに例があります

これから実行するクエリが遅いのが分かっていて、スロークエリログにそれを記録したくないなら

SET LOCAL SLOW_QUERY_LOG=0;
<<code>>

super権限のあるユーザでバッチジョブを実行していて、そのクエリを記録したくないなら(例えばmysqldumpを実行するなど)

<<code>>
SET LOCAL SQL_LOG_OFF=1, LOCAL SLOW_QUERY_LOG=0;

MariaDB 10.1mysqldumpでは、--disable-log-querysを付ければ自動で無効になります。

参考

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.