Διόρθωση τoυ /var/lib/mysql όταν τρώει χώρο απο τον δίσκο.

Στην εργασία μια πρωϊα βλέπω έναν webserver down. Έτσι εφόσον τον έκανα restart είπα να δω τις πταίει ναουμε, γιατι ήταν down.

Έτσι άρχισα με τους συνήθης ύποπτους μνημη, δισκο κοκ. Έφτασα σε ένα σημείω τρέχοντας την εντολή:

ncdu /var/lib

Να ποιανει 50G!!!

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

Και λέω δεν μπορεί να δω πόσο μεγάλες οι βάσεις μου είναι. Έτσι μπήκαν σε mysql console και έτρεξα:

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)

Οι βάσεις μου ήταν βρέφη. Ως εκ τούτου αναρωτιώμουν:

Έτσι με μερικά LS commands:

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

Είδα ΠΟΛΥ log. Τα log αυτά είναι για στο master-slave replication (και οχι δεν μιλω για BDSM η ότι η βάση έχει yandere Girlfriend). Στην περίπτωσή μου η βάση είναι μονη σαν την καλαμιά στον κάμπο.

Έτσι είπα στην βάση:

Omae wa mou shindeiru

Και έβαλα στο αρχείο /etc/mysql/mysql.conf.d/disable_replication.cοnf την εγγραφή:

[mysqld]
disable_log_bin

Και έκανα restart την mysql:

sudo service mysql restart

Μετά στην Mysql κονσόλα (εντολή mysql) έτρεξα:

reset master;
4 «Μου αρέσει»

Καλημέρα, έχε στο νου σου ότι μπορεί να έχεις θέμα με data recovery αν όλα πάνε κατά διαόλου,
με το binary_log off.

  • Certain data recovery operations require use of the binary log. After a backup has been restored, the events in the binary log that were recorded after the backup was made are re-executed. These events bring databases up to date from the point of the backup. See Section 7.5, “Point-in-Time (Incremental) Recovery”.

The binary log is not used for statements such as SELECT or SHOW that do not modify data. To log all statements (for example, to identify a problem query), use the general query log. See Section 5.4.3, “The General Query Log”.

Running a server with binary logging enabled makes performance slightly slower. However, the benefits of the binary log in enabling you to set up replication and for restore operations generally outweigh this minor performance decrement.

The binary log is resilient to unexpected halts. Only complete events or transactions are logged or read back.

2 «Μου αρέσει»