OracelDB知识:logMiner_AWRReport_一些小知识

因一台Oracle database的archive log异常增长,没人会这个.就只有硬着头皮边google边试着找原因.
花了几天的时间,学会了不少东西.最后找到了问题,是个肉鸡的不行的问题.
1.logMiner
当oracle启用archive log后,redo log写满了之后就会保存进archive log.这样在后续恢复的时候就可以通过log恢复到任意时间点.好处显而易见,坏处就是增加写开销和空间要求.
Oracle 的ARC Log不能直接读取,是数据库格式的,LogMiner就是用来读取它的.

sqlplus /nolog
conn / as sysdba;
set linesize 200;   --宽
set pagesize 100; --高
set num 50;          --数字长度
col SEG_OWNER format a10;   文本字段宽度
col table_name format a30;
col operation_code format 999;  数字字段格式
col x format 9999999;


exec sys.dbms_logmnr.add_logfile(logfilename =>'/oracle/oraarc/kyosfcs/1_11924_870522699.dbf'); --载入log,绝对路径.
exec sys.dbms_logmnr.start_logmnr(options => sys.dbms_logmnr.dict_from_online_catalog); --使用当前db的字典
select seg_owner,count(*)  from v$logmnr_contents group by seg_owner;

select seg_owner,table_name,operation_code,count(*) as x from v$logmnr_contents group by seg_owner,table_name,operation_code  order by x desc;

select sql_undo,sql_redo from v$logmnr_contents where scn in (select max(scn) from v$logmnr_contents);
execute dbms_logmnr.end_logmnr ;--结束
字段定义如下:
https://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_1154.htm#REFRN30132
SEG_OWNER/ SEG_NAME/ TABLE_NAME/ SEG_TYPE/ TABLE_SPACE/ ROW_ID/ SESSION_INFO/ OPERATION_CODE/ SQL_REDO/ SQL_UNDO 这些比较有用,意如字面.
一般分析个一两个大概问题出在哪个表,是什么样的操作引起就有头绪了.

2. AWR
AWR 也是Oracle自带的,用法很简单,执行SQL输入时间区间就完了,生成的html文档很方便看.
sqlplus /nolog
conn / as sysdba;
SQL> @$ORACLE_HOME/rdbms/admin/awrrpt.sql

Current Instance
~~~~~~~~~~~~~~~~

   DB Id    DB Name Inst Num Instance
----------- ------------ -------- ------------
  257816635 KYOSFCS 1 kyosfcs

Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'

Type Specified:  html


Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   DB Id     Inst Num DB Name    Instance Host
------------ -------- ------------ ------------ ------------
  257816635     1 KYOSFCS    kyosfcs kyo-sfcs02-l
inux
* 257816635     1 KYOSFCS    kyosfcs ksyod01
  257816635     1 KYOSFCS    kyosfcs ksyod01.youn
goptics.com
  257816635     1 KYOSFCS    kyosfcs ksyod011
  257816635     1 KYOSFCS    kyosfcs kyo-sfcs01-l
inux.youngop
tics.com
  257816635     1 KYOSFCS    kyosfcs KSYOD01.youn
goptics.com

Using  257816635 for database Id
Using        1 for instance number


Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed.  Pressing without
specifying a number lists all completed snapshots.



Listing the last 7 days of Completed Snapshots

Snap
Instance     DB Name     Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
kyosfcs      KYOSFCS       60750 25 5?  2018 00:00    1
      60751 25 5?  2018 01:00    1
      60752 25 5?  2018 02:01    1
      60753 25 5?  2018 03:01    1


Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 60902
Begin Snapshot Id specified: 60902

Enter value for end_snap: 60903
End   Snapshot Id specified: 60903



Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_60902_60903.html.  To use this name,
press to continue, otherwise enter an alternative.

Enter value for report_name: 
Using the report name awrrpt_1_60902_60903.html

AWR 的详细介绍,参见http://dbaplus.cn/news-10-734-1.html.
3.如果用sqlplus 要用到的一些table和view

.dba_开头表 
   dba_users           数据库用户信息 
   dba_segments    表段信息 
   dba_extents        数据区信息 
   dba_objects        数据库对象信息 
   dba_tablespaces 数据库表空间信息 
   dba_data_files     数据文件设置信息 
   dba_temp_files    临时数据文件信息 
   dba_rollback_segs         回滚段信息 
   dba_ts_quotas               用户表空间配额信息 
   dba_free_space              数据库空闲空间信息 
   dba_profiles                    数据库用户资源限制信息 
   dba_sys_privs                用户的系统权限信息 
   dba_tab_privs                 用户具有的对象权限信息 
   dba_col_privs                用户具有的列对象权限信息 
   dba_role_privs                用户具有的角色信息 
   dba_audit_trail                审计跟踪记录信息 
   dba_stmt_audit_opts       审计设置信息 
   dba_audit_object             对象审计结果信息 
   dba_audit_session     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值