今天在做oracle归档测试的时候发现了几个问题,在这里记录下来希望能得到大家的纰漏和帮助
[oracle@localhost ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 19 17:34:42 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
由于对oracle数据库不太熟悉,在执行了下面的命令的时候感到好奇怪:
SQL> alter database archivelog; alter database archivelog * ERROR at line 1: ORA-01126: database must be mounted in this instance and not open in any instance
这句话意思是说,要想进行配置归档,必须属于一个数据库实例中,这个在RAC中会出现这个问题可以参见:
点击打开链接
但是我发现我是测试在VM的环境下,不存在这种RAC情况:我试了两种情况第一种可以。只有mount的情况才可以操作
| SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. Total System Global Area ?417546240 bytes Fixed Size ? ? ? ? ? ? ? ? ?2213936 bytes Variable Size ? ? ? ? ? ? 314574800 bytes Database Buffers ? ? ? ? ? 96468992 bytes Redo Buffers ? ? ? ? ? ? ? ?4288512 bytes Database mounted. SQL> alter database archivelog; Database altered. |
| SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area ?417546240 bytes Fixed Size ? ? ? ? ? ? ? ? ?2213936 bytes Variable Size ? ? ? ? ? ? 314574800 bytes Database Buffers ? ? ? ? ? 96468992 bytes Redo Buffers ? ? ? ? ? ? ? ?4288512 bytes Database mounted. Database opened. SQL> alter database archivelog; alter database archivelog * ERROR at line 1: ORA-01126: database must be mounted in this instance and not open in any instanc ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?e |
SQL> show parameter db_recovery_file_dest; NAME TYPE ------------------------------------ -------------------------------- VALUE ------------------------------ db_recovery_file_dest string /u01/app/oracle/flash_recovery _area db_recovery_file_dest_size big integer 3882M
发现现在缺省使用的路径为 DB_RECOVERY_FILE_DEST,此路径是和Oracle的Flash_back_recovery 路径混杂在一起的,不太妥当。
所以要进行修改:
SQL> alter system set log_archive_dest = '/u01/app/oracle/arch' scope = spfile; System altered. SQL> !ls -lrt /u01/app/oracle total 48 drwxr-xr-x 2 oracle oinstall 4096 Dec 15 21:25 checkpoints drwxr-x--- 5 oracle oinstall 4096 Dec 15 22:03 cfgtoollogs drwxr-x--- 3 oracle oinstall 4096 Dec 15 22:04 oradata drwxr-x--- 3 oracle oinstall 4096 Dec 15 22:04 admin drwxrwxr-x 4 oracle oinstall 4096 Dec 15 22:04 diag drwxr-x--- 4 oracle oinstall 4096 Dec 15 22:06 flash_recovery_area
通过上面的查看你会发现数据库并没有为其创建一个arch目录,在建立日志文件的时候恰恰相反,假如当前目录下有你想创建的
文件你必须要先删除了再创建该文件。这个要注意一下。
SQL> !pwd /home/oracle SQL> !mkdir /u01/app/oracle/arch SQL> !ls -lrt /u01/app/oracle total 52 drwxr-xr-x 2 oracle oinstall 4096 Dec 15 21:25 checkpoints drwxr-x--- 5 oracle oinstall 4096 Dec 15 22:03 cfgtoollogs drwxr-x--- 3 oracle oinstall 4096 Dec 15 22:04 oradata drwxr-x--- 3 oracle oinstall 4096 Dec 15 22:04 admin drwxrwxr-x 4 oracle oinstall 4096 Dec 15 22:04 diag drwxr-x--- 4 oracle oinstall 4096 Dec 15 22:06 flash_recovery_area drwxr-xr-x 2 oracle oinstall 4096 Dec 19 17:41 arch SQL>