这里先说明这两个错误的解决办法然后直接看下面配置即可,
当添加完主备库后查看配置时出现 ORA-16797: database is not using a server parameter file。这个很明显就是数据库没有使用 Spfile 启库,直接用 pfile 启库所报的错误,解决办法关闭备库,创建 Spfile 文件后启库即可。
SYS@SBDB1> show parameter spfile
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
spfile string
SYS@SBDB1> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@SBDB1> create spfile from pfile;
File created.
SYS@SBDB1> startup
ORACLE instance started.
Total System Global Area 941600768 bytes
Fixed Size 1348860 bytes
Variable Size 683674372 bytes
Database Buffers 251658240 bytes
Redo Buffers 4919296 bytes
Database mounted.
Database opened.
SYS@SBDB1>
SYS@SBDB1> select database_role,open_mode,protection_mode from v$database;
DATABASE_ROLE OPEN_MODE PROTECTION_MODE
---------------- -------------------- --------------------
PHYSICAL STANDBY READ ONLY MAXIMUM PERFORMANCE
当切换模式为最高可用时出现 Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode;
这个错误没遇到过便网上查看了一番,几乎网上所有的文章均在说是由于传输模式为异步的原因,MOS 上到说明可能还 standby log 日志组没有建立的原因,但都不是这样的原因,我这里只是由于备库 dg_broker_start 参数没有设置为 TRUE,太坑了,居然只设置了主库的忘记备库设置此参数了。
SYS@prod1> show parameter dg_broker
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
dg_broker_config_file1 string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/dr1PROD1.dat
dg_broker_config_file2 string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/dr2PROD1.dat
dg_broker_start boolean FALSE
SYS@prod1> alter system set dg_broker_start=true;
System altered.
SYS@prod1> select count(*) from v$standby_log;
COUNT(*)
----------
4
SYS@prod1> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@prod1>
SYS@prod1>
SYS@prod1> startup
ORACLE instance started.
Total System Global Area 941600768 bytes
Fixed Size 1348860 bytes
Variable Size 692062980 bytes
Database Buffers 243269632 bytes
Redo Buffers 4919296 bytes
Database mounted.
Database opened.
SYS@prod1>
--备库参数也需要修改
SYS@SBDB1> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
SYS@SBDB1> show parameter dg_broker;
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
dg_broker_config_file1 string /u01/app/oracle/product/11.2.0
/db_1/dbs/dr1SBDB1.dat
dg_broker_config_file2 string /u01/app/oracle/product/11.2.0
/db_1/dbs/dr2SBDB1.dat
dg_broker_start boolean FALSE
SYS@SBDB1>
SYS@SBDB1> alter system set dg_broker_start=true;
System altered.
SYS@SBDB1> show parameter dg_broker;
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
dg_broker_config_file1 string /u01/app/oracle/product/11.2.0
/db_1/dbs/dr1SBDB1.dat
dg_broker_config_file2 string /u01/app/oracle/product/11.2.0
/db_1/dbs/dr2SBDB1.dat
dg_broker_start boolean TRUE
SYS@SBDB1>
--使用 dgmgrl 远程登陆主库进行配置
[oracle@JiekeXu_p2 ~]$ dgmgrl sys/oracle@prod1
DGMGRL for Linux: Version 11.2.0.3.0 - Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> help create --使用帮助命令添加主库
Creates a broker configuration
Syntax:
CREATE CONFIGURATION AS
PRIMARY DATABASE IS
CONNECT IDENTIFIER IS ;
DGMGRL> CREATE CONFIGURATION sbdb1_broker as PRIMARY DATABASE IS PROD1 CONNECT IDENTIFIER IS PROD1;
Configuration "sbdb1_broker" created with primary database "prod1"
DGMGRL> show CONFIGURATION
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
DGMGRL> help add --使用帮助命令添加备库 SBDB1
Adds a standby database to the broker configuration
Syntax:
ADD DATABASE
[AS CONNECT IDENTIFIER IS ]
[MAINTAINED AS {PHYSICAL|LOGICAL}];
DGMGRL> add database SBDB1 AS CONNECT IDENTIFIER IS SBDB1;
Database "sbdb1" added
DGMGRL> enable Configuration; --启用配置
Enabled.
DGMGRL> show Configuration --检查配置出现第一个错误ORA-16797
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database
Error: ORA-16797: database is not using a server parameter file
Fast-Start Failover: DISABLED
Configuration Status:
ERROR
--这里已使用 SPfile 重启备库了,但埋下了第二个错误的种子,备库 disabled
DGMGRL> show Configuration
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL> show database PROD1; --查看主库
Database - prod1
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
PROD1
Database Status:
SUCCESS
DGMGRL> help show
Displays information about a configuration, database, or instance
Syntax:
SHOW CONFIGURATION [VERBOSE];
SHOW DATABASE [VERBOSE] [];
SHOW INSTANCE [VERBOSE] []
[ON DATABASE ];
SHOW FAST_START FAILOVER;
--查看主库详细配置,发现日志传输为异步,需要修改为同步 SYNC
DGMGRL> SHOW DATABASE VERBOSE PROD1;
Database - prod1
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
PROD1
Properties:
DGConnectIdentifier = 'prod1'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '10'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'SBDB1, PROD1'
LogFileNameConvert = 'SBDB1, PROD1'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
SidName = 'PROD1'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=JiekeXu_p1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PROD1_DGMGRL.us.oracle.com)(INSTANCE_NAME=PROD1)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/home/oracle/flash'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
DGMGRL> EDIT DATABASE PROD1 SET PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
--配置完检查也是同步模式了
DGMGRL> SHOW DATABASE VERBOSE PROD1;
Database - prod1
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
PROD1
Properties:
DGConnectIdentifier = 'prod1'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '10'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'SBDB1, PROD1'
LogFileNameConvert = 'SBDB1, PROD1'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
SidName = 'PROD1'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=JiekeXu_p1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PROD1_DGMGRL.us.oracle.com)(INSTANCE_NAME=PROD1)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/home/oracle/flash'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
--这里切换保护模式是出现第二个报错 ORA-16627
DGMGRL>
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode
Failed.
DGMGRL> show CONFIGURATION
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
--开始排查,退出重新登录也是报错
DGMGRL> quit
[oracle@JiekeXu_p2 ~]$ dgmgrl sys/oracle@prod1
DGMGRL for Linux: Version 11.2.0.3.0 - Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> show CONFIGURATION
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode
Failed.
DGMGRL>
DGMGRL> SHOW DATABASE VERBOSE SBDB1;
Database - sbdb1
Role: PHYSICAL STANDBY
Intended State: OFFLINE
Transport Lag: (unknown)
Apply Lag: (unknown)
Real Time Query: OFF
Instance(s):
SBDB1
Properties:
DGConnectIdentifier = 'sbdb1'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '10'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'PROD1, SBDB1'
LogFileNameConvert = 'PROD1, SBDB1'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
SidName = 'SBDB1'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=JiekeXu_p2)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=SBDB1_DGMGRL.us.oracle.com)(INSTANCE_NAME=SBDB1)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/home/oracle/flash'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SHUTDOWN
DGMGRL> SHOW DATABASE VERBOSE PROD1;
Database - prod1
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
PROD1
Properties:
DGConnectIdentifier = 'prod1'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '10'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'SBDB1, PROD1'
LogFileNameConvert = 'SBDB1, PROD1'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
SidName = 'PROD1'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=JiekeXu_p1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PROD1_DGMGRL.us.oracle.com)(INSTANCE_NAME=PROD1)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/home/oracle/flash'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
--检查主备库日志传输均是同步模式
DGMGRL> EDIT DATABASE PROD1 SET PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode
Failed.
DGMGRL> edit database 'PROD1' set PROPERTY 'LogXptMode'='SYNC';
Object "PROD1" was not found
DGMGRL>
DGMGRL> edit database PROD1 set PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL>
DGMGRL> edit database SBDB1 set PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode
Failed.
--这里主库重启了一次,断开需要重新连接
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
ORA-03113: end-of-file on communication channel
Process ID: 3068
Session ID: 70 Serial number: 155
Configuration details cannot be determined by DGMGRL
DGMGRL>
DGMGRL> DGMGRL>
DGMGRL>
DGMGRL> quit
[oracle@JiekeXu_p2 ~]$ dgmgrl sys/oracle@prod1
DGMGRL for Linux: Version 11.2.0.3.0 - Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode
Failed.
DGMGRL> show CONFIGURATION;
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL> START OBSERVER;
Observer started
--这里新开一个窗口进行操作
[oracle@JiekeXu_p2 ~]$ dgmgrl sys/oracle@prod1
DGMGRL for Linux: Version 11.2.0.3.0 - Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL>
DGMGRL> show CONFIGURATION;
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL> enable FAST_START FAILOVER;
Error: ORA-16651: requirements not met for enabling fast-start failover
Failed.
DGMGRL> help add
Adds a standby database to the broker configuration
Syntax:
ADD DATABASE
[AS CONNECT IDENTIFIER IS ]
[MAINTAINED AS {PHYSICAL|LOGICAL}];
--这里检测发现状态均是未知的
DGMGRL> show database SBDB1;
Database - sbdb1
Role: PHYSICAL STANDBY
Intended State: OFFLINE
Transport Lag: (unknown)
Apply Lag: (unknown)
Real Time Query: OFF
Instance(s):
SBDB1
Database Status:
SHUTDOWN
DGMGRL> show database PROD1;
Database - prod1
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
PROD1
Database Status:
SUCCESS
--这里尝试删除 SBDB1 备库重新添加
DGMGRL> help delete
Unrecognized command "delete", try "help"
DGMGRL> help move
Unrecognized command "move", try "help"
DGMGRL> help
The following commands are available:
add Adds a standby database to the broker configuration
connect Connects to an Oracle database instance
convert Converts a database from one type to another
create Creates a broker configuration
disable Disables a configuration, a database, or fast-start failover
edit Edits a configuration, database, or instance
enable Enables a configuration, a database, or fast-start failover
exit Exits the program
failover Changes a standby database to be the primary database
help Displays description and syntax for a command
quit Exits the program
reinstate Changes a database marked for reinstatement into a viable standby
rem Comment to be ignored by DGMGRL
remove Removes a configuration, database, or instance
show Displays information about a configuration, database, or instance
shutdown Shuts down a currently running Oracle database instance
sql Executes a SQL statement
start Starts the fast-start failover observer
startup Starts an Oracle database instance
stop Stops the fast-start failover observer
switchover Switches roles between a primary and standby database
Use "help " to see syntax for individual commands
DGMGRL> help remove
Removes a configuration, database, or instance
Syntax:
REMOVE CONFIGURATION [PRESERVE DESTINATIONS];
REMOVE DATABASE [PRESERVE DESTINATIONS];
REMOVE INSTANCE [ON DATABASE ];
DGMGRL> remove database SBDB1;
Removed database "sbdb1" from the configuration
DGMGRL>
DGMGRL>
DGMGRL> help add
Adds a standby database to the broker configuration
Syntax:
ADD DATABASE
[AS CONNECT IDENTIFIER IS ]
[MAINTAINED AS {PHYSICAL|LOGICAL}];
DGMGRL> add database SBDB1 as connect IDENTIFIER IS SBDB1;
Database "sbdb1" added
DGMGRL>
DGMGRL> help show
Displays information about a configuration, database, or instance
Syntax:
SHOW CONFIGURATION [VERBOSE];
SHOW DATABASE [VERBOSE] [];
SHOW INSTANCE [VERBOSE] []
[ON DATABASE ];
SHOW FAST_START FAILOVER;
DGMGRL> SHOW CONFIGURATION;
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
-- 重新添加后备库还是 disabled
DGMGRL> SHOW CONFIGURATION;
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
--到这里终于检查到了是由于备库参数没有修改,配置好 dg_broker_start 参数后, enable 备库。
DGMGRL> help enable
Enables a configuration, a database, or fast-start failover
Syntax:
ENABLE CONFIGURATION;
ENABLE DATABASE ;
ENABLE FAST_START FAILOVER [CONDITION ];
DGMGRL> ENABLE DATABASE SBDB1;
Enabled.
DGMGRL> SHOW CONFIGURATION;
Configuration - sbdb1_broker
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
--修改模式为最大保护模式成功,start failover 也成功了。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded.
DGMGRL>
DGMGRL> enable FAST_START FAILOVER;
Enabled.
DGMGRL> SHOW CONFIGURATION;
Configuration - sbdb1_broker
Protection Mode: MaxAvailability
Databases:
prod1 - Primary database
sbdb1 - (*) Physical standby database
Fast-Start Failover: ENABLED
Configuration Status:
SUCCESS
DGMGRL>
这个步骤算是基本完成,特此记录学习。