>  기사  >  데이터 베이스  >  InnoDB 모니터가 알 수 없게 열리는 문제 분석

InnoDB 모니터가 알 수 없게 열리는 문제 분석

黄舟
黄舟원래의
2017-02-07 11:21:041915검색

1. 문제점

최근 특정 라이브러리의 오류 로그에서 대량의 로그 출력이 발생한 것으로 확인되었습니다. 이는 데이터베이스의 InnoDB 모니터링으로 인해 발생했습니다. 켜졌다가 제때 꺼지지 않아 로그 기록과 데이터베이스 성능에 영향을 미쳤습니다. innodb_status_output 및 innodb_status_output_locks 상태가 모두 ON인지 확인하세요.

mysql>  show variables like"innodb_status_output%";
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| innodb_status_output       | ON |
| innodb_status_output_locks| ON  |
+----------------------------+-------+
2 rows in set (0.00 sec)

2. InnoDB 모니터링과 관련된 두 가지 매개 변수

InnoDB에는 StandardMonitor, LockMonitor, TablespaceMonitor 및 TableMonitor를 포함한 네 가지 모니터링 유형이 버전 5.7에서 제거되었습니다. 제거 후 information_schema 테이블을 통해. 표준 모니터는 테이블 잠금, 행 잠금, 트랜잭션 잠금 대기, 스레드 세마포 대기, 파일 IO 요청, 버퍼 풀 통계, InnoDB 기본 스레드 제거 및 활성 트랜잭션이 보유한 변경 버퍼 병합 활동을 모니터링합니다. 잠금 모니터는 추가 잠금 정보를 제공합니다.

InnoDB의 모니터는 필요할 때만 켜지므로 성능 오버헤드가 발생하므로 관찰이 완료된 후에는 모니터링을 꺼야 합니다.

StandardMonitor를 켜고 끄는 방법은 다음과 같습니다. innodb_status_output 매개변수는 InnoDB 모니터 켜기/끄기를 제어하는 ​​데 사용됩니다. 이 열기 방법은 모니터링 결과를 데이터 디렉터리의 MySQL 오류 로그에 출력하며, 15초마다 출력이 생성되므로 오류 로그에서 많은 양의 출력이 발견됩니다.

        set GLOBAL innodb_status_output=ON/OFF;

Lock Monitor를 켜고 끄는 방법은 다음과 같습니다. innodb_status_output을 켜기 전에 먼저 켜야 합니다. 끄는 경우 innodb_status_output_locks를 직접 끄면 됩니다. 끄면 표준 모니터도 함께 꺼집니다.

   set GLOBALinnodb_status_output=ON;
        set GLOBAL innodb_status_output_locks=ON;

3. 보안 감사 로그 추적성 분석

위 설명할 수 없는 열기 동작은 보안 감사 로그를 통해 추적해야 합니다.

<AUDIT_RECORD>
 <NAME>Query</NAME>
 <RECORD>12050XXXXX_2016-08-08T08:07:52</RECORD>
 <TIMESTAMP>2016-09-17T06:10:40 UTC</TIMESTAMP>
 <COMMAND_CLASS>select</COMMAND_CLASS>
 <CONNECTION_ID>1618XXX</CONNECTION_ID>
 <STATUS>0</STATUS>
 <SQLTEXT>select 1</SQLTEXT>
  <USER>XX[XX]@  [172.XX.XX.XXX]</USER>
 <HOST></HOST>
 <OS_USER></OS_USER>
 <IP>172.XX.XX.XXX </IP>
</AUDIT_RECORD>

위 로그는 공식 웹사이트 문서에 따라 다음과 같이 구문 분석됩니다.

<NAME>A string representing the typeof instruction that generated the audit event, such as a command that theserver received from a client.操作类型;
<RECORD_ID>A unique identifier forthe audit record. The value is composed from a sequence number and timestamp,in the format SEQ_TIMESTAMP. 
The sequence number is initialized to the size ofthe audit log file at the time the audit log plugin opens it and increments by1 for each record logged. 
The timestamp is a UTC value in yyyy-mm-ddThh:mm:ss formatindicating the time when the audit log plugin opened the file.记录ID;
<TIMESTAMP>The date and time that theaudit event was generated. For example, the event corresponding to execution ofan SQL statement 
received from a client has a <TIMESTAMP> value occurringafter the statement finishes, not when it is received. The value has the formatyyyy-mm-ddThh:mm:ss 
UTC (with T, no decimals). The format includes a time zonespecifier at the end. The time zone is always UTC.语句执行完成的时间;
<COMMAND_CLASS>A string thatindicates the type of action performed.操作指令类型;
<CONNECTION_ID>An unsigned integerrepresenting the client connection identifier. 
This is the same as theCONNECTION_ID()function value within the session;会话连接ID;
<STATUS>An unsigned integerrepresenting the command status: 0 for success, nonzero if an error occurred.This is the same as the value of the mysql_errno()C 
API function.0代表成功,非0代表对应错误码;
<SQLTEXT>A string representing thetext of an SQL statement. The value can be empty. Long values may be truncated.This element appears only if the <NAME> 
value is Query or Execute.执行的SQL语句;
等等

위 매개변수의 의미를 이해한 후 해당 키워드 "innodb_status_output"과 해당 컨텍스트 로그를 grep할 수 있습니다. 보안 감사 로그의 내용 형식은 위와 동일하며 위의 분석에 따라 설명할 수 없는 작업을 수행한 계정, 작업 시간, 작업 소스 IP 주소 및 기타 정보를 감사할 수 있습니다. 비정상적인 문제의 추적성을 실현합니다.

4. 요약

(1) InnoDB의 모니터는 필요할 때만 켜지고, 관찰이 완료된 후에는 시간에 맞춰 종료됩니다. 왜냐하면 데이터베이스 성능과 로그 출력

(2) 보안 감사 로그를 통해 유사한 비정상적인 작업을 추적할 수 있습니다. 보안 감사 로그의 기록 적시성은 유효 범위 내에 있어야 하며 저장 공간과 기록 적시성이 균형을 이루어야 합니다.

(3) 더 중요한 사항으로는 감사 로그 로깅 제어 및 계정 권한 관리 제어에 주의해야 합니다.

이상은 InnoDB 모니터가 알 수 없이 열리는 문제에 대한 분석입니다. 자세한 내용은 PHP 중국어 홈페이지(www.php.cn)를 참고해주세요!


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.