Summary of mysql master-slave configuration problems and how to view database logs

One : Could not execute Delete_rows event on table yxjmanage.ums_user; Can't find record in 'ums_user', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000207, end_log_pos 97165262 Rows deleted from master, from The library does not exist, or has been manually deleted.
Execute the following statement after supplementing the data from the library

mysql>stop slave;
mysql>set global sql_slave_skip_counter=1
注释:跳过执行错误事务,继续执行,不会使主从复制停止
mysql>start slave
当要跳过多条错误事务时
mysql>set global sql_slave_skip_counter='数字'是错误的用法
正确应该到配置文件下去加入配置文件在
[mysqld]
#
# * Basic Settings
#
slave-skip-errors	=1062,1032#跳过指定error no类型的错误这里指的是错误类型1062

Two: View the binary binlog file of mysql

首先查看在主库中查看binlog日志文件有哪些,mysql> show binary logs;
其次 退出mysql找到binlog文件所在地cd /var/log/mysql
语句如下:
mysqlbinlog  -v --base64-output=DECODE-ROWS /var/log/mysql/master-bin.000387 | grep -A '20' 32823638

Database buffer pool optimization

show variables like "%_buffer%";   查看:innodb_buffer_pool_size

设置时innodb_buffer_pool_size值要是innodb_buffer_pool_instances  * innodb_buffer_pool_chunk_size的倍数才能设置成功!重点!!否则mysql会自动调整值的大小

set global innodb_buffer_pool_size = 2147483648;  系统内存的60%——80%最优?这个不是绝对的具体看下

When the system is online, we can further analyze the real-time status information about the Buffer Pool provided by the Innodb storage engine to determine whether the usage of the Innodb Buffer Pool in the system is normal and efficient:


> show status like  'Innodb_buffer_pool_%';
注意以下几个值Innodb Buffer  Pool 的 Read (读)命中率
var percent = (Innodb_buffer_pool_read_requests - Innodb_buffer_pool_reads) /Innodb_buffer_pool_read_requests 
percent越趋近于100%命中率越高,性能约好。

Check if the log is enabled
show variables like “general_log%”;
insert image description here

Turn on the log:
set global general_log = 'ON';

Check whether the log of slow query is enabled and its address;
show variables LIKE “%slow%”
insert image description here

Open slow query log
set global slow_query_log='ON';


Record set global long_query_time=1 if the query setting time exceeds 1s ;

Guess you like

Origin blog.csdn.net/m0_49412847/article/details/121261990