--删除文件后重新用备份创建控制文件镜像
SQL> !rm /u01/control04.ctl
SQL> alter database backup controlfile to '/u01/control04.ctl';
Database altered.
--关闭数据库后用spfile启动(原来是pfile启动的)
SQL> shutdown immediate
Database closed.
Database dismounted.
Oracle instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 507514240 bytes
Database Buffers 322961408 bytes
Redo Buffers 2396160 bytes
ORA-00214: control file '/u01/app/oracle/oradata/zlm11g/control01.ctl' version 9338 inconsistent with file '/u01/control04.ctl'
version 9332
仍然报新增的控制文件版本号与系统原有的不一致。
此时猜想可能需要在spfile中先设置好参数后,再生成控制文件备份作为镜像
--先恢复正确的spfile
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup pfile=$ORACLE_HOME/dbs/initzlm11g.ora
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 507514240 bytes
Database Buffers 322961408 bytes
Redo Buffers 2396160 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile;
File created.
SQL> shutdown immedaite
SP2-0717: illegal SHUTDOWN option
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 507514240 bytes
Database Buffers 322961408 bytes
Redo Buffers 2396160 bytes
Database mounted.
Database opened.
--设置control_files参数
SQL> alter system set control_files='/u01/app/oracle/oradata/zlm11g/control01.ctl','/u01/app/oracle/fast_recovery_area/zlm11g/control02.ctl','/u01/control03.ctl','/u01/control04.ctl' scope=spfile;
System altered.
--备份控制文件作为镜像
SQL> !rm /u01/control04.ctl
SQL> alter database backup controlfile to '/u01/control04.ctl';
Database altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 507514240 bytes
Database Buffers 322961408 bytes
Redo Buffers 2396160 bytes
ORA-00214: control file '/u01/app/oracle/oradata/zlm11g/control01.ctl' version 9373 inconsistent with file '/u01/control04.ctl'
version 9367
仍然是不一致的状态,看来之前的假设都被推翻了,用backup controlfile方式备份出的控制文件,与系统原有的控制文件,是不同的,无法做到像OS那样直接复制来得直接
总结:
1.修改静态参数需要重启数据库,然后通过pfile来指定新增的控制文件镜像,最后用pfile启动,并生成spfile
2.复制控制文件镜像文件时,停库后尽量用OS级copy方式,如果选择使用备份当前控制文件生成控制文件镜像的话,新生成的备份控制文件与数据库原有控制文件是不一致的