In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
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.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.