Tuesday 29 September 2015

Change master to example for mysql slave

mysql>CHANGE MASTER TO MASTER_HOST='x.x.x.x',MASTER_USER='replication_user', MASTER_PASSWORD='password', MASTER_LOG_FILE='master-bin.0001', MASTER_LOG_POS=  04;

Wednesday 9 September 2015

Monday 7 September 2015

Set mysql delayed replication for mysql old backup

MySQL 5.6 is  adding slave replication delay:

mysql> stop slave;

mysql> CHANGE MASTER TO MASTER_DELAY = 604800;

604800=7days in seconds

mysql> start slave;

mysql> show slave status\G;

         Seconds_Behind_Master: 19
         Master_SSL_Verify_Server_Cert: No
         Last_IO_Errno: 0
         Last_IO_Error: 
         Last_SQL_Errno: 0
         Last_SQL_Error: 
         Replicate_Ignore_Server_Ids: 
          Master_Server_Id: 1
          Master_UUID: 
          Master_Info_File: /data/mysqldata/master.info
          SQL_Delay: 604800

          SQL_Remaining_Delay: 604781



----------------------------------------------------------------------------------------
SQL_Delay=Seconds_Behind_Master+SQL_Remaining_Delay
604800=19+604781
-----------------------------------------------------------------------------------------

Enable Mysql Archive engine

How to enable archive engine

mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                    | Transactions | XA   | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                         | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance     | NO           | NO   | NO         |
| InnoDB     | NO      | Supports transactions, row-level locking, and foreign keys | NULL         | NULL | NULL       |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
5 rows in set (0.00 sec)


mysql> install plugin archive soname 'ha_archive.so';

mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                    | Transactions | XA   | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| ARCHIVE    | YES     | Archive storage engine                                     | NO           | NO   | NO         |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                         | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance     | NO           | NO   | NO         |
| InnoDB     | NO      | Supports transactions, row-level locking, and foreign keys | NULL         | NULL | NULL       |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
+------------+---------+------------------------------------------------------------+--------------+------+------------+




Tuesday 1 September 2015

How to Check MySQL engine type of tables?

My MySQL database contains tables using different storage engines (specifically myisam,innodb and others...).

mysql>SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = 'dbname';


A way to find out how many tables you have of different types:

mysql>select count(*), engine from information_schema.tables  group by engine;