1、MySQL调优参数有哪些
【双一参数重点说明下】
innodb_flush_log_at_trx_commit
0: 每次事务提交写入log buffer,每秒写入OS Buffer,并调fsync()刷盘
1: 每次事务提交log buffer --> os buffer -fsync()-> disk
2: 每次事务提交直接写入os buffer(跳过log buffer,由操作系统每秒调fsync()刷盘)
sync_binlog
0: 每次事务提交binlog_cache --> os buffer(由操作系统每秒进行刷盘)
1: 每次事务提交log buffer --> disk
N: N组事务提交后将数据更新到磁盘
连接层:
①max_connections=1000
②wait_timeout=600
③interactive_timeout=3600
server层:
①slow_query_log long_query_time
②sort_buffer join_buffer tmp_table
③max_execution_timeout
④sync_binlog=1
⑤binlog_format=row
innodb层:
①innodb_io_capacity :每秒刷脏页的数量
innodb_max_dirty_pages_pct 达到缓存区百分比 就触发刷盘
②innodb_buffer_pool_size:内存的50%~75%
innodb_log_buffer_size:1~2G redo日志文件是log_buffer的1-2倍大小
③transaction_isolation 隔离级别 RC
④innodb_flush_log_at_trx_commit
⑤行锁 innodb_lock_wait_timeout=10
2、MySQL有哪些锁?
按锁的资源层次分:
全局锁:Flush tables with read lock(FTWRL),典型使用场景是全库逻辑备份。
表锁:一种是表锁,一种是元数据锁。
1) MDL锁 S锁 X锁 IS锁 IX锁 AUTO_INC锁
2)元数据锁(metadata lock,MDL锁),MySQL使用MDL锁来管理对数据库对象的并发访问,并保证数据的一致性。
行锁:在索引上加的,有record、gap、next key lock
按锁的功能分:共享锁,排他锁,意向共享锁,意向排他锁
3、锁等待的监控数据如何获取?
0)show engine innodb status;
1)show processlist; 拿到前台的连接线程号,及等待什么锁
2)select * from performance_schema.threads where processlist_id=22; 查看对应