导读
作者:杨漆
16年关系型数据库管理,从oracle 9i 、10g、11g、12c到Mysql5.5、5.6、5.7、8.0 到TiDB获得3个OCP、2个OCM;运维路上不平坦,跌过不少坑、熬过许多夜。把工作笔记整理出来分享给大伙儿,希望帮到大家少走弯路、少熬夜。
Oracle运维中常出现Tablespace空间满,导致挂库。
通常出现这类事件需要DBA紧急处理。
躺若DB数量上千台,表空间异常多,DBA手工排错耗时长、枯燥、易出错。
若是这类情况正好出现在半夜、周末,DBA怎一个苦字了得!
提问:有没有办法将DBA解放出来,让DB自动诊断,自动扩容表空间?
答: 用这套自动扩容脚本就好(我已多年不Coding,下午写的这套代码比较Low,仅抛砖引玉,各位大神可在此基础上改写以便更好地适应自己的DB环境)
实验环境
1.创建test_tab表,不断插入数据
declare
i int;
begin
for i in 1…5 loop
insert into test.test_tab select * from test.test_tab;
commit;
end loop;
end;
/
2.自动监控程序运行结果
Monitor tablespace and autoextend !
作者:John 杨漆
Automatically monitors the tablespace usage
Automatic capacity expansion When the tablespace usage exceeds 85%
For Oracle Database
For study and research only, shall not be used for production environment and commercial purposes
If there is any problem, please contact me on wechat john2000111
Disk usage GB显示 !
Monitor tablespace rate Finished !
空间使用情况
TBS_NAME TOTAL_GB USED_GB FREE_GB RATE MAXEXTEND_GB