In my server Db takes too much space:
Filesystem Size Used Avail Use% Mounted on
/dev/root 58G 58G 461M 100% /
tmpfs 966M 0 966M 0% /dev/shm
tmpfs 387M 856K 386M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/nvme0n1p15 105M 6.1M 99M 6% /boot/efi
tmpfs 194M 4.0K 194M 1% /run/user/1000
Ans whilst I was investigating it I saw that /vae/lib/mysql
is the one who takes up the space:
ncdu 1.15.1 ~ Use the arrow keys to navigate, press ? for help
--- /var/lib
50.6 GiB [##########] /mysql
801.2 MiB [ ] /snapd
138.4 MiB [ ] /apt
90.1 MiB [ ] /mecab
39.4 MiB [ ] /dpkg
3.8 MiB [ ] /ubuntu-advantage
And I tried to investigate what is the thing that takes too much space. All of the databases do serve wordpress site therefore I cannot modify the schema too much.
But I cheched the db size though:
SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;
+--------------------+--------------+
| Database | Size (MB) |
+--------------------+--------------+
| blog1 | 166.00000000 |
| information_schema | 0.00000000 |
| mysql | 2.76562500 |
| performance_schema | 0.00000000 |
| blog2 | 31.79687500 |
| sys | 0.01562500 |
+--------------------+--------------+
6 rows in set (0.35 sec)
Both of them Are relatively small Databases. Therefore how on Jesus' Christ name the /var/lib/mysql takes too much space?
The setup is just a LEMP stack with mysql without replication.
Edit 1
I have looked upon /var/lib/mysql
and I see many records for binlog:
sudo du -sk /var/lib/mysql
53151572 /var/lib/mysql
$ sudo ls -l /var/lib/mysql | wc -l
623
# I susspect 653 lines would be too much if pasted here
$ sudo ls -l /var/lib/mysql | grep binlog | head
-rw-r----- 1 mysql mysql 43170892 Jun 4 00:00 binlog.000233
-rw-r----- 1 mysql mysql 35975939 Jun 5 00:00 binlog.000234
-rw-r----- 1 mysql mysql 36153241 Jun 6 00:00 binlog.000235
-rw-r----- 1 mysql mysql 37148526 Jun 7 00:00 binlog.000236
-rw-r----- 1 mysql mysql 34947871 Jun 8 00:00 binlog.000237
-rw-r----- 1 mysql mysql 34058129 Jun 9 00:00 binlog.000238
-rw-r----- 1 mysql mysql 36786212 Jun 10 00:00 binlog.000239
-rw-r----- 1 mysql mysql 34790230 Jun 11 00:00 binlog.000240
-rw-r----- 1 mysql mysql 37634381 Jun 12 00:00 binlog.000241
-rw-r----- 1 mysql mysql 35801131 Jun 13 00:00 binlog.000242
$ sudo ls -l /var/lib/mysql | grep binlog | wc -l
545
# 545 lines are binlog files therefore I have binlogs
And I have looked upon a way to mitigate it:
$ cat /etc/mysql/mysql.conf.d/rj.cnf
# Added by Rick James
[mysqld]
log_bin = # turn off
binlog_expire_logs_seconds = 86400 # 1 day
max_binlog_size = 1 # 100M
And I did:
mysql> SHOW BINARY LOGS;
PURGE BINARY LOGS BEFORE '2023-07-30 00:00:00';
Query OK, 0 rows affected, 1 warning (0.01 sec)
But still files keep filling up upon /var/lib/mysql
Would be safe if I rm -rf
them or if somehow could tell that binlog storage it /dev/null ?