What are the considerations of the event scheduler in MySQL failover
Today, I will talk to you about the matters needing attention of the event scheduler in MySQL failover, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Event Scheduler (event) is a new task scheduler in MySQL5.1, which solves functions that can only be accomplished by relying on system-scheduled tasks in previous versions.
Here's a case study:
Enable event:
Mysql > set global event_scheduler=ON
Query OK, 0 rows affected (0.01 sec)
Mysql > show variables like 'event%'
+-+ +
| | Variable_name | Value |
+-+ +
| | event_scheduler | ON |
+-+ +
In the master-slave architecture, create an event on master:
Mysql > show create event testevent\ G
* * 1. Row *
Event: testevent
Sql_mode: STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
Time_zone: SYSTEM
Create Event: CREATE DEFINER= `root` @ `% `EVENT `testevent` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-11 23 EVENT 50V 00' ON COMPLETION NOT PRESERVE ENABLE DO create table test02 as select * from test01
Character_set_client: utf8
Collation_connection: utf8_general_ci
Database Collation: utf8_general_ci
1 row in set (0.00 sec)
Use slave to synchronize, and then check the event status of master and slave
Master
Mysql > show events\ G
* * 1. Row *
Db: test
Name: testevent
Definer: root@%
Time zone: SYSTEM
Type: RECURRING
Execute at: NULL
Interval value: 1
Interval field: DAY
Starts: 2017-09-11 23:50:00
Ends: NULL
Status: ENABLED
Originator: 2
Character_set_client: utf8
Collation_connection: utf8_general_ci
Database Collation: utf8_general_ci
Slave
Mysql > show events\ G
* * 1. Row *
Db: test
Name: testevent
Definer: root@%
Time zone: SYSTEM
Type: RECURRING
Execute at: NULL
Interval value: 1
Interval field: DAY
Starts: 2017-09-11 23:50:00
Ends: NULL
Status: SLAVESIDE_DISABLED
Originator: 2
Character_set_client: utf8
Collation_connection: utf8_general_ci
Database Collation: utf8_general_ci
In other words, event can only be triggered on master, but not on slave. If it is triggered on slave, synchronization will be broken. When master / slave failover occurs, slave becomes master, and event state needs to be enabled manually:
Alter event' testevent' enable
After reading the above, do you have any further understanding of the considerations of the event scheduler in MySQL failover? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.