随着平台运行时间的增加,mysql二进制日志会占用大量的空间,使得
ceph告警,/根目录可用空间低于20%,所以此时要清理空间。
[root@node-1 lib]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/os-root 138G 99G 32G 76% / tmpfs 16G 22M 16G 1% /dev/shm /dev/sda3 194M 28M 156M 16% /boot /dev/mapper/mongo-mongodb 121G 32G 84G 28% /var/lib/mongo [root@node-1 lib]# cd /var/lib/ [root@node-1 lib]# du -sh ./* 24K ./alternatives 52K ./astute 8.0K ./authconfig 16K ./ceilometer 313M ./ceph 8.0K ./cinder 8.0K ./corosync 4.0K ./dav 8.0K ./dbus 4.0K ./dhclient 4.0K ./dnsmasq 4.0K ./games 186M ./ganglia 2.1G ./glance 4.0K ./haproxy 4.0K ./heat 4.0K ./hiera 28K ./iscsi 8.0K ./keystone 4.0K ./libvirt 8.0K ./logrotate.status 4.0K ./misc 2.7M ./mlocate 32G ./mongo 4.0K ./mongodb 24G ./mysql 4.0K ./net-snmp 328K ./neutron 28K ./nfs 92K ./nova 8.0K ./ntp 4.0K ./openstack-dashboard 8.0K ./openvswitch 37M ./pacemaker 8.0K ./php 8.0K ./plymouth 28K ./polkit-1 8.0K ./postfix 2.6M ./puppet 448K ./rabbitmq 4.0K ./random-seed 43M ./rpm 4.0K ./rsyslog 16K ./samba 12K ./stateless 4.0K ./swift 8.0K ./udev 12M ./yum [root@node-1 lib]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 561143 Server version: 5.6.16-log MySQL Community Server (GPL), wsrep_25.5.rXXXX Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show binary logs -> ; +------------------+------------+ | Log_name | File_size | +------------------+------------+ | mysql-bin.000001 | 65309 | | mysql-bin.000002 | 1050551 | | mysql-bin.000003 | 143 | | mysql-bin.000004 | 3540294 | | mysql-bin.000005 | 143 | | mysql-bin.000006 | 3003498 | | mysql-bin.000007 | 143 | | mysql-bin.000008 | 1860503 | | mysql-bin.000009 | 143 | | mysql-bin.000010 | 44957 | | mysql-bin.000011 | 143 | | mysql-bin.000012 | 3382 | | mysql-bin.000013 | 143 | | mysql-bin.000014 | 79842271 | | mysql-bin.000015 | 143 | | mysql-bin.000016 | 546006 | | mysql-bin.000017 | 143 | | mysql-bin.000018 | 1073742179 | | mysql-bin.000019 | 1073742802 | | mysql-bin.000020 | 1073744465 | | mysql-bin.000021 | 1073742189 | | mysql-bin.000022 | 1073742449 | | mysql-bin.000023 | 1073742099 | | mysql-bin.000024 | 1073742227 | | mysql-bin.000025 | 1073742421 | | mysql-bin.000026 | 1073742434 | | mysql-bin.000027 | 1073744436 | | mysql-bin.000028 | 1073741968 | | mysql-bin.000029 | 1073742232 | | mysql-bin.000030 | 1073741967 | | mysql-bin.000031 | 1073742139 | | mysql-bin.000032 | 1073742557 | | mysql-bin.000033 | 1073741954 | | mysql-bin.000034 | 1073741886 | | mysql-bin.000035 | 1073742119 | | mysql-bin.000036 | 967440665 | | mysql-bin.000037 | 143 | | mysql-bin.000038 | 1073742079 | | mysql-bin.000039 | 1073742755 | | mysql-bin.000040 | 1073742013 | | mysql-bin.000041 | 1073742194 | | mysql-bin.000042 | 721149061 | +------------------+------------+ 42 rows in set (0.00 sec) //删除mysql bin-log日志,删除binlog.000038之前的,不包括binlog.000038// mysql> purge binary logs to ‘mysql-bin.000038‘; Query OK, 0 rows affected (1.33 sec) mysql> show binary logs; +------------------+------------+ | Log_name | File_size | +------------------+------------+ | mysql-bin.000038 | 1073742079 | | mysql-bin.000039 | 1073742755 | | mysql-bin.000040 | 1073742013 | | mysql-bin.000041 | 1073742194 | | mysql-bin.000042 | 721266404 | +------------------+------------+ 5 rows in set (0.00 sec) mysql> exit Bye [root@node-1 lib]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/os-root 138G 80G 51G 62% / tmpfs 16G 22M 16G 1% /dev/shm /dev/sda3 194M 28M 156M 16% /boot /dev/mapper/mongo-mongodb 121G 32G 84G 28% /var/lib/mongo