ORACLE数据库Dataguard dg broker 3大模式相互切换 主备库互相切换

ORACLE数据库Dataguard dg broker 3大模式升级方式


主机名:
host:ocm1 ip:192.168.88.101 sid=pmdb db_name=pmdb db_unique_name=pmdb
host:ocm2 ip:192.168.88.102 sid=pmdbdg db_name=pmdb db_unique_name=pmdbdg


maximum performance mode


oracle dg 主备库的db_name(sid)是一样的,db_unique_name不一样
主库的操作:


1.sql>alter database force logging;


2.sql>select * from v$log;


3.sql>select member from v$logfile;


4.
sql>ALTER DATABASE ADD STANDBY LOGFILE GROUP 4
(‘/u01/oracle/oradata/PMDB/redo04.log‘) SIZE 50m;


sql>ALTER DATABASE ADD STANDBY LOGFILE GROUP 5
(‘/u01/oracle/oradata/PMDB/redo05.log‘) SIZE 50m;


sql>ALTER DATABASE ADD STANDBY LOGFILE GROUP 6
(‘/u01/oracle/oradata/PMDB/redo06.log‘) SIZE 50m;


配置参数文件:
DB_UNIQUE_NAME=pmdb
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(pmdb,pmdbdg)‘
LOG_ARCHIVE_DEST_1=‘LOCATION=/home/oracle/arch/  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=pmdb‘
LOG_ARCHIVE_DEST_2=‘SERVICE=pmdbdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pmdbdg‘


FAL_SERVER=pmdbdg
FAL_CLIENT=pmdb
DB_FILE_NAME_CONVERT=‘/u01/oracle/oradata/pmdbdg/‘,‘/u01/oracle/oradata/pmdb/‘
LOG_FILE_NAME_CONVERT= ‘/u01/oracle/oradata/pmdbdg/‘,‘/u01/oracle/oradata/pmdb/‘
STANDBY_FILE_MANAGEMENT=AUTO


sql>shutdown immediate


cd $ORACLE_BASE/oradata


tar -vcf pmdb.tar pmdb


gzip pmdb.tar


主库:scp pmdb.tar.gz ocm2:/u01/oralce/oradata->备库:cd /u01/oracle/oradata/ tar -vxzf pmdb.tar.gz


sql>startup mount


sql>alter database create standby controlfile as ‘/tmp/control.stdby‘;


scp /tmp/control.stdby ocm2:/u01/oracle/oradata/pmdbdg


cd $ORACLE_HOME/dbs
scp initpmdb.ora ocm2:/tmp


配置主库的tns:
cd $ORACLE_HOME/network/admin
vim tnsnames.ora
vim tnsnames.ora
添加如下代码:
PMDBDG =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ocm2)(PORT = 1521))
    (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = pmdbdg)
  )
)


tail -f alter_pmdb.log


备库


cd $ORACLE_HOME/dbs
orapwd file=orapwpmdbdg password=oracle entries=5 force=y


cd $ORACLE_BASE/oradata/pmdbdg
rm *.ctl
mv control.stdby control01.ctl


cp /tmp/initpmdb.ora  $ORACLE_HOME/dbs
cd $ORACLE_HOME/dbs/
mv initpmdb.ora initpmdbdg.ora


vim initpmdbdg.ora


DB_UNIQUE_NAME=pmdbdg
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(pmdb,pmdbdg)‘
LOG_ARCHIVE_DEST_1=‘LOCATION=/home/oracle/arch/  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=pmdbdg‘
LOG_ARCHIVE_DEST_2=‘SERVICE=pmdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pmdb‘


FAL_SERVER=pmdb
FAL_CLIENT=pmdbdg
DB_FILE_NAME_CONVERT=‘/u01/oracle/oradata/pmdb/‘,‘/u01/oracle/oradata/pmdbdg/‘
LOG_FILE_NAME_CONVERT= ‘/u01/oracle/oradata/pmdb/‘,‘/u01/oracle/oradata/pmdbdg/‘
STANDBY_FILE_MANAGEMENT=AUTO


mkdir -p /u01/oracle/admin/pmdbdg/udump
mkdir -p /u01/oracle/admin/pmdbdg/cdump
mkdir -p /u01/oracle/admin/pmdbdg/bdump
mkdir -p /u01/oracle/admin/pmdbdg/adump
注意修改initpmdbdg.ora文件中的control文件路径。


配置备库的tns:
cd $ORACLE_HOME/network/admin
vim tnsnames.ora
添加如下代码:
PMDB =
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ocm1)(PORT = 1521))
    (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = pmdb)
  )
)




测试连通性:
sqlplus ‘sys/oracle1@pmdb as sysdba‘


启动实例:
export ORACLE_SID=pmdbdg
sqlplus ‘/as sysdba‘


sql>startup mount


启动监听程序:
lsnrctl start


lsnrctl status


show parameters local


show parameters dump


tail -f alter_pmdbdg.log






启动顺序:
先备库:
此时备库之前已经是mount状态:
执行sql>alter database recover managed standby database disconnect from session;
然后查看后台alter日志。
日志中会显示Clearing online redo logfile;
media recovery waiting for thread 1 sequence 32


再主库:
sql>alter database open;
然后查看日志:
日志中会显示:
lgwr: setting ‘active‘ archival for destination log_archive_dest_2


此时查看备库日志:
日志中会显示:
primary database is in maximum performance mode
media recovery log /home/oracle/arch/1_32_.log


在主库尝试切换几组日志:
sql>alter system switch logfile;
sql>alter system switch logfile;
sql>alter system switch logfile;


然后到备库中查看日志:
media recovery log 


再主库尝试创建表空间看备库是否也有相应表空间:
sql>create tablespace test datafile ‘/u01/app/oracle/oradata/prod/disk2/test01.dbf‘ size 10m;
sql>alter system switch logfile(切换完日志备库中才会传过去刚创建的表空间)。








角色切换(switchover):
主库:
sql>select switchover_status from v$database;
switchover_status
------------------------
SESSIONS_ACTIVE(不会显示to standby状态)


sql> alter database commit to switchover to physical standby with session shutdown;
查看后台alter 日志


然后查看备库后台alter日志:
日志中会有End-of-REDO标识。(主库和备库都会有End-of-REDO标识)


备库:
sql>alter database commit to switchover to primary;


此时原来的主库变成备库,备库变成主库。


启动的时候先备库再主库:


备库(原来的主库):
sql>shutdown
sql>startup mount
sql>alter database recover managed standby database disconnect from session;




主库(原来的备库):
sql>alter database open;




然后再切换回原来的角色:


主库(原来的备库)
sql> alter database commit to switchover to physical standby with session shutdown;


备库(原来的主库)
sql> alter database commit to switchover to primary;


sql>alter database open;


主库(原来的备库)


sql>shutdown
sql>startup




升级到最大保护模式:


主库:
sql>shutdown immediate


备库:
sql>shutdown immediate


主库:
修改主库pfile文件:
原来:
LOG_ARCHIVE_DEST_2=‘SERVICE=pmdbdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pmdbdg‘
修改为:
LOG_ARCHIVE_DEST_2=‘SERVICE=pmdbdg LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pmdbdg‘


备库:
修改备库pfile文件:
原来:
LOG_ARCHIVE_DEST_2=‘SERVICE=pmdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pmdb‘
修改为:
LOG_ARCHIVE_DEST_2=‘SERVICE=pmdb LGWR SYNC affirm VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=pmdb‘






升级到最大保护模式(需要完全同步)
1.先做一次主备库切换
先主库:
sql>alter database commit to switchover to physical standby with session shutdown;


再备库:
sql>alter database commit to switchover to primary;


然后在原来的主库上:
sql>shutdown
sql>startup mount
sql>alter database recover managed standby database disconnect from session;


然后在原来的备库库上:
sql>alter database set standby database to maximize protection;
sql>alter database open;
在原来的备库上建立测试表:
SQL> create table test_lzq(id number,name varchar2(20));


Table created.


SQL> insert into test_lzq values(1,‘lzq‘);


1 row created.


SQL> insert into test_lzq values(1,‘lzq‘);


1 row created.


SQL> insert into test_lzq values(1,‘lzq‘);


1 row created.


SQL> insert into test_lzq values(1,‘lzq‘);


1 row created.


SQL> insert into test_lzq values(1,‘lzq‘);


1 row created.


SQL> commit;


Commit complete.


SQL> select count(*) from test_lzq;


  COUNT(*)
----------
5


sql>shutdown immediate


再在原来的主库上:
sql>shutdown immediate
sql>startup


SQL> select count(*) from test_lzq;


  COUNT(*)
----------
5


最后变回原来的模式:
先在原来的主库上:
sql>shutdown abort
sql>startup mount
再在原来的备库上:
sql>startup mount
最后在原来的主库上:
sql>alter database recover managed standby database disconnect from session;
最后在原来的备库上:
sql>alter database set standby database to maximize protection;
sql>alter database open;




升级最高可用模式:
此时保证主备库都是mount状态:
sql>startup mount
再在原来的备库上:
sql>startup mount
最后在原来的主库上:
sql>alter database recover managed standby database disconnect from session;
最后在原来的备库上:
sql>alter database set standby database to maximize availability;
sql>alter database open;






dg broker




DG broker配置及应用测试
 
一.配置broker的先决条件
1.数据库版本:主库和备库版本必须10g r2 或者更高,企业版
2.参数文件:必须使用spfile
SQL> show parameter spfile
 
NAME         TYPE        VALUE
------------ ----------- ---------------
spfile         string     /u01/oracle/10g/dbs/spfilepmdb.ora
                                                
3.确定主备库的compatibe值相同
 
4.主备库dg_broker_start的值必须为:true
SQL> alter system set dg_broker_start=true scope=both;
System altered.
SQL> show parameter dg_broker
NAME                    TYPE        VALUE
--------------------------- -------- ------------------------------
dg_broker_config_file1    string     /u01/oracle/10g/dbs/dr1pmdb.dat
dg_broker_config_file2    string     /u01/oracle/10g/dbs/dr2pmdb.dat
dg_broker_start           boolean     TRUE
 
5.必须在监听里设置global_name的值
主库:
SID_LIST_LISTENER=
    (SID_LIST=
      (SID_DESC=
        (SID_NAME=pmdb)
        (GLOBAL_DBNAME=pmdb_DGMGRL)
        (ORACLE_HOME=/u01/oracle/10g)))
 
备库:
SID_LIST_LISTENER=
    (SID_LIST=
      (SID_DESC=
        (SID_NAME=pmdbdg)
        (GLOBAL_DBNAME=pmdbdg_DGMGRL)
        (ORACLE_HOME=/u01/oracle/10g)))
6.在主备库开启闪回数据库功能
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;
SQL>ALTER DATABASE FLASHBACK ON;
SQL>ALTER DATABASE OPEN;
 
 
 
注:如果是rac模式,需要在每个节点上设置dg_broker_config_filen参数
   ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1 = ‘+DG/DIRECTORY/DR1.DAT‘ SCOPE=BOTH;
    ALTER SYSTEM SET DG_BROKER_CONFIG_FILE2 = ‘+DG/DIRECTORY/DR2.DAT‘ SCOPE=BOTH;
    如果使用了非默认端口(1521),必须设置local_lisener以便所有成员都能访问
 
  二.broker配置
 
在从库上配置
1.运行命令, 连接到主库:
  dgmgrl
connect sys/oracle@pmdbdg
2.创建broker配置
[oracle@ocm2 ]$ dgmgrl
DGMGRL for Linux: Version 10.2.0.1.0 - Production
 
Copyright (c) 2000, 2005, Oracle. All rights reserved.
 
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle@pmdb
Connected.
DGMGRL> create configuration ‘pmdbsoulution‘ as primary database is ‘pmdb‘ connect identifier is ‘pmdb‘;
Configuration "pordbsoulution" created with primary database "pmdb"
DGMGRL> show configuration
 
Configuration
  Name:                pordbsoulution
  Enabled:             NO
  Protection Mode:     MaxAvailability
  Fast-Start Failover: DISABLED
  Databases:
    pordb - Primary database
 
Current status for "pmdbsoulution":
DISABLED
 
添加备库到broker配置:
DGMGRL> add database ‘pmdbdg‘ as connect identifier is pmdbdg maintained as physical;
Database "pmdbdg" added
DGMGRL> show configuration
 
Configuration
  Name:                pordbsoulution
  Enabled:             NO
  Protection Mode:     MaxAvailability
  Fast-Start Failover: DISABLED
  Databases:
    pmdb - Primary database
    pmdbdg - Physical standby database
 
Current status for "pmdbdgsoulution":
DISABLED
 
 
 
3.使broker配置生效
DGMGRL> enable configuration;
Enabled.
DGMGRL> show configuration
 
Configuration
  Name:                pordbsoulution
  Enabled:             YES
  Protection Mode:     MaxAvailability
  Fast-Start Failover: DISABLED
  Databases:
    pmdb - Primary database
    pmdbdg - Physical standby database
 
Current status for "pordbsoulution":
SUCCESS
 
可以看到当前状态改变了
 
设置数据库状态模式:
设定 FastStartFailoverTarget 值.
DGMGRL> edit database ‘pmdb‘ set property ‘logxptmode‘=‘sync‘;
Property "logxptmode" updated
DGMGRL> edit database ‘pmdbdg‘ set property ‘logxptmode‘=‘sync‘;
Property "logxptmode" updated
 
使 Fast-Start Failover 生效
DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.
 
开启 Observer
DGMGRL> start observer
注:执行开启 Observer后,界面不会自动退出,如果要执行其它dgmgrl命令需重新开一个窗口
 
 
重新开一个窗口,进入dgmgrl,查看fast-start failover 配置
DGMGRL> show configuration;
DGMGRL> show configuration verbose;
 
4.验证fast-start failover 配置
 
主库:
SQL> col FS_FAILOVER_OBSERVER_HOST for a30
SQL>select fs_failover_observer_present,fs_failover_observer_host,fs_failover_threshold
from v$database;
FS_FAIL FS_FAILOVER_OBSERVER_HOST      FS_FAILOVER_THRESHOLD
------- ------------------------------ ---------------------
YES     slindb                                             30
 
备库:
SQL> col FS_FAILOVER_OBSERVER_HOST for a30
SQL>select fs_failover_observer_present,fs_failover_observer_host,fs_failover_threshold
from v$database;
 
FS_FAIL FS_FAILOVER_OBSERVER_HOST      FS_FAILOVER_THRESHOLD
------- ------------------------------ ---------------------
YES     slindb                                            30
 
修改fsfailoverthreshold值为什么120,默认为30
DGMGRL> edit configuration set property faststartfailoverthreshold=120;
Property "faststartfailoverthreshold" updated
 
测试broker
 
 查看主库和备库配置信息和状态:
DGMGRL> show database verbose pmdb;
 
Database
  Name:            pmdb
  Role:            PRIMARY
  Enabled:         YES
  Intended State:  ONLINE
  Instance(s):
    pmdb
 
  Properties:
    InitialConnectIdentifier        = ‘pmdb‘
    LogXptMode                      = ‘sync‘
    Dependency                      = ‘‘
    DelayMins                       = ‘0‘
    Binding                         = ‘OPTIONAL‘
    MaxFailure                      = ‘0‘
    MaxConnections                  = ‘1‘
    ReopenSecs                      = ‘300‘
    NetTimeout                      = ‘180‘
    LogShipping                     = ‘ON‘
    PreferredApplyInstance          = ‘‘
    ApplyInstanceTimeout            = ‘0‘
    ApplyParallel                   = ‘AUTO‘
    StandbyFileManagement           = ‘AUTO‘
    ArchiveLagTarget                = ‘0‘
    LogArchiveMaxProcesses          = ‘2‘
    LogArchiveMinSucceedDest        = ‘1‘
    DbFileNameConvert       = ‘/u01/oracle/oradata/pmdbdg, /oracle/oradata/pmdb‘
    LogFileNameConvert      = ‘/u01/oracle/oradata/pmdbdg, /oracle/oradata/pmdb‘
    FastStartFailoverTarget         = ‘pmdbdg‘
    StatusReport                    = ‘(monitor)‘
    InconsistentProperties          = ‘(monitor)‘
    InconsistentLogXptProps         = ‘(monitor)‘
    SendQEntries                    = ‘(monitor)‘
    LogXptStatus                    = ‘(monitor)‘
    RecvQEntries                    = ‘(monitor)‘
    HostName                        = ‘plindb‘
    SidName                         = ‘ocm1‘
    LocalListenerAddress            = ‘(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1)(PORT=1521))‘
    StandbyArchiveLocation          = ‘/home/oracle/arch‘
    AlternateLocation               = ‘‘
    LogArchiveTrace                 = ‘0‘
    LogArchiveFormat                = ‘%t_%s_%r.dbf‘
    LatestLog                       = ‘(monitor)‘
    TopWaitEvents                   = ‘(monitor)‘
 
Current status for "pmdb":
SUCCESS
 
DGMGRL> show database verbose pmdbdg;   
 
Database
  Name:            pmdbdg
  Role:            PHYSICAL STANDBY
  Enabled:         YES
  Intended State:  ONLINE
  Instance(s):
    pmdbdg
 
  Properties:
    InitialConnectIdentifier        = ‘pmdbdg‘
    LogXptMode                      = ‘sync‘
    Dependency                      = ‘‘
    DelayMins                       = ‘0‘
    Binding                         = ‘OPTIONAL‘
    MaxFailure                      = ‘0‘
    MaxConnections                  = ‘1‘
    ReopenSecs                      = ‘300‘
    NetTimeout                      = ‘180‘
    LogShipping                     = ‘ON‘
    PreferredApplyInstance          = ‘‘
    ApplyInstanceTimeout            = ‘0‘
    ApplyParallel                   = ‘AUTO‘
    StandbyFileManagement           = ‘AUTO‘
    ArchiveLagTarget                = ‘0‘
    LogArchiveMaxProcesses          = ‘2‘
    LogArchiveMinSucceedDest        = ‘1‘
    DbFileNameConvert               = ‘/u01/oracle/oradata/pmdb, /u01/oracle/oradata/pmdbdg‘
    LogFileNameConvert              = ‘/u01/oracle/oradata/pmdb, /u01/oracle/oradata/pmdbdg‘
    FastStartFailoverTarget         = ‘pordb‘
    StatusReport                    = ‘(monitor)‘
    InconsistentProperties          = ‘(monitor)‘
    InconsistentLogXptProps         = ‘(monitor)‘
    SendQEntries                    = ‘(monitor)‘
    LogXptStatus                    = ‘(monitor)‘
    RecvQEntries                    = ‘(monitor)‘
    HostName                        = ‘ocm2‘
    SidName                         = ‘pmdbdg‘
    LocalListenerAddress            = ‘(ADDRESS=(PROTOCOL=tcp)(HOST=ocm2)(PORT=1521))‘
    StandbyArchiveLocation          = ‘/home/oracle/arch/‘
    AlternateLocation               = ‘‘
    LogArchiveTrace                 = ‘0‘
    LogArchiveFormat                = ‘%t_%s_%r.dbf‘
    LatestLog                       = ‘(monitor)‘
    TopWaitEvents                   = ‘(monitor)‘
 
Current status for "pmdbdg":
SUCCESS
三.验证和测试Broker
1.主备切换测试:switchover
 
查看主库和备库状态和角色
主库:
SQL> select database_role,switchover_status from v$database;
 
DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PRIMARY          SESSIONS ACTIVE
 
备库:
SQL> select database_role,switchover_status from v$database;
 
DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY SESSIONS ACTIVE
 
[oracle@ocm2 ~]$ dgmgrl
DGMGRL for Linux: Version 10.2.0.1.0 - Production
 
Copyright (c) 2000, 2005, Oracle. All rights reserved.
 
Welcome to DGMGRL, type "help" for information.
DGMGRL>
 
DGMGRL> connect sys/oracle@pmdb
Connected.
DGMGRL> show configuration
 
Configuration
  Name:                pmdbsoulution
  Enabled:             YES
  Protection Mode:     MaxAvailability
  Fast-Start Failover: ENABLED
  Databases:
    pmdb - Primary database
    pmdbdg - Physical standby database
          - Fast-Start Failover target
 
Current status for "pmdbsoulution":
SUCCESS
 
将主库切换到sordb上,切换时同时观察主库,务库,dgmgrl的告警日志信息:
tail -f /oracle/admin/pmdb/bdump/alter*.log
tail -f /oracle/admin/pmdbdg/bdump/alter*.log
tail -f /oracle/admin/pmdbdg/bdump/dr*.log
 
形如切换:
DGMGRL> switchover to sordb;
Performing switchover NOW, please wait...
Operation requires shutdown of instance "pmdb" on database "pmdb"
Shutting down instance "pmdb"...
ORA-01109: database not open
 
Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "pmdbdg" on database "pmdbdg"
Shutting down instance "ordb"...
ORA-01109: database not open
 
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pmdb" on database "pmdb"
Starting instance "ordb"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "pmdbdg" on database "pmdbdg"
Starting instance "pmdbdg"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "pmdbdg"
 
切换成功后,查看新的主库和备库的状态和角色:
SQL> select database_role,switchover_status from v$database;
SQL> select status from v$instance;
DGMGRL> show configuration;
 
Configuration
  Name:                pordbsoulution
  Enabled:             YES
  Protection Mode:     MaxAvailability
  Fast-Start Failover: ENABLED
  Databases:
    pmdbdg - Primary database
    pmdb - Physical standby database
          - Fast-Start Failover target
 
Current status for "pordbsoulution":
SUCCESS
 
2.failover测试
手动测试:
DGMGRL> failover to pmdbdg;
Performing failover NOW. Please wait...
Operation requires shutdown of instance "pmdbdg " on database
"sordb".
Shutting down instance "sordb"...
database not mounted
ORACLE instance shut down.
Operation requires startup of instance "pmdbdg" on database "pmdbdg".
Starting instance "sordb"...
ORACLE instance started.
Database mounted.
Failover succeeded. New primary is "pmdbdg"
切换成功后,主库自动变为pmdbdg
 
自动测试:
将主库shutdown abort
SQL> shutdown abort
ORACLE instance shut down.
 
此时在observer控制台上看到:
DGMGRL> start observer
Observer started
 
22:26:38.10  Friday, December 09, 2011
Initiating fast-start failover to database "pmdbdg"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "pmdbdg"
22:26:52.27  Friday, December 09, 2011
 
表示在主库pmdb出现故障时,自动切换,新的主库为pmdbdg
查看failover后的新主库sordb角色和状态:
SQL> select database_role,switchover_status from v$database;
 
DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PRIMARY          SESSIONS ACTIVE
 
SQL> select status from v$instance;
 
STATUS
------------
OPEN
切换成功。
 
如果此时再将pordb启动,启动后会自动转化为备库:
此时在observer控制台上看到:
22:31:04.46  Friday, December 09, 2011
Initiating reinstatement for database "pmdb"...
Reinstating database "pordb", please wait...
Operation requires shutdown of instance "pmdbdg" on database "pmdbdg"
Shutting down instance "pmdbdg"...
ORA-01109: database not open
 
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pmdb" on database "pmdb"
Starting instance "pmdb"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "pmdb" ...
Reinstatement of database "pordb" succeeded
22:31:59.61  Friday, December 09, 2011
 
 
查看pordb角色和状态:
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY SESSIONS ACTIVE
 
SQL> select status from v$instance;
STATUS
------------
MOUNTED
 
查看sordb角色和状态:
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PRIMARY          SESSIONS ACTIVE
 
SQL> select status from v$instance;
STATUS
------------
OPEN
 
查看主库和备库归档日志及应用信息:
select sequence#,first_time,next_time,applied from v$archived_log order by sequence#;
 
总结:在实验中还是遇到一些问题,不过最后都一一的顺利解决,最容易遇到的以下问题:
1. ORA-01031: insufficient privileges
PING[ARC0]: Heartbeat failed to connect to standby ‘sordb‘. Error is 1031.
 
这各情况有两个可能,一个是密码文件没有拷到备库上,另一个原因是TNS设置不正确或者监听有问题,重新设置这两个地方就可以解决。
2.备库接收不到备库的日志
这个主要还是需要看告警日志,主要原因还是网络和权限的问题,当然也有可能是由其它原因导致网络和权限问题,比如备库的环境变量设置,我就在实验时不小心备库sid设置的问题引起权


限问题,导致备库接收不到日志
3.     数据库文件是使用OMF管理的,那么使用rman创建的备库的数据文件名已经与主库的文件名不一样了,此       时需将参数文件里的控制文件的路径和名称修改为备库上的实际路径和


名称,否则启动数据库会报错。




Warning: ORA-16610: command ‘EDIT DATABASE billdb SET PROPERTY‘ in progress
是正常的,说明操作正在进行中,等待一段时间后再检查,直到最后出现SUCCESS。











ORACLE数据库Dataguard dg broker 3大模式相互切换 主备库互相切换

上一篇:数独 C#


下一篇:摆脱恼人的IE控件,mediaDevices Api 实现高拍仪抓拍