MYSQL JOB

 最近上mysql 项目 陆续上些mysql 信息,DBA 还是要兼几门数据库.

 

代码
/* mysql job*/

-- create test table test_1,test_2
drop table if exists test_1,test_2;
create table test_1(id int,var varchar(50)) engine =myisam;
create table test_2(id int,var varchar(50)) engine =myisam;

--- insert test data
insert into test_1 select 1,'a';
insert into test_1 select 2,'b';

 

 

 

 每秒执行

代码
create event e_1 on schedule every 1 second do
insert into test3.test_2 select * from test3.test_1

--- start job
select * from test3.test_2

set global event_scheduler = 1;


--- stop job
set global event_scheduler = 0

 

查看mysql job信息

--- show events
use test3;

show events;

select * from information_schema.events

在某时间段里每秒执行

代码
truncate table test_2;

set global event_scheduler = 0

create event e_2 on schedule every 1 second STARTS '2010-08-12 16:29:33' ENDS DATE_ADD('2010-08-12 16:29:33',INTERVAL 1 SECOND) do
insert into test3.test_2 select * from test3.test_1

set global event_scheduler = 1

set global event_scheduler = 0

 

监控的多台mysql job 通过 dbcenter 库 陆续抓取mysql 系统信息 通过邮件报表发出。

mysqldbcenter 见

http://www.cnblogs.com/xwj1985/archive/2010/04/02/1703121.html

 

posted on 2010-08-12 16:52  徐郞顾  阅读(3000)  评论(0编辑  收藏  举报

导航