為了減少監(jiān)控或同級多套數(shù)據(jù)庫存儲容量或者備份檢查的工作量,可以考慮使用一個專門做監(jiān)控服務(wù)器,通過配置一些需要到的配置表,然后以sh腳本或者存儲過程形式固化采集多套庫的存儲容量情況或者備份情況的方式,形成簡易的采集流程,大大簡化了重復(fù)而繁瑣的數(shù)據(jù)庫管理工作。配置方法:1、監(jiān)控服務(wù)器;2、監(jiān)控服務(wù)器通往各個被監(jiān)控服務(wù)器dblink的配置表,(如下 suxing.conf11g_dblink_tab或者suxing.CONF_BACKUPCHECK_DBLINK_TAB)----由于兩個配置表的功能有所差異,所以分開兩個配置表;3、專門作監(jiān)控的用戶;4、腳本或者存儲過程(如下多個服務(wù)器容量統(tǒng)計腳本和多個服務(wù)器備份檢查結(jié)果采集腳本);5、存放采集數(shù)據(jù)的表(如下 suxing.space_gather11G_tab或者 suxing.db_backup_check_alltab)。#####多個服務(wù)器容量統(tǒng)計腳本:declare
v_sql varchar2(4000);
begin
for rec in (select * from suxing.conf11g_dblink_tab) loop
v_sql :='insert into suxing.space_gather11G_tab
select * from (
with
I as (select instance_name from v$instance@'||rec.db_link||'),
A as (select round(sum(bytes)/1024/1024/1024,2) aa from dba_data_files@'||rec.db_link||'),
B as (select round(sum(bytes)/1024/1024/1024,2) bb from dba_free_space@'||rec.db_link||'),
C as (select round(sum(BYTES / 1024 / 1024 / 1024), 2) cc
from v$datafile@'||rec.db_link||' a, v$tablespace@'||rec.db_link||' b
where a.TS# = b.TS#
and a.CREATION_TIME <
to_date(''2017-07-15 10:00:00'', ''YYYY-MM-DD HH24:MI:SS'')),
D as (select round(sum(BYTES / 1024 / 1024 / 1024), 2) dd
from v$datafile@'||rec.db_link||' a, v$tablespace@'||rec.db_link||' b
where a.TS# = b.TS#
and a.CREATION_TIME <
to_date(''2017-04-15 00:00:00'', ''YYYY-MM-DD HH24:MI:SS'')),
E as (select round(sum(BYTES / 1024 / 1024 / 1024), 2) ee
from v\$datafile@'||rec.db_link||' a, v\$tablespace@'||rec.db_link||' b
where a.TS# = b.TS#
and a.CREATION_TIME <
to_date(''2017-06-15 00:00:00'', ''YYYY-MM-DD HH24:MI:SS'')),
G as (select GROUP_NUMBER,NAME,TOTAL_MB/1024 totalGB,FREE_MB/1024 freeGB
from v$asm_diskgroup@'||rec.db_link||' where name like ''DATA%'')
select I.instance_name,A.aa Total_G,A.aa-B.bb Used_G,B.bb Free_G,G.totalGB,G.freeGB,(C.cc - D.dd)/3 AVRG3,C.cc - E.ee,sysdate,to_char(sysdate,''yymmdd'')
from I,A,B,C,D,E,G
)';
--dbms_output.put_line(v_sql);
execute immediate v_sql;
commit;
end loop;
end;
#####多個服務(wù)器備份檢查結(jié)果采集腳本:declare
v_sql varchar2(4000);
begin
for rec in (select * from suxing.CONF_BACKUPCHECK_DBLINK_TAB) loop
v_sql :='insert into suxing.db_backup_check_alltab
select * from (
with
I as (select instance_name from v$instance@'||rec.db_link||'),
BC as (
select start_time, t.INPUT_TYPE, status
from v$rman_backup_job_details@'||rec.db_link||' t
where t.start_time in (select max(start_time)
from v$rman_backup_job_details@'||rec.db_link||')
and t.INPUT_TYPE = ''ARCHIVELOG''
group by t.start_time, t.INPUT_TYPE, t.STATUS
union all
select start_time, t.INPUT_TYPE, status
from v$rman_backup_job_details@'||rec.db_link||' t
where t.start_time in (select max(start_time)
from v$rman_backup_job_details@'||rec.db_link||' t
where t.INPUT_TYPE = ''DB INCR'')
group by t.start_time, t.INPUT_TYPE, t.STATUS)
select I.instance_name,BC.*,to_char(sysdate,''mmddhh34'') from I,BC)';
--dbms_output.put_line(v_sql);
execute immediate v_sql;
commit;
end loop;
end;
注:這些腳本當(dāng)中,with子句的作用非常關(guān)鍵。
文章標(biāo)題:監(jiān)控或統(tǒng)計多套數(shù)據(jù)庫的存儲容量與備份
新聞來源:http://aaarwkj.com/article40/gppgeo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、做網(wǎng)站、服務(wù)器托管、企業(yè)建站、品牌網(wǎng)站設(shè)計、
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源:
創(chuàng)新互聯(lián)