手把手教你安裝Data Guard
(1)
主庫(kù)安裝數(shù)據(jù)庫(kù),備庫(kù)只安裝軟件,我們可以采用在主庫(kù)裝完軟件的時(shí)候?qū)μ摂M機(jī)進(jìn)行復(fù)制。
主庫(kù)在用dbca建庫(kù)的時(shí)候,全局?jǐn)?shù)據(jù)庫(kù)選擇szscpdb,sid選擇szsc。
(2)
配置主庫(kù)和備庫(kù)信息
主庫(kù):
操作系統(tǒng):oracle liunx 5.6
主機(jī)名:SZSCPDB
ip地址:192.168.1.21
oracle_sid:szsc
db_unqiue_name:szscpdb
service_name:szscpdb
global_name:szscpdb
監(jiān)聽(tīng)名、端口:listener、1521
備庫(kù):
操作系統(tǒng):oracle liunx 5.6
主機(jī)名:SZSCSTB
ip地址:192.168.1.22
oracle_sid:szsc
db_unqiue_name:szscstb
service_name:szscstb
global_name:szscstb
監(jiān)聽(tīng)名、端口:listener、1521
(3)
查看主庫(kù)和備庫(kù)的hosts文件,確定ip和主機(jī)名的解析:
主庫(kù):
[oracle@SZSCPDB szscpdb]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.21 SZSCPDB
192.168.1.22 SZSCSTB
備庫(kù):
[oracle@SZSCSTB szscstb]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.21 SZSCPDB
192.168.1.22 SZSCSTB
(4)
確定主庫(kù)的監(jiān)聽(tīng)是開(kāi)啟的
[oracle@SZSCPDB szscpdb]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 15-DEC-2013 15:30:42
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SZSCPDB)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 15-DEC-2013 14:24:29
Uptime 0 days 1 hr. 6 min. 12 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/SZSCPDB/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SZSCPDB)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "szscXDB" has 1 instance(s).
Instance "szsc", status READY, has 1 handler(s) for this service...
Service "szscpdb" has 2 instance(s).
Instance "szsc", status UNKNOWN, has 1 handler(s) for this service...
Instance "szsc", status READY, has 1 handler(s) for this service...
The command completed successfully
(5)
配置主庫(kù)為歸檔模式:
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /arch/szscpdb
Oldest online log sequence 3
Next log sequence to archive 5
Current log sequence 5
(6)
更改主庫(kù)為force logging
SQL> alter database force logging;
Database altered.
(7)
創(chuàng)建主庫(kù)的密碼文件
[root@SZSCPDB dbs]# cd /u01/app/oracle/product/11.2.0/db_1/dbs/
[root@SZSCPDB dbs]# orapwd file=$ORACLE_HOME/dbs/orapwszsc password=oracle entries=30;
(8)
修改主庫(kù)的監(jiān)聽(tīng)文件,請(qǐng)確保有SID_LIST_LISTENER:
[root@SZSCPDB dbs]# cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[root@SZSCPDB admin]# vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = szscpdb)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = szsc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SZSCPDB)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
(9)
修改主庫(kù)的tnsname文件:
[root@SZSCPDB admin]# vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
SZSCPDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.21)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = szscpdb)
)
)
SZSCSTB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = szscstb)
)
)
(10)
修改主庫(kù)的參數(shù)文件:
[root@SZSCPDB admin]# cd /u01/app/oracle/product/11.2.0/db_1/dbs/
szsc.__db_cache_size=192937984
szsc.__java_pool_size=4194304
szsc.__large_pool_size=4194304
szsc.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
szsc.__pga_aggregate_target=209715200
szsc.__sga_target=306184192
szsc.__shared_io_pool_size=0
szsc.__shared_pool_size=96468992
szsc.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/szscpdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/szscpdb/control01.ctl','/u01/app/oracle/oradata/szscpdb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='szscpdb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=szscXDB)'
*.log_archive_config='dg_config=(szscpdb,szscstb)'
*.log_archive_dest_1='LOCATION=/arch/szscpdb LGWR VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=szscpdb'
*.log_archive_dest_2='SERVICE=SZSCSTB ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=szscstb'
*.DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscstb/','/u01/app/oracle/oradata/szscpdb/'
*.LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscstb/','/u01/app/oracle/oradata/szscpdb/'
*.log_archive_format='%t_%s_%r.arc'
*.memory_target=512753664
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
*.standby_file_management='AUTO'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.fal_server=szscstb
*.fal_client=szscpdb
*.db_unique_name=szscpdb
注意:
1、
log_archive_dest_2='SERVICE=SZSCSTB
這個(gè)參數(shù)就是tnsnames的別名,就是這個(gè)文件開(kāi)頭的那個(gè)大寫(xiě)的名字。
2、
*.fal_server=szscstb
*.fal_client=szscpdb
這兩個(gè)參數(shù)是各自的service_name。
(11)
傳輸主庫(kù)的參數(shù)文件、密碼文件以及tnsname文件到備庫(kù)上:
[oracle@SZSCPDB dbs]$ cd /u01/app/oracle/product/11.2.0/db_1/dbs
scp initszsc.ora orapwszsc SZSCSTB:$ORACLE_HOME/dbs
[oracle@SZSCPDB ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
scp tnsnames.ora SZSCSTB:$ORACLE_HOME/network/admin
(12)
修改備庫(kù)的參數(shù)文件:
[root@SZSCSTB admin]# cd /u01/app/oracle/product/11.2.0/db_1/dbs/
[root@SZSCSTB dbs]# vi initszsc.ora
szsc.__db_cache_size=192937984
szsc.__java_pool_size=4194304
szsc.__large_pool_size=4194304
szsc.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
szsc.__pga_aggregate_target=209715200
szsc.__sga_target=306184192
szsc.__shared_io_pool_size=0
szsc.__shared_pool_size=96468992
szsc.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/szscstb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/szscstb/control01.ctl','/u01/app/oracle/oradata/szscstb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='szscpdb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=szscXDB)'
*.log_archive_config='dg_config=(szscpdb,szscstb)'
*.log_archive_dest_1='LOCATION=/arch/szscstb LGWR VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=szscstb'
*.log_archive_dest_2='SERVICE=SZSCPDB ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=szscpdb'
*.DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscpdb/','/u01/app/oracle/oradata/szscstb/'
*.LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/szscpdb/','/u01/app/oracle/oradata/szscstb/'
*.log_archive_format='%t_%s_%r.arc'
*.memory_target=512753664
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
*.standby_file_management='AUTO'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.fal_server=szscpdb
*.fal_client=szscstb
*.db_unique_name=szscstb
(13)
在備庫(kù)上創(chuàng)建相應(yīng)的目錄,因?yàn)閭鋷?kù)開(kāi)始沒(méi)有創(chuàng)建數(shù)據(jù)庫(kù),有些目錄是參數(shù)文件中沒(méi)有的。
1、
audit_file_dest:
[oracle@SZSCSTB ~]$ mkdir -p /u01/app/oracle/admin/szscstb/adump/
2、
control_files:
[oracle@SZSCSTB ~]$ mkdir -p /u01/app/oracle/oradata/szscstb
3、
創(chuàng)建一個(gè)備份文件的位置,等會(huì)主庫(kù)會(huì)將備份傳遞過(guò)來(lái):
[root@SZSCSTB ~]# mkdir /backup
[root@SZSCSTB ~]# chown -R oracle:oinstall /backup
4、
創(chuàng)建一個(gè)歸檔目錄,接收主庫(kù)傳遞的歸檔日志:
[root@SZSCSTB ~]# mkdir -p /arch/szscstb
[root@SZSCSTB ~]# chown -R oracle:oinstall /arch/szscstb
(15)
在主庫(kù)上用rman做一個(gè)全備,也需要?jiǎng)?chuàng)建備份的目錄:
[root@SZSCPDB ~]# mkdir /backup
[root@SZSCPDB ~]# chown -R oracle:oinstall /backup
RMAN>backup device type disk format '/backup/%U' database plus archivelog;
(16)
將主庫(kù)的備份文件傳遞到備庫(kù)上:
[oracle@SZSCPDB admin]$ cd /backup/
[oracle@SZSCPDB backup]$ scp * SZSCSTB:/backup
(17)
將備庫(kù)啟動(dòng)到nomount狀態(tài):
[root@SZSCSTB ~]# su - oracle
[oracle@SZSCSTB ~]$ sqlplus / as sysdba
SQL> startup nomount;
(18)
修改備庫(kù)的監(jiān)聽(tīng)文件。
[oracle@SZSCSTB admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = szscstb)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = szsc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SZSCSTB)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
(19)
啟動(dòng)監(jiān)聽(tīng),確保服務(wù)名注冊(cè)無(wú)誤)
[oracle@SZSCSTB ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 15-DEC-2013 07:42:41
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SZSCSTB)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 15-DEC-2013 06:13:05
Uptime 0 days 1 hr. 29 min. 36 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/SZSCSTB/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SZSCSTB)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "szscXDB" has 1 instance(s).
Instance "szsc", status READY, has 1 handler(s) for this service...
Service "szscstb" has 2 instance(s).
Instance "szsc", status UNKNOWN, has 1 handler(s) for this service...
Instance "szsc", status READY, has 1 handler(s) for this service...
The command completed successfully
(20)
主庫(kù)應(yīng)用備份文件到備庫(kù)上,使用duplicate方式(在主庫(kù)上執(zhí)行)
RMAN> connect auxiliary sys/oracle@SZSCSTB
connected to auxiliary database: SZSCPDB (not mounted)
RMAN> duplicate target database for standby;
Starting Duplicate Db at 08-MAR-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
contents of Memory Script.:
{
restore clone standby controlfile;
}
executing Memory Script
Starting restore at 08-MAR-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /BACKUP/0lo3vm4i_1_1
channel ORA_AUX_DISK_1: piece handle=/backup/0lo3vm4i_1_1 tag=TAG20130308T022752
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/u01/app/oracle/oradata/szscstb/control01.ctl
output file name=/u01/app/oracle/oradata/szscstb/control02.ctl
Finished restore at 08-MAR-13
contents of Memory Script.:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script.:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/szscstb/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/szscstb/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/szscstb/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/szscstb/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/szscstb/users01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/szscstb/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 08-MAR-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to //u01/app/oracle/oradata/szscstb/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/szscstb/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/szscstb/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/szscstb/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /backup/0ko3vm18_1_1
channel ORA_AUX_DISK_1: piece handle=/backup/0ko3vm18_1_1 tag=TAG20130308T022752
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:05
Finished restore at 08-MAR-13
contents of Memory Script.:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/users01.dbf
Finished Duplicate Db at 08-MAR-13
(21)
執(zhí)行備庫(kù)恢復(fù)模式。(在備庫(kù)上執(zhí)行)
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
szsc MOUNTED
SQL> alter database recover managed standby database disconnect from session;
Database altered.
(22)
查看日志同步情況,確保日志都應(yīng)用了。
SQL> SELECT SEQUENCE#, REGISTRAR, FIRST_TIME, NEXT_TIME, APPLIED
2 FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# REGISTR FIRST_TIM NEXT_TIME APPLIED
---------- ------- --------- --------- ---------
13 RFS 15-DEC-13 15-DEC-13 YES
14 RFS 15-DEC-13 15-DEC-13 YES
15 RFS 15-DEC-13 15-DEC-13 YES
16 RFS 15-DEC-13 15-DEC-13 YES
17 RFS 15-DEC-13 15-DEC-13 YES
18 RFS 15-DEC-13 15-DEC-13 YES
19 RFS 15-DEC-13 15-DEC-13 YES
20 RFS 15-DEC-13 15-DEC-13 YES
21 RFS 15-DEC-13 15-DEC-13 YES
22 RFS 15-DEC-13 15-DEC-13 YES
(23)
創(chuàng)建standby logfile。主庫(kù)和備庫(kù)都要添加。
主庫(kù):
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscpdb/sredo01.log' size 512M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscpdb/sredo02.log' size 512M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscpdb/sredo03.log' size 512M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscpdb/sredo04.log' size 512M;
備庫(kù):
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscstb/sredo01.log' size 512M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscstb/sredo02.log' size 512M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscstb/sredo03.log' size 512M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/szscstb/sredo04.log' size 512M;
(24)
實(shí)現(xiàn)日志同步。(備庫(kù)上執(zhí)行)
SQL> alter database recover managed standby database disconnect from session;
完成之后,結(jié)束這個(gè)恢復(fù)進(jìn)程:
SQL> alter database recover managed standby database cancel;
將備庫(kù)啟動(dòng)到open read only的狀態(tài)。
SQL> alter database open read only;
(25)
查看主庫(kù)和備庫(kù)的日志同步情況,確保已經(jīng)同步。(如果沒(méi)有同步,繼續(xù)第24步)
主庫(kù):
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /arch/szscpdb
Oldest online log sequence 21
Next log sequence to archive 23
Current log sequence 23
備庫(kù):
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /arch/szscstb
Oldest online log sequence 21
Next log sequence to archive 0
Current log sequence 23
在備庫(kù)上執(zhí)行:
SQL> SELECT SEQUENCE#, REGISTRAR, FIRST_TIME, NEXT_TIME, APPLIED
2 FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# REGISTR FIRST_TIM NEXT_TIME APPLIED
---------- ------- --------- --------- ---------
13 RFS 15-DEC-13 15-DEC-13 YES
14 RFS 15-DEC-13 15-DEC-13 YES
15 RFS 15-DEC-13 15-DEC-13 YES
16 RFS 15-DEC-13 15-DEC-13 YES
17 RFS 15-DEC-13 15-DEC-13 YES
18 RFS 15-DEC-13 15-DEC-13 YES
19 RFS 15-DEC-13 15-DEC-13 YES
20 RFS 15-DEC-13 15-DEC-13 YES
21 RFS 15-DEC-13 15-DEC-13 YES
22 RFS 15-DEC-13 15-DEC-13 YES
(26)
確認(rèn)數(shù)據(jù)可以同步,在主庫(kù)上創(chuàng)建一張表,看備庫(kù)上是否可以查看到。
主庫(kù):
SQL> create table zsx (id number);
Table created.
備庫(kù):
SQL> desc zsx
ERROR:
ORA-04043: object zsx does not exist
注意:
發(fā)現(xiàn)數(shù)據(jù)沒(méi)有同步,請(qǐng)執(zhí)行下面27,接收數(shù)據(jù)。
(27)
備庫(kù)上接收數(shù)據(jù),并自動(dòng)同步:
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> desc zsx
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER
(28)
再次驗(yàn)證數(shù)據(jù)是否同步。
主庫(kù):
SQL> insert into zsx values(1);
1 row created.
SQL> commit;
Commit complete.
備庫(kù):
SQL> select * from zsx;
ID
----------
1
(29)
如果28步?jīng)]有問(wèn)題,那么就代表你的DG配置成功了。下一階段就是實(shí)現(xiàn)switchover了。