目录
-
- 问题1:redo日志保存了什么数据信息?
- 问题2:联机重做日志文件可以同时写入吗?
- 问题3:相关动态性能视图
- 问题4:日志切换
- 问题5:查看归档日志信息
- 问题6:redo文件多路复用
- 问题7:实例恢复中起到的作用
- 问题8:redo文件
- 问题9:日志切换次数
-
问题1:redo日志保存了什么数据信息?
重做记录包含对数据库修改时的元数据信息
1 SCN(System Change Number)号和变化的时间戳(Time Stamp)
2 修改事务的事务ID
3 提交事务时的SCN号和时间戳
4 产生变化的操作类型
5 被修改数据段的名称和类型
问题2:联机重做日志文件可以同时写入吗?
不能,在任何时刻只有一个可以写入。【current】
问题3:相关动态性能视图
v$log
记录从控制文件中读取的所有重做日志文件组的基本信息。
v$logfile
包括每个成员日志文件的基本信息、状态、重做日志组好、成员文件名称等信息。
问题4:日志切换
1 当前重做日志文件被写满
2 指定时间进行日志切换
alter system set archive_lag_target=1800;
3 手工日志切换
alter system switch logfile;
alter system archive log all;
alter system archive log current;
问题5:查看归档日志信息
archive log list
显示当前连接实例的归档重做日志文件信息
v$database
数据库是否处与归档模式
v$archived_log
从控制文件中获取已归档日志的信息,如归档目标名称等
v$archived_dest
显示所有归档目标的位置和状态等信息
v$log_history
从控制文件中获得重做日志历史信息
问题6:redo文件多路复用
show parameter db_create
db_create_online_log_dest_n
问题7:实例恢复中起到的作用
问题8:redo文件
问题9:日志切换次数
每小时日志切换次数
set linesize 150
select THREAD
from v$log_history where first_time>=sysdate-1
group by THREAD
日志切换次数
SELECT * FROM (
SELECT * FROM (
SELECT thread
TO_CHAR(FIRST_TIME, 'MM-DD') AS "DAY"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '00', 1, 0)), '999') "00:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '01', 1, 0)), '999') "01:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '02', 1, 0)), '999') "02:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '03', 1, 0)), '999') "03:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '04', 1, 0)), '999') "04:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '05', 1, 0)), '999') "05:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '06', 1, 0)), '999') "06:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '07', 1, 0)), '999') "07:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '08', 1, 0)), '999') "08:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '09', 1, 0)), '999') "09:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '10', 1, 0)), '999') "10:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '11', 1, 0)), '999') "11:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '12', 1, 0)), '999') "12:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '13', 1, 0)), '999') "13:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '14', 1, 0)), '999') "14:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '15', 1, 0)), '999') "15:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '16', 1, 0)), '999') "16:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '17', 1, 0)), '999') "17:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '18', 1, 0)), '999') "18:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '19', 1, 0)), '999') "19:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '20', 1, 0)), '999') "20:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '21', 1, 0)), '999') "21:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '22', 1, 0)), '999') "22:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '23', 1, 0)), '999') "23:00"
FROM V$LOG_HISTORY
WHERE first_time>sysdate-7 and
extract(year FROM FIRST_TIME) = extract(year FROM sysdate)
GROUP BY thread
) ORDER BY TO_DATE(extract(year FROM sysdate) || DAY, 'YYYY MM-DD') DESC
)
order by 2 desc,1 asc;