现象是,系统里的java连接mysql超时了,
2021-11-17 20:04:35 ERROR [com.alibaba.druid.pool.DruidDataSource.handleConnectionException(DruidDataSource.java:1486)][pool-4-thread
-1] - discard connectioncom.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 60,054 milliseconds ago. The last packet sent successfully to the server w
as 60,054 milliseconds ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3559)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3459)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3900)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2494)
于是去mysql的机器,查看/var/log/messages日志,查对应的时间点的情况
Nov 17 20:10:10 mysql01 kernel: [] sync_buffer+0x43/0x50
Nov 17 20:10:10 mysql01 kernel: [] __wait_on_bit+0x61/0x90
Nov 17 20:10:10 mysql01 kernel: [] ? sync_buffer+0x0/0x50
Nov 17 20:10:10 mysql01 kernel: [] out_of_line_wait_on_bit+0x78/0x90
Nov 17 20:10:10 mysql01 kernel: [] ? wake_bit_function+0x0/0x50
Nov 17 20:10:10 mysql01 kernel: [] __wait_on_buffer+0x26/0x30
Nov 17 20:10:10 mysql01 kernel: [] jbd2_journal_commit_transaction+0xaa6/0x1520 [jbd2]
Nov 17 20:10:10 mysql01 kernel: [] ? try_to_del_timer_sync+0x7b/0xe0
Nov 17 20:10:10 mysql01 kernel: [] kjournald2+0xb8/0x220 [jbd2]
Nov 17 20:10:10 mysql01 kernel: [] ? autoremove_wake_function+0x0/0x40
Nov 17 20:10:10 mysql01 kernel: [] ? kjournald2+0x0/0x220 [jbd2]
Nov 17 20:10:10 mysql01 kernel: [] kthread+0xa0/0xc0
Nov 17 20:10:10 mysql01 kernel: [] child_rip+0x20/0x30
Nov 17 20:10:10 mysql01 kernel: [] ? kthread+0x0/0xc0
Nov 17 20:10:10 mysql01 kernel: [] ? child_rip+0x0/0x30
Nov 17 20:10:10 mysql01 kernel: INFO: task mysqld:15659 blocked for more than 120 seconds.
Nov 17 20:10:10 mysql01 kernel: Not tainted 2.6.32-754.24.3.el6.x86_64 #1
Nov 17 20:10:10 mysql01 kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Nov 17 20:10:10 mysql01 kernel: mysqld D 0000000000000000 0 15659 14648 0x00000080
Nov 17 20:10:10 mysql01 kernel: ffff880208b23988 0000000000000082 0000000000000000 ffffffff8160da00
Nov 17 20:10:10 mysql01 kernel: 0000000000000000 0000000000000000 000c585bb06e233e ffffffff8106f8de
Nov 17 20:10:10 mysql01 kernel: 00000001cf196efd 00000000000006d3 ffff88020a8b45f8 ffff880208b23fd8
Nov 17 20:10:10 mysql01 kernel: Call Trace:
Nov 17 20:10:10 mysql01 kernel: [] ? perf_event_task_sched_out+0x2e/0x70
Nov 17 20:10:10 mysql01 kernel: [] do_get_write_access+0x29d/0x520 [jbd2]
Nov 17 20:10:10 mysql01 kernel: [] ? wake_bit_function+0x0/0x50
Nov 17 20:10:10 mysql01 kernel: [] jbd2_journal_get_write_access+0x31/0x50 [jbd2]
Nov 17 20:10:10 mysql01 kernel: [] __ext4_journal_get_write_access+0x38/0x80 [ext4]
Nov 17 20:10:10 mysql01 kernel: [] ext4_reserve_inode_write+0x73/0xa0 [ext4]
Nov 17 20:10:10 mysql01 kernel: [] ext4_mark_inode_dirty+0x4c/0x1d0 [ext4]
发现mysql被阻塞了blocked for more than 120 seconds,mysql的io非常之高,用top查看系统的负载也到达了50的样子
用mpstat查看cpu情况
[root@mysql01 ~]# mpstat -P ALL 1 3
Linux 2.6.32-754.24.3.el6.x86_64 (mysql01) 11/19/2021 _x86_64_ (8 CPU)
10:34:09 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
10:34:10 AM all 2.63 0.00 0.75 9.39 0.00 0.00 0.00 0.00 87.23
10:34:10 AM 0 19.39 0.00 5.10 75.51 0.00 0.00 0.00 0.00 0.00
10:34:10 AM 1 1.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 98.00
10:34:10 AM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:10 AM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:10 AM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:10 AM 5 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 99.00
10:34:10 AM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:10 AM 7 0.00 0.00 0.00 0.99 0.00 0.00 0.00 0.00 99.01
10:34:10 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
10:34:11 AM all 1.25 0.00 0.63 11.17 0.00 0.00 0.13 0.00 86.83
10:34:11 AM 0 10.10 0.00 3.03 85.86 0.00 0.00 0.00 0.00 1.01
10:34:11 AM 1 0.99 0.00 0.00 0.99 0.00 0.00 0.00 0.00 98.02
10:34:11 AM 2 0.00 0.00 0.00 4.00 0.00 0.00 0.00 0.00 96.00
10:34:11 AM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:11 AM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:11 AM 5 0.00 0.00 0.99 0.99 0.00 0.00 0.00 0.00 98.02
10:34:11 AM 6 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 99.00
10:34:11 AM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:11 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
10:34:12 AM all 2.76 0.00 0.75 9.15 0.00 0.00 0.00 0.00 87.34
10:34:12 AM 0 20.41 0.00 5.10 73.47 0.00 0.00 1.02 0.00 0.00
10:34:12 AM 1 0.99 0.00 0.99 0.99 0.00 0.00 0.00 0.00 97.03
10:34:12 AM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:12 AM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:12 AM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:12 AM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:12 AM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
10:34:12 AM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
Average: all 2.21 0.00 0.71 9.90 0.00 0.00 0.04 0.00 87.13
Average: 0 16.61 0.00 4.41 78.31 0.00 0.00 0.34 0.00 0.34
Average: 1 0.99 0.00 0.33 0.99 0.00 0.00 0.00 0.00 97.68
Average: 2 0.00 0.00 0.00 1.34 0.00 0.00 0.00 0.00 98.66
Average: 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 5 0.00 0.00 0.66 0.33 0.00 0.00 0.00 0.00 99.00
Average: 6 0.00 0.00 0.00 0.33 0.00 0.00 0.00 0.00 99.67
Average: 7 0.00 0.00 0.00 0.33 0.00 0.00 0.00 0.00 99.67
好明显,都在等io
用iostat查看io情况,%util的值,一直在80%,99%之间变化
iostat -d -k -x 5
以为磁盘有问题,用dd测下速看看
[root@mysql01 ~]# cd /data
[root@mysql01 data]# dd if=/dev/zero of=./speed.txt bs=4096 count=1000000
1000000+0 records in
1000000+0 records out
4096000000 bytes (4.1 GB) copied, 26.6844 s, 153 MB/s
从上面的结果看,也还好,没问题
以为可能磁盘有坏道,用下面命令也扫了一遍,没问题
[root@mysql01 ~]# badblocks -s -v /dev/xvdb > /root/badsectors.txt
Checking blocks 0 to 524287999
Checking for bad blocks (read-only test): done
Pass completed, 0 bad blocks found.
结果也没有坏的块,这个过程,很耗时。
用show processlist命令查看mysql正在忙着什么,一看,也没什么任务在执行的
想看看mysql,研究写哪个文件时,最耗时的
root@(none):51: >use performance_schema;
Database changed
root@performance_schema:51: >select * from file_summary_by_instance order by SUM_TIMER_WAIT desc limit 5\G;
*************************** 1. row ***************************
FILE_NAME: /data/mysql/mysqldata/xxl_job/xxl_job_log.ibd
EVENT_NAME: wait/io/file/innodb/innodb_data_file
OBJECT_INSTANCE_BEGIN: 140371407685312
COUNT_STAR: 156488283
SUM_TIMER_WAIT: 55470322706881104
MIN_TIMER_WAIT: 1642740
AVG_TIMER_WAIT: 354469434
MAX_TIMER_WAIT: 1066118677536
COUNT_READ: 156434427
SUM_TIMER_READ: 55306253340826796
MIN_TIMER_READ: 1642740
AVG_TIMER_READ: 353542310
MAX_TIMER_READ: 1066118677536
SUM_NUMBER_OF_BYTES_READ: 2563021619200
COUNT_WRITE: 40187
SUM_TIMER_WRITE: 544849988496
MIN_TIMER_WRITE: 6698868
AVG_TIMER_WRITE: 13557830
MAX_TIMER_WRITE: 1324577628
SUM_NUMBER_OF_BYTES_WRITE: 670810112
COUNT_MISC: 13669
SUM_TIMER_MISC: 163524516065812
MIN_TIMER_MISC: 2722016
AVG_TIMER_MISC: 11963165852
MAX_TIMER_MISC: 370070878122
*************************** 2. row ***************************
FILE_NAME: /data/mysql/mysqldata/ib_logfile1
EVENT_NAME: wait/io/file/innodb/innodb_log_file
OBJECT_INSTANCE_BEGIN: 140371407592384
COUNT_STAR: 293601
SUM_TIMER_WAIT: 1330825010299224
MIN_TIMER_WAIT: 741114
AVG_TIMER_WAIT: 4532766920
MAX_TIMER_WAIT: 806650077750
COUNT_READ: 2
SUM_TIMER_READ: 8299888256
MIN_TIMER_READ: 3661680
AVG_TIMER_READ: 4149944128
MAX_TIMER_READ: 8296226576
SUM_NUMBER_OF_BYTES_READ: 66048
COUNT_WRITE: 146794
SUM_TIMER_WRITE: 110605673453220
MIN_TIMER_WRITE: 2758800
AVG_TIMER_WRITE: 753475096
MAX_TIMER_WRITE: 160836192858
SUM_NUMBER_OF_BYTES_WRITE: 161222144
COUNT_MISC: 146805
SUM_TIMER_MISC: 1220211036957748
MIN_TIMER_MISC: 741114
AVG_TIMER_MISC: 8311780774
MAX_TIMER_MISC: 806650077750
*************************** 3. row ***************************
FILE_NAME: /data/mysql/logs/mysql-bin.000242
EVENT_NAME: wait/io/file/sql/binlog
OBJECT_INSTANCE_BEGIN: 140371408972928
COUNT_STAR: 1086836
SUM_TIMER_WAIT: 1174377938782862
MIN_TIMER_WAIT: 481536
AVG_TIMER_WAIT: 1080547138
MAX_TIMER_WAIT: 15103281467670
COUNT_READ: 793620
SUM_TIMER_READ: 2696020907294
MIN_TIMER_READ: 481536
AVG_TIMER_READ: 3397086
MAX_TIMER_READ: 89632953036
SUM_NUMBER_OF_BYTES_READ: 176679183
COUNT_WRITE: 147090
SUM_TIMER_WRITE: 2161348565046
MIN_TIMER_WRITE: 2623368
AVG_TIMER_WRITE: 14693954
MAX_TIMER_WRITE: 21358085364
SUM_NUMBER_OF_BYTES_WRITE: 89397774
COUNT_MISC: 146126
SUM_TIMER_MISC: 1169520569310522
MIN_TIMER_MISC: 549252
AVG_TIMER_MISC: 8003507446
MAX_TIMER_MISC: 15103281467670
*************************** 4. row ***************************
FILE_NAME: /data/mysql/mysqldata/ibdata1
EVENT_NAME: wait/io/file/innodb/innodb_data_file
OBJECT_INSTANCE_BEGIN: 140371407590976
COUNT_STAR: 538087
SUM_TIMER_WAIT: 818008362311514
MIN_TIMER_WAIT: 1714218
AVG_TIMER_WAIT: 1520215422
MAX_TIMER_WAIT: 15103626782904
COUNT_READ: 26031
SUM_TIMER_READ: 19145895155068
MIN_TIMER_READ: 1714218
AVG_TIMER_READ: 735503604
MAX_TIMER_READ: 6907870230030
SUM_NUMBER_OF_BYTES_READ: 428556288
COUNT_WRITE: 450607
SUM_TIMER_WRITE: 8866758759958
MIN_TIMER_WRITE: 6168426
AVG_TIMER_WRITE: 19677350
MAX_TIMER_WRITE: 29837681852
SUM_NUMBER_OF_BYTES_WRITE: 15197650944
COUNT_MISC: 61449
SUM_TIMER_MISC: 789995708396488
MIN_TIMER_MISC: 3617790
AVG_TIMER_MISC: 12856119606
MAX_TIMER_MISC: 15103626782904
*************************** 5. row ***************************
FILE_NAME: /data/mysql/mysqldata/ib_logfile0
EVENT_NAME: wait/io/file/innodb/innodb_log_file
OBJECT_INSTANCE_BEGIN: 140371407591680
COUNT_STAR: 108503
SUM_TIMER_WAIT: 622487588494970
MIN_TIMER_WAIT: 625746
AVG_TIMER_WAIT: 5737053762
MAX_TIMER_WAIT: 15104228469660
COUNT_READ: 4
SUM_TIMER_READ: 20659505790
MIN_TIMER_READ: 625746
AVG_TIMER_READ: 5164876134
MAX_TIMER_READ: 20656567668
SUM_NUMBER_OF_BYTES_READ: 3584
COUNT_WRITE: 54248
SUM_TIMER_WRITE: 39016218299806
MIN_TIMER_WRITE: 2408934
AVG_TIMER_WRITE: 719219160
MAX_TIMER_WRITE: 7673037933858
SUM_NUMBER_OF_BYTES_WRITE: 49436160
COUNT_MISC: 54251
SUM_TIMER_MISC: 583450710689374
MIN_TIMER_MISC: 810084
AVG_TIMER_MISC: 10754653448
MAX_TIMER_MISC: 15104228469660
5 rows in set (0.24 sec)
ERROR:
No query specified
从上面结果来看,xxl_job是最耗时的。知道点眉目了,因为公司的定时任务是用的xxljob,定时任务里,有每几秒执行的任务,我猜它的日志记录一定很大,于是查看一下
root@xxl_job:55: >select count(*) from xxl_job_log;
+----------+
| count(*) |
+----------+
| 13766158 |
+----------+
1 row in set (30.32 sec)
我的天,这个表的记录有千万!!!这些记录,没做定时任务来清理,由于都是一些没用的记录,所以这个表的数据我全清了
清了之后,再用iostat查看
iostat -d -k -x 5
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
xvdb 0.00 24.00 0.20 24.00 0.80 188.00 15.60 0.02 1.00 0.00 1.01 0.58 1.40
xvda 0.00 0.00 0.00 0.60 0.00 2.40 8.00 0.00 3.00 0.00 3.00 3.00 0.18
dm-0 0.00 0.00 0.00 0.60 0.00 2.40 8.00 0.00 3.00 0.00 3.00 3.00 0.18
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
xvdb 0.00 40.60 1.20 55.20 9.60 377.60 13.73 0.04 0.77 3.00 0.72 0.44 2.50
xvda 0.00 0.80 0.00 0.80 0.00 5.60 14.00 0.00 1.75 0.00 1.75 1.25 0.10
dm-0 0.00 0.00 0.00 1.40 0.00 5.60 8.00 0.00 2.14 0.00 2.14 0.71 0.10
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
xvdb 0.00 102.60 0.20 38.40 0.80 559.20 29.02 0.05 1.21 1.00 1.21 0.23 0.90
xvda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
xvdb 0.00 20.40 0.20 23.40 0.80 173.60 14.78 0.01 0.63 0.00 0.63 0.36 0.84
xvda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
xvdb 0.00 33.20 0.20 24.40 0.80 225.60 18.41 0.02 0.76 1.00 0.75 0.41 1.00
xvda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
%util一下子就降下来了,用iotop查看mysql进程的io也下降了
[root@mysql01 mysqldata]# mpstat -P ALL 1 3
Linux 2.6.32-754.24.3.el6.x86_64 (mysql01) 11/19/2021 _x86_64_ (8 CPU)
05:48:03 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
05:48:04 PM all 0.00 0.00 0.00 0.25 0.00 0.00 0.00 0.00 99.75
05:48:04 PM 0 0.00 0.00 0.00 1.01 0.00 0.00 0.00 0.00 98.99
05:48:04 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:04 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:04 PM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:04 PM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:04 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:04 PM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:04 PM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:04 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
05:48:05 PM all 0.00 0.00 0.00 1.38 0.00 0.00 0.13 0.00 98.50
05:48:05 PM 0 0.99 0.00 0.00 11.88 0.00 0.00 0.00 0.00 87.13
05:48:05 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:05 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:05 PM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:05 PM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:05 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:05 PM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:05 PM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:05 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
05:48:06 PM all 0.12 0.00 0.12 5.12 0.00 0.00 0.00 0.00 94.62
05:48:06 PM 0 0.00 0.00 1.01 40.40 0.00 0.00 0.00 0.00 58.59
05:48:06 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:06 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:06 PM 3 0.99 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.01
05:48:06 PM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:06 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:06 PM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:48:06 PM 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
Average: all 0.04 0.00 0.04 2.25 0.00 0.00 0.04 0.00 97.62
Average: 0 0.33 0.00 0.33 17.73 0.00 0.00 0.00 0.00 81.61
Average: 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 3 0.33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.67
Average: 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
[root@mysql01 mysqldata]#
cpu的iowait也下降了
定义一个事件,让mysql定时清理30天前的日志记录
DELIMITER $$
CREATE EVENT `e_xxl_job_log_d_day` ON SCHEDULE EVERY 1 DAY STARTS '2020-11-20 05:00:00' ENDS '2036-01-01 05:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
DELETE FROM `xxl_job`.`xxl_job_log` WHERE trigger_time<=CONCAT(DATE_SUB(CURDATE(), INTERVAL 30 DAY),' 00:00:00');
END$$
DELIMITER;
记录一下,希望对有需要的朋友也起一点提示