分类目录归档:Oracle

手工添加备库文件

早上在Oracle11.2.0.4,Dataguard环境下,主库增加一个数据文件,导致备库无法日志无法应用,检查发现备库初始化参数STANDBY_FILE_MANAGEMENT为MANUL,

告警日志信息如下:

Archived Log entry 1283 added for thread 1 sequence 2182 ID 0x540eaffc dest 1:
Thu Jul 16 09:24:14 2015
Media Recovery Log /oracle/u01/oracle/db1124/oradata/orcl/arch/1_2182_875790564.dbf
File #17 added to control file as ‘UNNAMED00017′ because
the parameter STANDBY_FILE_MANAGEMENT is set to MANUAL
The file should be manually created to continue.

解决办法:

1,查看文件号

select * from v$datafile;

2,创建文件

alter database create datafile 18 as ‘/oracle/u01/oracle/db1124/oradata/orcl/NTSMS06.DBF’

3,开启日志应用

Alter database recover managed standby database disconnect from session

如果standby_file_management参数为auto,主库添加数据文件,且转化路径没有在初始化参数中配置,则可以采用以下步骤解决:

1, 先将初始话参数standby_file_management 改为manual
SQL> alter system set standby_file_management=manual;
2, SQL> alter database create datafile 18 as ‘/oracle/u01/oracle/db1124/oradata/orcl/NTSMS06.DBF’
3,– SQL>Recover standby database
4, SQL>Alter database recover managed standby database disconnect from session
5, SQL> alter system set standby_file_management=auto;

Oracle 11g Dataguard switchover切换测试

如果参数设置合理我们的物理standby是可以进行平滑切换的,

SQL> select *from v$version;

BANNER
——————————————————————————–
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
PL/SQL Release 11.2.0.4.0 – Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 – Production
NLSRTL Version 11.2.0.4.0 – Production

具体进行切换的步骤如下:
1、 在主库查看v$database中的 switchover_status字段。
SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE SWITCHOVER_STATUS
—————- ——————–
PRIMARY TO STANDBY
2、 转换主库角色到备库角色使用语句
SQL> alter database commit to switchover to physical standby with session shutdown wait;

Database altered.

SQL> shutdown immediate;
ORA-01012: not logged on
3、 关闭数据库并且启动到mount阶段
shutdown immediate;
startup mount;

—以下为备库操作
4、在备库查看v$database中的 switchover_status字段,看是否为to_primary

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE SWITCHOVER_STATUS
—————- ——————–
PHYSICAL STANDBY SESSIONS ACTIVE
SQL> alter database commit to switchover to primary ;
alter database commit to switchover to primary
ERROR at line 1:
ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected
SQL> alter database commit to switchover to primary with session shutdown wait;
Database altered.

5、在备库执行
alter database commit to switchover to primary with session shutdown wait;
来进行角色切换
6、关闭备库,启动备库
sql> shutdown immediate;
sql> startup;
7、使用强制归档选项
alter database force logging;
8、在原来主库上开启日志应用
alter database recover managed standby database disconnect from session;