Maxwell을 사용하여 MySQL 바이너리 로그를 JSON 형식으로 출력
Maxwell 다운로드
다음 사이트에서 Maxwell을 다운로드할 수 있습니다.
 htps : // 기주 b. 이 m/전으로 sk/마x우우 l/레아아세 s/도 w응아 d/v1.10.8/마x우우l-1.10.8. r. gz
$ curl -sLo - https://github.com/zendesk/maxwell/releases/download/v1.10.8/maxwell-1.10.8.tar.gz | tar zxvf -
 MySQL/Aurora측 설정
1. 바이너리 로그 형식을 "ROW"(행 기반 로깅)로 변경합니다.
$ vi my.cnf
[mysqld]
server-id=1
log-bin=master
binlog_format=row
RDS를 사용하는 경우 매개 변수 그룹을 변경합니다.
 
2. MySQL/Aurora에서 Maxwell 사용자를 만들고 권한을 부여합니다.
mysql> CREATE USER 'maxwell' identified by 'password';
mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE on *.* to 'maxwell' identified by 'password';
mysql> GRANT ALL on maxwell.* to 'maxwell';
 Maxwell 시작
다음 명령을 사용하여 STDOUT(표준 출력) 모드에서 Maxwell을 시작합니다.
$ cd maxwell-1.10.8
$ bin/maxwell --user='maxwell' --password='password' --host='xxxxxxxx.rds.amazonaws.com' --producer=stdout
 JSON 형식 binlog 출력
동작 확인으로서 MySQL측 이하의 SQL을 발행합니다.
mysql> INSERT INTO user_info VALUES (0, 'admin', 'password', '[email protected]');
Query OK, 1 row affected (0.01 sec)
mysql> update user_info set username='user', email='[email protected]';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> delete from user_info;
Query OK, 1 row affected (0.01 sec)
다음 JSON이 출력됩니다.
{"database":"test_db","table":"user_info","type":"insert","ts":1508315079,"xid":929,"commit":true,"data":{"id":0,"username":"admin","password":"password","email":"[email protected]"}}
{"database":"test_db","table":"user_info","type":"update","ts":1508315160,"xid":1012,"commit":true,"data":{"id":0,"username":"user","password":"password","email":"[email protected]"},"old":{"username":"admin","email":"[email protected]"}}
{"database":"test_db","table":"user_info","type":"delete","ts":1508315171,"xid":1018,"commit":true,"data":{"id":0,"username":"user","password":"password","email":"[email protected]"}}
 인용
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Maxwell을 사용하여 MySQL 바이너리 로그를 JSON 형식으로 출력), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/KevinFQ/items/28da1655a3448e4ca5d5
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
$ curl -sLo - https://github.com/zendesk/maxwell/releases/download/v1.10.8/maxwell-1.10.8.tar.gz | tar zxvf -
1. 바이너리 로그 형식을 "ROW"(행 기반 로깅)로 변경합니다.
$ vi my.cnf
[mysqld]
server-id=1
log-bin=master
binlog_format=row
RDS를 사용하는 경우 매개 변수 그룹을 변경합니다.

2. MySQL/Aurora에서 Maxwell 사용자를 만들고 권한을 부여합니다.
mysql> CREATE USER 'maxwell' identified by 'password';
mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE on *.* to 'maxwell' identified by 'password';
mysql> GRANT ALL on maxwell.* to 'maxwell';
Maxwell 시작
다음 명령을 사용하여 STDOUT(표준 출력) 모드에서 Maxwell을 시작합니다.
$ cd maxwell-1.10.8
$ bin/maxwell --user='maxwell' --password='password' --host='xxxxxxxx.rds.amazonaws.com' --producer=stdout
 JSON 형식 binlog 출력
동작 확인으로서 MySQL측 이하의 SQL을 발행합니다.
mysql> INSERT INTO user_info VALUES (0, 'admin', 'password', '[email protected]');
Query OK, 1 row affected (0.01 sec)
mysql> update user_info set username='user', email='[email protected]';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> delete from user_info;
Query OK, 1 row affected (0.01 sec)
다음 JSON이 출력됩니다.
{"database":"test_db","table":"user_info","type":"insert","ts":1508315079,"xid":929,"commit":true,"data":{"id":0,"username":"admin","password":"password","email":"[email protected]"}}
{"database":"test_db","table":"user_info","type":"update","ts":1508315160,"xid":1012,"commit":true,"data":{"id":0,"username":"user","password":"password","email":"[email protected]"},"old":{"username":"admin","email":"[email protected]"}}
{"database":"test_db","table":"user_info","type":"delete","ts":1508315171,"xid":1018,"commit":true,"data":{"id":0,"username":"user","password":"password","email":"[email protected]"}}
 인용
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Maxwell을 사용하여 MySQL 바이너리 로그를 JSON 형식으로 출력), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/KevinFQ/items/28da1655a3448e4ca5d5
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
$ cd maxwell-1.10.8
$ bin/maxwell --user='maxwell' --password='password' --host='xxxxxxxx.rds.amazonaws.com' --producer=stdout
동작 확인으로서 MySQL측 이하의 SQL을 발행합니다.
mysql> INSERT INTO user_info VALUES (0, 'admin', 'password', '[email protected]');
Query OK, 1 row affected (0.01 sec)
mysql> update user_info set username='user', email='[email protected]';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> delete from user_info;
Query OK, 1 row affected (0.01 sec)
다음 JSON이 출력됩니다.
{"database":"test_db","table":"user_info","type":"insert","ts":1508315079,"xid":929,"commit":true,"data":{"id":0,"username":"admin","password":"password","email":"[email protected]"}}
{"database":"test_db","table":"user_info","type":"update","ts":1508315160,"xid":1012,"commit":true,"data":{"id":0,"username":"user","password":"password","email":"[email protected]"},"old":{"username":"admin","email":"[email protected]"}}
{"database":"test_db","table":"user_info","type":"delete","ts":1508315171,"xid":1018,"commit":true,"data":{"id":0,"username":"user","password":"password","email":"[email protected]"}}
인용
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Maxwell을 사용하여 MySQL 바이너리 로그를 JSON 형식으로 출력), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/KevinFQ/items/28da1655a3448e4ca5d5
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
Reference
이 문제에 관하여(Maxwell을 사용하여 MySQL 바이너리 로그를 JSON 형식으로 출력), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/KevinFQ/items/28da1655a3448e4ca5d5텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)