暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
利用Oracle可恢复空间分配技术自动分配表空间
654
7页
2次
2019-09-12
5墨值下载
利用
Oracle
可恢复空间分配技术自动分配表空间
Oracle
可恢复空间分配技术让我们可以通过创建一个在会话挂起时自动运行的
after
suspend on database
触发器处理问题,如通过电子邮件报告挂起事件、检查并自动修复挂
起故障等,如可以在插入数据导致表空间容量不足时,通过触发器程序判断并自动给表空间分
配容量。以下例子给出这方面的应用。
一、可恢复空间自动分配功能的部署
因为
after suspend on database
触发器中不允许调用
DDL
语句,因此空间分配的操作不能
通过触发器调用来执行。这里的办法就是通过调度程序来启动作业,并且这个调度作业必须是
基于事件触发的。
通过设置实例参数
resumable_timeout
为所有会话启用可恢复空间。这是一个动态参数,如
设置会话在遇到空间问题时挂起
1
分钟
alter system set resumable_timeout = 60;
创建一个用来进行可恢复空间管理的用户并授权
conn / as sysdba
create user alloc identified by alloc;
grant connect, resource to alloc;
grant create job to alloc;
grant create trigger to alloc;
grant aq_administrator_role to alloc;
grant execute on dbms_aq to alloc;
grant select on dba_resumable to alloc;
grant select on dba_data_files to alloc;
grant dba to alloc;
连接到
alloc
用户
conn alloc/alloc
创建一个存放可恢复空间分配的
SQL
语句的表
create table resumable_sql(sql_text varchar2(200));
定义一个记录消息信息的类型
create or replace type event_queue_type as object(event_name
varchar2(30));
/
创建队列表用于记录消息,指定表名和消息的类型名
begin
dbms_aqadm.create_queue_table(queue_table =>
'event_queue_table',
queue_payload_type => 'event_queue_type',
multiple_consumers => true);
end;
/
创建消息队列,指定队列名和队列表
begin
dbms_aqadm.create_queue(queue_name => 'event_queue',
queue_table => 'event_queue_table');
end;
/
启动队列
begin
dbms_aqadm.start_queue(queue_name => 'event_queue');
end;
/
创建一个错误日志表,对程序发生的错误进行定位
create table err_logs(proc_name varchar2(50), log_time date,
error_stack varchar2(200), error_backtrace varchar2(200));
创建执行空间分配的存储过程
create or replace procedure alloc_space authid current_user is
my_count number;
my_sql varchar2(200);
begin
--
获取空间分配的执行语句
select count(*) into my_count from resumable_sql;
if my_count != 0 then
select sql_text into my_sql from resumable_sql where rownum = 1;
--
执行空间分配
execute immediate my_sql;
delete from resumable_sql;
commit;
end if;
exception
when others then
--
记入错误日志
insert into err_logs
of 7
5墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜