Last active
August 14, 2021 02:28
-
-
Save nansystem/8da2f2b7adb8be9333a10773247ea180 to your computer and use it in GitHub Desktop.
MySQLのmy.cnfの設定内容を理解する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [mysqld] | |
| server-id=1 | |
| # https://gist.github.com/fevangelou/fb72f36bbe333e059b66 | |
| datadir = /var/lib/mysql | |
| # よく使われるログの種類 | |
| # ログの種類 ログの内容 | |
| # error サーバーから出力されるエラーメッセージ | |
| # slow query 処理に時間のかかったクエリ | |
| # general すべての操作 | |
| # binary 更新SQLをバイナリ形式で記録 | |
| # debug 開発者向けのトレースログ | |
| # https://qiita.com/toshihirock/items/a97d174be68f485fbbf2 | |
| # https://www.ritolab.com/entry/98 | |
| # https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html#option_mysqld_log-bin | |
| # バイナリログは、バックアップとレプリケーションに使用される。 | |
| # binary log is used for backup and replication. | |
| # デフォルトのディレクトリはdataディレクトリ。 | |
| # つまり、/var/lib/mysql | |
| # The default location for binary log files is the data directory. | |
| # デフォルトのベースになるファイル名 [host_name]-bin | |
| # the base name defaults to host_name-bin, using the name of the host machine. | |
| # バイナリログはMySQL8.0からデフォルトで有効。 | |
| # よって、バックアップ、レプリケーションで利用しない場合は明示的に無効にする必要がある。 | |
| # From MySQL 8.0, binary logging is enabled by default | |
| # 以下のファイル名でバイナリログが生成されていく | |
| # mysql-bin-log.000001 | |
| # mysql-bin-log.000002 | |
| # mysql-bin-log.000003 | |
| log-bin=/var/log/mysql/bin_log/mysql-bin-log | |
| # バイナリログを管理するためのインデックスファイル。バイナリログのファイル名が記録されてる。 | |
| log_bin_index=/var/log/mysql/bin_log/bin.list | |
| # バイナリログのファイルサイズ。デフォルト1GB。最低4KB、最高1GB。 | |
| # The minimum value is 4096 bytes. The maximum and default value is 1GB. | |
| # ファイルサイズの上限を超えると、新しいファイルが生成される。 | |
| max_binlog_size=256M | |
| # ログファイルの保存期間。デフォルト30日 | |
| # expire_logs_daysは非推奨。代わりに秒単位で指定できるbinlog_expire_logs_secondsを使う。 | |
| # expire_logs_days is deprecated, and you should expect it to be removed in a future release. Instead, use binlog_expire_logs_seconds, | |
| # デフォルト30日 | |
| # default expiration period is 30 days. | |
| expire_logs_days=2 | |
| # デフォルトOFF | |
| # GTID = Global Transaction Identifiers | |
| # https://dev.mysql.com/doc/refman/8.0/en/replication-options-gtids.html#sysvar_gtid_mode | |
| # トランザクションごとにIDで管理してくれる。 | |
| gtid_mode=ON | |
| # GTIDで記録できるステートメントのみ使うよう強制できる | |
| enforce-gtid-consistency | |
| # デフォルト1 | |
| # 選択肢3つだが、デフォルトの1を使うのが最も安全。 | |
| # 設定値 ログバッファ→ログファイル ディスクフラッシュ | |
| # 0: 毎秒 毎秒 | |
| # 1: COMMIT時 COMMIT時 | |
| # 2: COMMIT時 毎秒 | |
| # https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit | |
| # https://www.na3.jp/entry/20191113/p1 | |
| innodb_flush_log_at_trx_commit=1 | |
| # デフォルト1 | |
| # デフォルト1が最も安全。 | |
| # Enables synchronization of the binary log to disk before transactions are committed. | |
| # https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html#sysvar_sync_binlog | |
| sync_binlog=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment