- 最后登录
- 2015-3-2
- 在线时间
- 246 小时
- 威望
- 95
- 金钱
- 1510
- 注册时间
- 2011-10-14
- 阅读权限
- 50
- 帖子
- 152
- 精华
- 1
- 积分
- 95
- UID
- 33
|
1#
发表于 2013-3-4 10:24:37
|
查看: 5762 |
回复: 16
ML 论坛里的所写的Oracle-base的脚本,由于一些原因(你懂的),给不会的童鞋贴在这里- -- -----------------------------------------------------------------------------------
- -- File Name :[url]http://www.oracle-base.com/dba/10g/generate_multiple_awr_reports.sql[/url]
- -- Author : DR Timothy S Hall
- -- Description : Generates AWR reports for all snapsots between the specified start and end point.
- -- Requirements : Access to the v$ views, UTL_FILE and DBMS_WORKLOAD_REPOSITORY packages.
- -- Call Syntax : Create the directory with the appropriate path.
- -- Adjust the start and end snapshots as required.
- -- @generate_multiple_awr_reports.sql
- -- Last Modified: 02/08/2007
- -- -----------------------------------------------------------------------------------
- CREATE OR REPLACE DIRECTORY awr_reports_dir AS '/tmp/';
- DECLARE
- -- Adjust before use.
- l_snap_start NUMBER := 1;
- l_snap_end NUMBER := 10;
- l_dir VARCHAR2(50) := 'AWR_REPORTS_DIR';
-
- l_last_snap NUMBER := NULL;
- l_dbid v$database.dbid%TYPE;
- l_instance_number v$instance.instance_number%TYPE;
- l_file UTL_FILE.file_type;
- l_file_name VARCHAR(50);
- BEGIN
- SELECT dbid
- INTO l_dbid
- FROM v$database;
- SELECT instance_number
- INTO l_instance_number
- FROM v$instance;
-
- FOR cur_snap IN (SELECT snap_id
- FROM dba_hist_snapshot
- WHERE instance_number = l_instance_number
- AND snap_id BETWEEN l_snap_start AND l_snap_end
- ORDER BY snap_id)
- LOOP
- IF l_last_snap IS NOT NULL THEN
- l_file := UTL_FILE.fopen(l_dir, 'awr_' || l_last_snap || '_' || cur_snap.snap_id || '.htm', 'w', 32767);
-
- FOR cur_rep IN (SELECT output
- FROM TABLE(DBMS_WORKLOAD_REPOSITORY.awr_report_html(l_dbid, l_instance_number, l_last_snap, cur_snap.snap_id)))
- LOOP
- UTL_FILE.put_line(l_file, cur_rep.output);
- END LOOP;
- UTL_FILE.fclose(l_file);
- END IF;
- l_last_snap := cur_snap.snap_id;
- END LOOP;
-
- EXCEPTION
- WHEN OTHERS THEN
- IF UTL_FILE.is_open(l_file) THEN
- UTL_FILE.fclose(l_file);
- END IF;
- RAISE;
- END;
- /
复制代码 个人测试机上的运行结果- [root@OEL48 tmp]# ll
- total 1711
- -rw-r--r-- 1 oracle oinstall 258016 Mar 4 11:29 awr_1_2.htm
- -rw-r--r-- 1 oracle oinstall 124614 Mar 4 11:32 awr_2_3.htm
- -rw-r--r-- 1 oracle oinstall 197851 Mar 4 11:34 awr_3_4.htm
- -rw-r--r-- 1 oracle oinstall 158034 Mar 4 11:37 awr_4_5.htm
- -rw-r--r-- 1 oracle oinstall 253271 Mar 4 11:37 awr_5_6.htm
- -rw-r--r-- 1 oracle oinstall 201584 Mar 4 11:39 awr_6_7.htm
- -rw-r--r-- 1 oracle oinstall 125158 Mar 4 11:41 awr_7_8.htm
- -rw-r--r-- 1 oracle oinstall 205918 Mar 4 11:42 awr_8_9.htm
- -rw-r--r-- 1 oracle oinstall 169717 Mar 4 11:42 awr_9_10.htm
- -rw-r----- 1 oracle oinstall 446 Feb 27 11:07 cpuinfo.txt
- drwx------ 3 oracle oinstall 1024 Feb 28 13:48 gconfd-oracle
- drwx------ 2 root root 1024 Feb 27 10:12 gconfd-root
- -rw-r----- 1 oracle oinstall 18 Feb 27 10:57 glibc.txt
- drwx------ 2 oracle oinstall 1024 Feb 28 13:48 keyring-LgIRTh
- -rw-r----- 1 oracle oinstall 20 Feb 27 11:07 LinuxVendor_output.txt
- drwx------ 2 root root 12288 Feb 27 09:24 lost+found
- srwxr-xr-x 1 oracle oinstall 0 Feb 28 13:52 mapping-oracle
- srwxr-xr-x 1 root root 0 Feb 27 01:59 mapping-root
- -rw-r----- 1 oracle oinstall 21594 Feb 27 10:57 pkginfo.txt
- -rw-r----- 1 oracle oinstall 100 Feb 27 11:07 swapinfo.txt
- -rw-r----- 1 oracle oinstall 11 Feb 27 11:07 tmpFileKernelParms.txt
- -rw-r--r-- 1 root root 0 Feb 27 02:03 vboxguest-Module.symvers
复制代码 存放目录 以及间隔都可以自己修改。。。 在生产库上跑之前 请在测试库上测试 |
Oracle ALLSTARS II:171092051(Oracle基础讨论群)
提问之前请阅读以下链接
http://t.askmaclean.com/thread-714-1-1.html
http://train.askmaclean.com/node/5
Oracle ALLSTARS III:180013778(扯蛋打酱油专用群)
|
|