IT

Defragmentace tabulek v MySql

Pořád zapomínám, takže zjištění stavu fragmentace: select ENGINE, TABLE_NAME,Round( DATA_LENGTH/1024/1024) as data_length , round(INDEX_LENGTH/1024/1024) as index_length, round(DATA_FREE/ 1024/1024) as data_free, (data_free/(index_length+data_length)) as frag_ratio from information_schema.tables where DATA_FREE > 0 order by frag_ratio desc; A potom: OPTIMIZE TABLE tabulka;

Continue Reading...

IT

Online replikace databáze MySQL

Na masteru v /etc/mysql/my.cnf: bind-address = xxx.xxx.xxx.xxx server-id = 1 log_bin = /var/log/mysql/mysql-bin.log binlog_do_db = databaze_co_chceme_replikovat a restart mysql Potom: GRANT REPLICATION SLAVE ON *.* TO ‚slave_user’@’%‘ IDENTIFIED BY ‚password‘; FLUSH PRIVILEGES; USE databaze_co_chceme_replikovat; FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS; Z výpisu si zapsat jméno logu a číslo udávající pozici v logu. ptom […]

Continue Reading...