[MySQL] Binary Log 관련 명령

■ show 명령.

 

▶︎ Binlog 리스트 출력.

mysql> SHOW BINARY LOGS;
mysql> SHOW MASTER LOGS;

mysql> SHOW BINARY LOGS;
+---------------+-----------+
| Log_name      | File_size |
+---------------+-----------+
| binlog.000015 |    724935 |
| binlog.000016 |    733481 |
+---------------+-----------+

show binary logs show master logs 출력내용이 같습니다.

 

▶︎ 이벤트 출력.

명령어 형식
---------------------------------------------
SHOW BINLOG EVENTS
   [IN 'log_name']
   [FROM pos]
   [LIMIT [offset,] row_count]
---------------------------------------------
SHOW RELAYLOG EVENTS
    [IN 'log_name']
    [FROM pos]
    [LIMIT [offset,] row_count]
    [channel_option]

channel_option:
    FOR CHANNEL channel
---------------------------------------------

 

1. 출력형식

아래 명령들의 모든 출력형식은 다음과 비슷합니다.

+----------------------------+-------+----------------+------------+-------------+-------------------------------------------------------+
| Log_name                   | Pos   | Event_type     | Server_id  | End_log_pos | Info                                                  |
+----------------------------+-------+----------------+------------+-------------+-------------------------------------------------------+
| mysql-bin-changelog.066584 |     4 | Format_desc    | 1611966438 |         123 | Server ver: 5.7.19-log, Binlog ver: 4                 |
| mysql-bin-changelog.066584 |   123 | Previous_gtids | 1611966438 |         150 |                                                       |
| mysql-bin-changelog.066584 |   150 | Anonymous_Gtid | 1611966438 |         211 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                  |
| mysql-bin-changelog.066584 |   211 | Query          | 1611966438 |         283 | BEGIN                                                 |
| mysql-bin-changelog.066584 |   283 | Table_map      | 1611966438 |         384 | table_id: 34255 (table.table1)      |
........

 

 

2. 모든 이벤트 출력.

mysql> show binlog events;

 

3. 특정 파일내의 이벤트 출력.

- 출력 라인수 제한 포함

- 라인수 제한(limit 옵션) 없으면 파일내의 모든 이벤트 출력.

mysql> show binlog events in 'mysql-bin-changelog.667772' limit 100;

 

4. 특정 포지션에서 이벤트 출력.

- 특정 Binary Log파일의 특정 포지션부터 파일내 모든 이벤트 출력.

show binlog events in 'mysql-bin-changelog.667795' from 4;

- 특정 Binary Log파일의 특정 포지션부터 라인수 제한내의 모든 이벤트 출력.

show binlog events in 'mysql-bin-changelog.667795' from 4 limit 10;

- 특정 Binary Log파일의 특정 포지션부터 출력하는데 출력 내용중 특정라인부터 특정 갯수만 출력.

(로그파일의 포지션 4부터 출력하는데 출력내용중 5번째 행부터 10개만 출력)

show binlog events in 'mysql-bin-changelog.667795' from 4 limit 5, 10;

 

5. 출력 컬럼 설명.

+ Log_name

나열되는 파일의 이름입니다.

+ Pos

이벤트가 발생하는 위치입니다.

+ Event_type

이벤트 유형을 설명하는 식별자입니다.

+ Server_id

이벤트가 시작된 서버의 서버 ID

+ End_log_pos

다음 이벤트가 시작되는 위치로, Pos + 이벤트 크기와 같습니다.

+ Info

이벤트 유형에 대한 자세한 정보 정보의 형식은 이벤트 유형에 따라 다릅니다.

'Databases > MySQL' 카테고리의 다른 글

[MySQL] Purge Log  (0) 2020.11.12
[MySQL] root 암호 분실시 재설정 방법  (0) 2020.11.09
[MySQL] CHECKSUM TABLE  (0) 2020.11.06
[MySQL] CHECK TABLE & Repair TABLE  (0) 2020.11.03
[MySQL] REPAIR TABLE 최적화 문법  (0) 2020.11.02

Designed by JB FACTORY