分类: Oracle
2007-12-07 15:48:18
前言:在rac下,更改归档模式不像单机或主/备模式下那么容易更改,主要是因为cluster_database参数的缘故。通过将cluster_database参数从true改为false,可以顺利用更改单机归档模式的方式来更改归档设置。更改完毕后,再将cluster_database参数改回true即可。至于归档日志,可以通过nfs共享来保存两边共有的归档日志,当然也可以用rman直接各自备各个节点的归档日志,当需要恢复时,再将归档日志合并即可。
1、关闭运行中的数据库
# su - oracle
$sqlplus /nolog
sql>connect /as sysdba
sql>shutdown immediate
2、导出现有数据库的spfile文件
如果没有spfile,可以先创建spfile
sql>create spfile from pfile;
然后导出spfile
sql>create pfile='/oracle/pfile.ora' from spfile; //将pfile创建到/oracle目录下
3、修改/oracle/pfile.ora文件
更改cluster_database参数为false。同时可以添加自动归档参数log_archive_start=true,如下:
*.log_archive_start=true
*.cluster_database=false
*.log_archive_dest='LOCATION=/oracle/archivelog' //将归档日志存放到/oracle/archivelog文件系统下,便于管理
*.log_archive_format=%t_%s.dbf
#################### For 11G参数文件############################
*.log_archive_start=true ////去掉,11g里该参数已失效。
*.log_archive_format=%t_%s.dbf
----改为*.log_archive_format=%r_%t_%s.arc
*.cluster_database=false
*.log_archive_dest='LOCATION=/oracle/archivelog' //将归档日志存放到/oracle/archivelog文件系统下,便于管理
需改为*.log_archive_dest='/oracle/archivelog' , location只适用于standby.
4、导入已修改的spfile
在数据库关闭状态下:
sql>create spfile from pfile='/oracle/pfile.ora';
5、启动数据库到加载状态(mount)
$sqlplus /nolog
sql>connect /as sysdba
sql>startup mount
6、更改数据库运行模式为归档模式
$sqlplus /nolog
sql>connect /as sysdba
sql>startup mount
sql>alter database archivelog; //更改为归档模式
sql>alter database open; //将数据库打开
sql>archive log list; //检查数据库归档参数是否已经正确更改
7、将cluster_database参数更改回true
首先关闭数据库
$sqlplus /nolog
sql>connect /as sysdba
sql>shutdown immediate
sql>create spfile from pfile='/oracle/pfile01.ora'; //将现有spfile导出
修改/oracle/pfile01.ora,将cluster_database参数更改为true;
8、导入新修改的pfile01.ora文件
$sqlplus /nolog
sql>connect /as sysdba
sql>create spfile from pfile='/oracle/pfile01.ora';
sql>startup //正常启动数据库
####################################################################
如果使用的是spfile,还有更简单一点的步骤
先确认一下是否使用的是spfile, 请参考eygle的文章 .
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /opt/oracle/10g/db/dbs/arch
Oldest online log sequence 35
Current log sequence 36
SQL> select decode(count(*), 1, 'spfile', 'pfile' ) USED from v$spparameter where rownum=1 and isspecified='TRUE' ;
USED
------
Spfile
SQL> alter system set cluster_database=false scope=spfile sid='*';
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 557842432 bytes
Fixed Size 2085560 bytes
Variable Size 243273032 bytes
Database Buffers 306184192 bytes
Redo Buffers 6299648 bytes
Database mounted.
SQL> alter database archivelog;
SQL> alter database open ;
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/10g/db/dbs/arch
Oldest online log sequence 35
Next log sequence to archive 36
Current log sequence 36
SQL> alter system set cluster_database=true scope=spfile sid='*';
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
再用sqlplus 或 srvctl启动oracle即可了。
参见
http://blog.csdn.net/cockcrow/archive/2005/12/13/551683.aspx
归档日志目标地址的语法格式log_archive_dest_n=只适用于支持standby database的Enterprise Edition,而且location也是支持standby database的写法,所以Standard Edition 只能使用语法格式log_archive_dest=
和log_archive_duplex_dest=
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/db/dbs/arch
Oldest online log sequence 9
Next log sequence to archive 10
Current log sequence 10
SQL>
SQL>
SQL>
SQL> alter system set log_archive_dest='/oracle/arch';
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracle/arch
Oldest online log sequence 11
Next log sequence to archive 12
Current log sequence 12
SQL>