复制代码 代码如下:
(root:localhost:)test> SET GLOBAL event_scheduler = ON;
(root:localhost:)test> show processlist/G
*************************** 4. row ***************************
Id: 46147
User: event_scheduler
Host: localhost
db: NULL
Command: Daemon
Time: 1
State: Waiting on empty queue
Info: NULL
复制代码 代码如下:
create procedure `Slave_Monitor`()
begin
SELECT VARIABLE_VALUE INTO @SLAVE_STATUS
FROM information_schema.GLOBAL_STATUS
WHERE VARIABLE_NAME='SLAVE_RUNNING';
IF ('ON' != @SLAVE_STATUS) THEN
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=0;
SLAVE START;
END IF;
end; //
delimiter ;
复制代码 代码如下:
CREATE EVENT IF NOT EXISTS `Slave_Monitor`
ON SCHEDULE EVERY 5 SECOND
ON COMPLETION PRESERVE
DO
CALL Slave_Monitor();
复制代码 代码如下:
(root:localhost:)test> alter event `Slave_Monitor` ON
COMPLETION PRESERVE DISABLE;
(root:localhost:)test> alter event `Slave_Monitor` ON
COMPLETION PRESERVE ENABLE;
新闻热点
疑难解答