web-dev-qa-db-ja.com

/ var / log / mysqlフォルダーを削除

間違いのため、mysqlのログフォルダーを削除しました。フォルダーとエラーログを生成する方法はありますか? Debian 9 StretchでMariaDB 10.3を使用しています

1
Fabian

mysqldはエラーログファイルを開いたままにします。ファイルを削除しても、ファイルハンドラーは有効であり、ファイルはそれを開いたプロセス(= mysqld)で使用できます。

# lsof  | grep mysqld
...
mysqld    20163 20192           mysql    2w      REG              253,2       4434         15 /var/log/mysql/error.log

# rm /var/log/mysql/error.log
# lsof  | grep mysqld | grep error
...
mysqld    20163 20310           mysql    2w      REG              253,2       4549         15 /var/log/mysql/error.log (deleted)

エラーログの内容は/procファイルシステムから取得できます。

# ls -la /proc/20163/fd/ | grep error
l-wx------ 1 mysql mysql 64 May  2 15:49 1 -> /var/log/mysql/error.log (deleted)
l-wx------ 1 mysql mysql 64 May  2 15:49 2 -> /var/log/mysql/error.log (deleted)
# cat /proc/20163/fd/1
2020-05-02T15:49:46.163721Z 0 [Warning] Could not increase number of max_open_files to more than 5000 (request: 65535)
2020-05-02T15:49:46.355461Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-0ubuntu0.18.04.1-log) starting as process 20163 ...
2020-05-02T15:49:46.371978Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-02T15:49:46.372006Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-02T15:49:46.372010Z 0 [Note] InnoDB: Uses event mutexes
2020-05-02T15:49:46.372013Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-02T15:49:46.372016Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-02T15:49:46.372023Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-02T15:49:46.372272Z 0 [Note] InnoDB: Number of pools: 1
2020-05-02T15:49:46.372380Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-02T15:49:46.376119Z 0 [Note] InnoDB: Initializing buffer pool, total size = 384M, instances = 1, chunk size = 128M
2020-05-02T15:49:46.398759Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-05-02T15:49:46.404255Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-05-02T15:49:46.421829Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-05-02T15:49:48.448175Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-05-02T15:49:48.448255Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-05-02T15:49:48.938748Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-05-02T15:49:48.939384Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-05-02T15:49:48.939393Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-05-02T15:49:48.939823Z 0 [Note] InnoDB: Waiting for purge to start
2020-05-02T15:49:48.990402Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 3292611
2020-05-02T15:49:48.990563Z 0 [Note] InnoDB: Loading buffer pool(s) from /database/mysql/ib_buffer_pool
2020-05-02T15:49:48.990773Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-05-02T15:49:49.476557Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200502 15:49:49
2020-05-02T15:49:49.569129Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-05-02T15:49:49.569147Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-05-02T15:49:49.596450Z 0 [Warning] CA certificate ca.pem is self signed.
2020-05-02T15:49:49.596491Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-05-02T15:49:49.616398Z 0 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2020-05-02T15:49:49.616425Z 0 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
2020-05-02T15:49:49.616456Z 0 [Note] Server socket created on IP: '0.0.0.0'.
2020-05-02T15:49:49.856411Z 0 [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--relay-log=produ-data-db-0000-05f01-use2-relay-bin' to avoid this problem.
2020-05-02T15:49:49.946618Z 1 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2020-05-02T15:49:49.966480Z 2 [Warning] Slave SQL for channel '': If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
2020-05-02T15:49:49.966566Z 2 [Note] Slave SQL thread for channel '' initialized, starting replication in log 'mysql-bin.000116' at position 2493, relay log './produ-data-db-0000-05f01-use2-relay-bin.000002' position: 1811
2020-05-02T15:49:49.971887Z 1 [Note] Slave I/O thread for channel '': connected to master 'replication@produ-data-db-0000-0c5f4-use2:3306',replication started in log 'mysql-bin.000116' at position 2493
2020-05-02T15:49:51.066602Z 0 [Note] Event Scheduler: Loaded 0 events
2020-05-02T15:49:51.066831Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.29-0ubuntu0.18.04.1-log'  socket: '/var/lib/mysql-files/mysql.sock'  port: 3306  (Ubuntu)
2020-05-02T15:50:05.681566Z 5 [Warning] IP address '10.0.182.254' could not be resolved: Name or service not known

同じ方法で他のファイルを取得できます(遅いログ、一般的なログ)。ただし、ファイルが閉じられて削除された場合、あなたはほとんど運が悪くなります(回復することは不可能ではありませんが難しい)。

3
akuzminsky