1:归档日志文件
在线日志 ——用于崩溃/实例恢复/介质恢复
归档日志 ——用于介质恢复
2:确认数据库是否为归档模式
archive log list; --查看数据归档信息
select log_mode from v$database; --查看数据库是否为归档模式
3:归档模式和非归档模式的相互切换
alter database noarchivelog;--数据库切换成非归档模式(MOUNT)
alter database archivelog; --数据库切换成归档模式(MOUNT)
4:归档文件的位置和名字
standby_archive_dest
归档文件名称log_archive_format %t_%s_%r.dbf --归档文件名称
archive_lag_target=0 表示禁用基于时间的日志切换功能
log_archive_config dataguard时候使用
log_archive_dest 主
log_archive_duplex_dest 从
log_archive_duplex_dest
log_archive_dest_1='location=/opt/soft/archive_dest'
service
alter system set log_archive_dest_1='location=/opt/soft/archive_dest' scope=spfile;
5:删除归档文件
5.1)手动删除
SQL>archive log list;
rman target /
RMAN>backup archivelog all;
cd /opt/soft/archive_dest
rm -f 1_*906824971.dbf
rman target /
RMAN>list archivelog all;
RMAN>crosscheck archivelog all;
RMAN>delete expired archivelog all;
RMAN>delete noprompt expired archivelog all;
5.2)自动删除
RMAN>delete archivelog all completed before 'SYSDATE-2';删除两条前的归档日志,不备份
SQL>select * from v$archived_log where status='A'
cd /opt/soft/archive_dest/
ls
RMAN>backup archivelog all delete all input;
cd /opt/soft/archive_dest/
ls
7:归档相关视图
v$archived_log -->从控制文件中获得归档的相关信息
v$archive_dest -->归档路径及状态
v$log_history -->控制文件中日志的历史信息
v$database -->查看数据库是否处于归档状态
v$archive_processes -->归档相关的后台进程信息
8:归档平率
SELECT trunc(first_time) "Date",
to_char(first_time, 'Dy') "Day",
count(1) "Total",
SUM(decode(to_char(first_time, 'hh24'),'00',1,0)) "h0",
SUM(decode(to_char(first_time, 'hh24'),'01',1,0)) "h1",
SUM(decode(to_char(first_time, 'hh24'),'02',1,0)) "h2",
SUM(decode(to_char(first_time, 'hh24'),'03',1,0)) "h3",
SUM(decode(to_char(first_time, 'hh24'),'04',1,0)) "h4",
SUM(decode(to_char(first_time, 'hh24'),'05',1,0)) "h5",
SUM(decode(to_char(first_time, 'hh24'),'06',1,0)) "h6",
SUM(decode(to_char(first_time, 'hh24'),'07',1,0)) "h7",
SUM(decode(to_char(first_time, 'hh24'),'08',1,0)) "h8",
SUM(decode(to_char(first_time, 'hh24'),'09',1,0)) "h9",
SUM(decode(to_char(first_time, 'hh24'),'10',1,0)) "h10",
SUM(decode(to_char(first_time, 'hh24'),'11',1,0)) "h11",
SUM(decode(to_char(first_time, 'hh24'),'12',1,0)) "h12",
SUM(decode(to_char(first_time, 'hh24'),'13',1,0)) "h13",
SUM(decode(to_char(first_time, 'hh24'),'14',1,0)) "h14",
SUM(decode(to_char(first_time, 'hh24'),'15',1,0)) "h15",
SUM(decode(to_char(first_time, 'hh24'),'16',1,0)) "h16",
SUM(decode(to_char(first_time, 'hh24'),'17',1,0)) "h17",
SUM(decode(to_char(first_time, 'hh24'),'18',1,0)) "h18",
SUM(decode(to_char(first_time, 'hh24'),'19',1,0)) "h19",
SUM(decode(to_char(first_time, 'hh24'),'20',1,0)) "h20",
SUM(decode(to_char(first_time, 'hh24'),'21',1,0)) "h21",
SUM(decode(to_char(first_time, 'hh24'),'22',1,0)) "h22",
SUM(decode(to_char(first_time, 'hh24'),'23',1,0)) "h23",
decode(trunc(first_time),
trunc(sysdate), round(count(1) / (24 * to_number(to_char(sysdate, 'sssss')+1) / 86400),2),
round(count(1) / 24, 2)) "Avg"
FROM V$log_history
group by trunc(first_time), to_char(first_time, 'Dy')
Order by 1;
9 增加日志组和成员
创建新的日志组
alter database add logfile group 4 ('/opt/oracle/oradata/WEISIDB/redo04.log') size 100m;
增加日志成员
alter database add logfile member '/opt/oracle/oradata/WEISIDB/redo04_02.log' to group 4;
删除日志组
alter database drop logfile group 1;
10 切换归档模式步骤
1:关闭数据库
shutdown immediate;
2: 启动到mount
startup mount;
3: 修改成归档模式
alter database archivelog;
4: 打开数据库
alter database open ;
5:全备数据库
backup database plus archivelog delete input; (备份全库及控制文件、服务器参数文件与所有归档的重做日志,并删除旧的归档日志)