Oracle笔记

2010年9月10日 06:11

“如果使用专用服务器连接,会在USER_DUMP_DEST参数指定的目录中生成跟踪文件。如果使用共享服务器连接,则在BACKGROUND_DUMP_DEST参数指定的目录中生成跟踪文件。”

网上来的,这句话似乎是有问题的,因为我的测试数据库自安装起就是用专用服务器连接,但是BACKGROUND_DUMP_DEST依旧有大量Trace文件。还是“bdump是有关后台进程的trace,udump是有关用户的”更正确些。

Oracle笔记

2010年9月10日 06:06

表空间可以Offline就可以ReadOnly的说法显然是错误的,SYSAUX表空间就是最好的证据。

Oracle笔记

2010年9月10日 05:08

alter database backup controlfile to trace;

虽然曾经说过凡是“alter database”的都不能在数据库打开的情况下修改memory,但是这句语句似乎是例外。输入后,trace文件即生成在了$ORACLE_BASE/admin/<sid>/bdump下,可以通过时间(Linux命令: ll -t)去寻找这个文件,打开就可以找到控制文件的恢复SQL语句,似乎还有两个版本,一个NORESETLOGS版本和一次RESETLOGS版本。

 

/*NORESETLOGS版本*/
STARTUP NOMOUNT  //这里没分号?大概startup语句就是不加分号的。
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS  ARCHIVELOG

    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/home/oracle/oracle/oradata/orcl/redo01.log'  SIZE 50M,
  GROUP 2 '/home/oracle/oracle/oradata/orcl/redo02.log'  SIZE 50M,
  GROUP 3 '/home/oracle/oracle/oradata/orcl/redo03.log'  SIZE 50M
-- STANDBY LOGFILE
DATAFILE
  '/home/oracle/oracle/oradata/orcl/system01.dbf',
  '/home/oracle/oracle/oradata/orcl/undotbs01.dbf',
  '/home/oracle/oracle/oradata/orcl/sysaux01.dbf',
  '/home/oracle/oracle/oradata/orcl/users01.dbf',
  '/home/oracle/oracle/oradata/orcl/example01.dbf'
CHARACTER SET WE8ISO8859P1
;
 
/*RESETLOGS版本*/
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/home/oracle/oracle/oradata/orcl/redo01.log'  SIZE 50M,
  GROUP 2 '/home/oracle/oracle/oradata/orcl/redo02.log'  SIZE 50M,
  GROUP 3 '/home/oracle/oracle/oradata/orcl/redo03.log'  SIZE 50M
-- STANDBY LOGFILE
DATAFILE
  '/home/oracle/oracle/oradata/orcl/system01.dbf',
  '/home/oracle/oracle/oradata/orcl/undotbs01.dbf',
  '/home/oracle/oracle/oradata/orcl/sysaux01.dbf',
  '/home/oracle/oracle/oradata/orcl/users01.dbf',
  '/home/oracle/oracle/oradata/orcl/example01.dbf'
CHARACTER SET WE8ISO8859P1
;

Oracle笔记

2010年9月10日 04:25

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; //开启控制文件自动备份

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
 
RMAN> backup database spfile include current controlfile plus archivelog;
 
/*备份归档日志,由于命令中带有plus archivelog,因此手动备份归档日志*/
Starting backup at 09-SEP-10
current log archived //当前日志归档
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=4 recid=1 stamp=729289389
channel ORA_DISK_1: starting piece 1 at 09-SEP-10
channel ORA_DISK_1: finished piece 1 at 09-SEP-10
piece handle=/home/oracle/oracle/flash_recovery_area/ORCL/backupset/2010_09_09/o1_mf_annnn_TAG20100909T202309_68knfh2s_.bkp tag=TAG20100909T202309 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 09-SEP-10
 
/*备份数据文件,控制文件和服务器参数文件*/
Starting backup at 09-SEP-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/oracle/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/home/oracle/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/home/oracle/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/home/oracle/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/home/oracle/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-SEP-10
channel ORA_DISK_1: finished piece 1 at 09-SEP-10
piece handle=/home/oracle/oracle/flash_recovery_area/ORCL/backupset/2010_09_09/o1_mf_nnndf_TAG20100909T202312_68knfjll_.bkp tag=TAG20100909T202312 comment=NONE //数据文件备份位置
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 09-SEP-10
channel ORA_DISK_1: finished piece 1 at 09-SEP-10
piece handle=/home/oracle/oracle/flash_recovery_area/ORCL/backupset/2010_09_09/o1_mf_ncsnf_TAG20100909T202312_68knk68q_.bkp tag=TAG20100909T202312 comment=NONE //控制文件和服务器参数文件位置
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 09-SEP-10
 
/*归档日志再次被备份,事后查看备份文件,发现第一次归档备份文件大小是第二次的数百倍,可能因为是Open Backup,数据库在备份期间生成了重做日志,因此需要再次备份,证据就是Close Backup的时候不会有第二次备份归档日志,他会显示:specification does not match any archive log in the recovery catalog backup cancelled because all files were skipped*/
Starting backup at 09-SEP-10
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=5 recid=2 stamp=729289512
channel ORA_DISK_1: starting piece 1 at 09-SEP-10
channel ORA_DISK_1: finished piece 1 at 09-SEP-10
piece handle=/home/oracle/oracle/flash_recovery_area/ORCL/backupset/2010_09_09/o1_mf_annnn_TAG20100909T202512_68knk991_.bkp tag=TAG20100909T202512 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 09-SEP-10
 
/*由于之前开启了自动备份控制文件和服务器参数文件,因此他们再次被备份*/
Starting Control File and SPFILE Autobackup at 09-SEP-10
piece handle=/home/oracle/oracle/flash_recovery_area/ORCL/autobackup/2010_09_09/o1_mf_s_729289514_68knkby5_.bkp comment=NONE //注意不是放在backupset文件夹下面,而是放在autobackup文件夹下面
Finished Control File and SPFILE Autobackup at 09-SEP-10
 
 
/*
备份完毕,共五个文件,四个在backupset文件夹下,一个在autobackup文件夹下
从上述文字可知,如果开启控制文件自动备份,那么只要发生备份,控制文件和服务器参数文件必然会自动备份,无论备份命令中是否已经显式的要求备份他们了,且自动备份的位置是在autobackup文件夹下。
 
控制文件和服务器参数文件总备份在一起。
 
只要要求备份归档日志(即plus archivelog),归档日志就会有两次备份,分别存储在两个文件下。
*/