开启两台库A 18.109 B 18.69
在A上 startup 再 startup mount
修改为归档模式 alter database archivelog;
改为强制写日志
SQL> alter database force logging;
修改参数文件,通过spfile 建立Pfile
create pfile from spfile;
在路径/oracle/app/oracle/product/10.2.0/db_1/dbs/下修改initTEST.ora添加如下内容
DB_UNIQUE_NAME=TEST
LOG_ARCHIVE_CONFIG='DG_CONFIG=(db109,db69)'
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=TEST'
LOG_ARCHIVE_DEST_2='SERVICE=db69 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=TEST'
FAL_SERVER=db109
FAL_CLIENT=db69
STANDBY_FILE_MANAGE=AUTO
配置监听文件/oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.18.109) (PORT = 1521))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_NAME = TEST)
(ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1)
(SID_NAME = TEST)
)
)
配置监听文件/oracle/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
db109 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.109)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = TEST)
)
)
db69 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.69)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = TEST)
)
)
开启监听
将参数文件/oracle/app/oracle/product/10.2.0/db_1/dbs/initTEST.ora
scp oracle@192.168.69:/home/oracle/oracle/app/oracle/product/10.2.0/db_1/dbs/下
B 备份库上
进入到/oracle/app/oracle/product/10.2.0/db_1/dbs/initTEST.ora修改如下内容
LOG_ARCHIVE_DEST_2='SERVICE=db109 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=TEST'
FAL_SERVER=db69
FAL_CLIENT=db109
配置监听文件/oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.18.69) (PORT = 1521))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_NAME = TEST)
(ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1)
(SID_NAME = TEST)
)
)
配置监听文件/oracle/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
db69 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.69)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = TEST)
)
)
db109 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.109)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = TEST)
)
)
开启监听lsnrctl start
SQL>startup mount force
A B上分别执行
mkdir db_bak
mkdir archive
A上 rman target / 进入rman模式
RMAN> backup full database format='/home/oracle/db_bak/%U' include current controlfile for standby;
进入db_bak目录下 执行scp * oracle@192.168.18.69:/home/oracle/db_bak/
再在rman模式接着执行如下操作
RMAN> connect auxiliary sys/123456@db69
RMAN> duplicate target database for standby nofilenamecheck;
进入sql模式
SQL> select process from v$managed_standby;
PROCESS
---------
ARCH
ARCH
SQL> alter system switch logfile;多次执行
SQL> select process from v$managed_standby;
PROCESS
---------
ARCH
ARCH
LNS
B上
SQL> select process from v$managed_standby;
PROCESS
---------
ARCH
ARCH
RFS
RFS
SQL> alter database recover managed standby database disconnect from session;
SQL> select process from v$managed_standby;
PROCESS
---------
ARCH
ARCH
RFS
RFS
MRP0
搭建DG完成进行验证
A 上
SQL> create table t01 as select * from dba_objects;
SQL> commit;
SQL> select count(*) from t01;查看有数据产生
SQL> alter system switch logfile;
B 上
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> select count(*) from t01;产看也有数据产生 验证成功
转载于:https://blog.51cto.com/6236004/1093591