Rebuild Slave-DB & Replication
Since the mysqldump command locks the tables, it is not necessary that there is no traffic on the master database. With --master-data the command mysqldump stores the correct position for inserting the replication on the slave server.
If the hard disk of the slave is full, please refer to the instructions on this page below - "Slave Disk Full".
Login to MySQL with credentials USER and PWD, then stop slave and leave MySQL again. Use the following commands for this:
|
Restart MySQL Server with the following command:
on CentOS Server: service mysqld restart
Write a MySQL dump. Now perform the following steps on the master server. Create a backup directory and change to the same. The MySQL dumb is now executed with the following command
mysqldump -uUSER -pPWD --single-transaction --master-data=2 --databases JTELWeb JTELStats JTELLog --add-drop-database --add-drop-table --events --routines --triggers > filename.sql
As of release 3.12 the following command is required:
mysqldump -uUSER -pPWD --single-transaction --master-data=2 --databases JTELWeb JTELStats JTELStats2 JTELLog --add-drop-database --add-drop-table --events --routines --triggers > filename.sql
Here is a brief explanation of this:
In versions 3.12, 3.14 and 3.15 If someone logs on to the portal while the dump is being pulled, it will go wrong. Enclosed a SQL query. If the time changes after executing the query, a login has taken place. If this happens, the dump has to be pulled again and in the meantime it has to be permanently checked if a login has taken place. Only if this is not the case, the dump can be replicated error-free to the slave. SELECT Max(dtAcdLoggedIn) FROM Users; In versions 3.11 and below and version 3.16 this problem does not exist. |
We switch back to the slave server and now import the mysqldump.
|
CHANGE MASTER TO MASTER_LOG_FILE='binlog.000872', MASTER_LOG_POS=11940974;Memorize the parameters
MASTER_LOG_FILE
und MASTER_LOG_POS
.repl
on the Master DB Server. This is usually always the password of the user root - the easiest way to try it is to log on from the slave to the master with this password: mysql -h <masterIP> -u repl -p<Passwort>
- if this works, then you know.mysql -uUSER -pPWD
CHANGE MASTER TO MASTER_HOST='<name or ip of master servers>',MASTER_USER='repl',MASTER_PASSWORD='<passwort>',MASTER_LOG_FILE='<Name LogFile>', MASTER_LOG_POS=<Position LogFile>;
Here all parameters must be replaced with those from step 5.
|
Now we check the slave status (a few times) with the command
|
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
There are several reasons why the slave disk can become full.
Every time a query creates a tmp table, it is written to the temp directory, usually /tmp. This happens when the maximum size exceeds the maximum "in memory" table size. This is defined with the variables tmp_table_size
aswell as max_heap_table_size .
See also https://dev.mysql.com/doc/refman/5.6/en/internal-temporary-tables.html for more information.
The tables in /tmp are kept until the respective DB connection is closed or a DROP TEMPORARY TABLE is called. If the /tmp directory is full, it is likely that a DROP TEMPORARY TABLE is missing somewhere. This can also happen through customer queries to the DB.
The installation of tmpwatch creates help in a permanent way
Hints:
MySQL first writes the relay logs from the master to a file. Once replication is interrupted, but the slave relay process continues to operate, the disk is filled by relay logs.
This step should be done in any case, especially before the next one (ibdata too large) to make room.
The files for the database are usually located in /var/lib/mysql
If not, the location can be found in /etc/my.cnf The corresponding entry is datadir=(pfad)
Alle Relay Logs löschen:
cd /var/lib/mysql |
Restart MySQL service
service mysqld restart |
If enough space is available (at least 20%) then proceed with the slave recovery as described above.
The files for the database are usually located in /var/lib/mysql
Unsubscribe the MySQL service from the autostart:
service mysqld disable |
Restart the computer with :
reboot |
Only works if less than 100% disk is reached (possibly after reboot above) then
Log on to the mysql server:
mysql -u root -p |
Drop all JTEL databases:
SET FOREIGN_KEY_CHECKS=0; |
Press CTRL+C to return to the command line, and then
service mysqld stop |
Start MySql Server, and enable it again if necessary:
service mysqld start |
Check disk space, and proceed with Slave Restore as described above.
In this case the slave is simply too small. The hard disk must be expanded (as with extending the STORE role, apply only to the logical volume where the MySQL database data resides). Then perform the steps again, if the disk is too small, then restore the slave as described above.
Or the slave is completely rebuilt with a larger plate.