952、953版本多VC审计日志汇总任务
之前由于系统表gbase.audit_log_bak1损坏,导致转储一直失败产生了大量积压,下面的任务增加了转储之前对表gbase.audit_log_bak1的修复。
use vc xxxx;
use gclusterdb;
delimiter #
CREATE EVENT "summary_adit_lg"
ON SCHEDULE EVERY 60 MINUTE
STARTS '2025-8-6 00:00:00'
ON COMPLETION PRESERVE
ENABLE
LOCAL
DO
begin
declare errno int;
declare msg text;
declare exit handler for sqlexception begin get diagnostics condition 1 errno = gbase_errno, msg = message_text;
create table if not exists import_audit_log_errors(err_time datetime, hostname varchar(64), err_no int, msg_txt varchar(1024)) CHARSET=utf8mb4;
insert into import_audit_log_errors values (now(), @@hostname, errno, substr(msg, 0, 1024));
end;
create table if not exists "audit_log_express" (
"hostname" varchar(64) DEFAULT NULL,
"thread_id" int(11) DEFAULT NULL,
"taskid" bigint(20) DEFAULT NULL,
"start_time" datetime DEFAULT NULL,
"end_time" datetime DEFAULT NULL,
"user_host" varchar(4096) DEFAULT NULL,
"uid" bigint(20) DEFAULT NULL,
"user" varchar(128) DEFAULT NULL,
"host_ip" varchar(32) DEFAULT NULL,
"query_time" time DEFAULT NULL,
"rows" bigint(20) DEFAULT NULL,
"vc_id" varchar(64) DEFAULT NULL,
"db" varchar(512) DEFAULT NULL,
"table_list" varchar(4096) DEFAULT NULL,
"sql_text" varchar(8191) DEFAULT NULL,
"sql_type" varchar(16) DEFAULT NULL,
"sql_command" varchar(32) DEFAULT NULL,
"operators" varchar(256) DEFAULT NULL,
"status" varchar(16) DEFAULT NULL,
"conn_type" varchar(16) DEFAULT NULL
) ENGINE=EXPRESS DEFAULT CHARSET=utf8mb4 TABLESPACE='sys_tablespace';
set self sql_mode = '';
set _gbase_query_path = on;
set @cnt=0;select count(1) into @cnt from information_schema.tables where table_name='audit_log_bak2' and table_schema='gbase';
if @cnt=1 then drop self table gbase.audit_log_bak2;end if;
create self table gbase.audit_log_bak2 like gbase.audit_log;
set @cnt=0;select count(1) into @cnt from information_schema.tables where table_name='audit_log_bak1' and table_schema='gbase';
if @cnt=1 then repair table gbase.audit_log_bak1;insert into audit_log_express select @@hostname as hostname,thread_id,taskid,start_time,end_time,user_host,uid,user,host_ip,query_time,rows,vc_id,db,substr(table_list,0,4096),to_char(substr(sql_text, 0, 8191)),sql_type,sql_command,operators,status,conn_type from gbase.audit_log_bak1;drop self table gbase.audit_log_bak1; end if;
rename self table gbase.audit_log to gbase.audit_log_bak1, gbase.audit_log_bak2 to gbase.audit_log;
repair table gbase.audit_log_bak1;insert into audit_log_express select @@hostname as hostname,thread_id,taskid,start_time,end_time,user_host,uid,user,host_ip,query_time,rows,vc_id,db,substr(table_list,0,4096),to_char(substr(sql_text, 0, 8191)),sql_type,sql_command,operators,status,conn_type from gbase.audit_log_bak1;
drop self table gbase.audit_log_bak1;
end #
热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25044
- 42023-09-25浏览数:18519
- 52020-05-11浏览数:17526