# MariaDB Error Log Location
log-error = /var/lib/mysql/query_log/error/db_error.log
my.cnf 파일에 log-error에 에러 로그를 저장 할 경로를 적어준다.
service mariadb restart
my.cnf 수정사항을 반영한다.
MariaDB [query_log]> show variables like 'log_error';
+---------------+---------------------------------------------+
| Variable_name | Value |
+---------------+---------------------------------------------+
| log_error | /var/lib/mysql/query_log/error/db_error.log |
+---------------+---------------------------------------------+
log_error 경로가 제대로 수정 되었는지 확인 한다.
cd /var/lib/mysql/
mkdir query_log # 쿼리 로그 폴더 생성
chown mysql:mysql /var/lib/mysql/query_log # query_log 폴더 소유자, 그룹 mysql 변경
이 위에는 general_log 설정을 했다면 할 필요가 없다.
mkdir /var/lib/mysql/query_log/error # error 로그 저장 폴더 생성
chown mysql:mysql /var/lib/mysql/query_log/error # error 폴더 소유자, 그룹 mysql 변경
touch /var/lib/mysql/query_log/error/db_error.log # error 로그 저장 파일 생성
chown mysql:mysql /var/lib/mysql/query_log/error/db_error.log # error 로그 파일 소유자, 그룹 mysql 변경
로그 파일 저장 폴더와 파일 생성 과정이고 소유자와 그룹을 mysql 로 변경하여 마리아 디비가 접근 읽기, 쓰기 가능하게 만들어준다.
service mariadb restart
my.cnf 수정사항을 반영한다.
[root@mariadb-setting-test error]# cat db_error.log
[root@mariadb-setting-test error]#
현재 에러 로그 파일에 아무것도 없다.
service mariadb restart
서버 재시작 명령어 사용
[root@mariadb-setting-test error]# cat db_error.log
2023-09-14 13:46:09 140261439256320 [Note] /usr/sbin/mysqld (initiated by: unknown): Normal shutdown
2023-09-14 13:46:09 140261439256320 [Note] Event Scheduler: Purging the queue. 0 events
2023-09-14 13:46:09 140261300184832 [Note] InnoDB: FTS optimize thread exiting.
2023-09-14 13:46:09 140261439256320 [Note] InnoDB: Starting shutdown...
2023-09-14 13:46:09 140261057349376 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2023-09-14 13:46:09 140261057349376 [Note] InnoDB: Buffer pool(s) dump completed at 230914 13:46:09
2023-09-14 13:46:11 140261439256320 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2023-09-14 13:46:11 140261439256320 [Note] InnoDB: Shutdown completed; log sequence number 1616239
2023-09-14 13:46:11 140261439256320 [Note] /usr/sbin/mysqld: Shutdown complete
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Uses event mutexes
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Compressed tables use zlib 1.2.7
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Using Linux native AIO
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Number of pools: 1
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Using SSE2 crc32 instructions
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Completed initialization of buffer pool
2023-09-14 13:46:11 140615372326656 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Highest supported file format is Barracuda.
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: 128 out of 128 rollback segments are active.
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Creating shared tablespace for temporary tables
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2023-09-14 13:46:11 140615931848896 [Note] InnoDB: 5.7.37 started; log sequence number 1616239
2023-09-14 13:46:11 140614930781952 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2023-09-14 13:46:11 140614930781952 [Note] InnoDB: Buffer pool(s) load completed at 230914 13:46:11
2023-09-14 13:46:11 140615931848896 [Note] Plugin 'FEEDBACK' is disabled.
2023-09-14 13:46:11 140615931848896 [Note] Server socket created on IP: '::'.
2023-09-14 13:46:11 140615931848896 [Note] Reading of all Master_info entries succeeded
2023-09-14 13:46:11 140615931848896 [Note] Added new Master_info '' to hash table
2023-09-14 13:46:11 140615931848896 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.2.43-MariaDB-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
이렇게 에러 로그 파일에 기록이 남는다.
에러 로그는 “DB의 시작과 중지, 테이블의 손상 등 DB서버가 작동하는 도중에 발생하는 오류정보를 저장한다.” 라고 한다.
그렇기 때문에 서버가 재부팅 하는 것도 에러 로그에 남는 것이다.