概述:前文redhat 6.4 oracle 11g dataguard 搭建(一)我们已经使用冷备进行dg的搭建,此文将使用rman的duplicate技术进行dg搭建;步骤都是相同的,让我们开始吧!
实验:
1、监听配置
[root@cube tmp]# su - oracle
[oracle@cube ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 31-DEC-2017 14:48:45
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@cube ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@cube admin]$ vi listener.ora
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=CUBE)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(SID_NAME=CUBE))
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(PROGRAM=extproc)))
[oracle@cube admin]$ vi tnsnames.ora
CUBE=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521))
(CONNECT_DATA=
(SERVER=dedicated)
(SERVICE_NAME=CUBE)))
JAKKI=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.68)(PORT=1521))
(CONNECT_DATA=
(SERVER=dedicated)
(SERVICE_NAME=JAKKI)))
[oracle@cube admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 31-DEC-2017 14:52:19
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/cube/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 31-DEC-2017 14:52:20
Uptime 0 days 0 hr. 0 min. 0 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/cube/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary...
Service "CUBE" has 1 instance(s).
Instance "CUBE", status UNKNOWN, has 1 handler(s) for this service...
Service "plsextproc" has 1 instance(s).
Instance "plsextproc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@jakki ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@jakki admin]$ vi listener.ora
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.68)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=JAKKI)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(SID_NAME=JAKKI))
(SID_DESC=
(SID_NAME=plsextproc)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(PROGRAM=extproc)))
~
[oracle@jakki admin]$ vi tnsnames.ora
CUBE=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521))
(CONNECT_DATA=
(SERVER=dedicated)
(SERVICE_NAME=CUBE)))
JAKKI=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.68)(PORT=1521))
(CONNECT_DATA=
(SERVER=dedicated)
(SERVICE_NAME=JAKKI)))
[oracle@jakki admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 31-DEC-2017 14:54:04
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/jakki/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.68)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.68)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 31-DEC-2017 14:54:05
Uptime 0 days 0 hr. 0 min. 0 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/jakki/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.68)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary...
Service "JAKKI" has 1 instance(s).
Instance "JAKKI", status UNKNOWN, has 1 handler(s) for this service...
Service "plsextproc" has 1 instance(s).
Instance "plsextproc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@cube admin]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Dec 31 14:56:00 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database force logging;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 2
Current log sequence 2
SQL> create pfile from spfile;
File created.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
[oracle@cube dbs]$ vi initCUBE.ora ---添加内容
DB_UNIQUE_NAME=CUBE
LOG_ARCHIVE_CONFIG='DG_CONFIG=(CUBE,JAKKI)'
LOG_ARCHIVE_DEST_1=
'LOCATION=/u01/app/oracle/fast_recovery_area
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=CUBE'
LOG_ARCHIVE_DEST_2=
'SERVICE=JAKKI ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=JAKKI'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=JAKKI
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/JAKKI/','/u01/app/oracle/oradata/CUBE/'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/JAKKI/','/u01/app/oracle/oradata/CUBE/'
STANDBY_FILE_MANAGEMENT=AUTO
SQL> create spfile from pfile;
File created.
SQL> startup
ORACLE instance started.
Total System Global Area 839282688 bytes
Fixed Size 2257880 bytes
Variable Size 545262632 bytes
Database Buffers 289406976 bytes
Redo Buffers 2355200 bytes
Database mounted.
Database opened.
将参数文件传输至jakki上
[oracle@cube dbs]$ scp initCUBE.ora 192.168.1.68:/u01/app/oracle/product/11.2.0/db_1/dbs/initJAKKI.ora
The authenticity of host '192.168.1.68 (192.168.1.68)' can't be established.
RSA key fingerprint is b1:d6:b5:7f:6e:66:72:ee:86:ad:35:c3:cb:ab:fa:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.68' (RSA) to the list of known hosts.
oracle@192.168.1.68's password:
scp: u01/app/oracle/product/11.2.0/db_1/dbs/initJAKKI.ora: No such file or directory
[oracle@cube dbs]$ scp orapwCUBE 192.168.1.68:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwJAKKI
[oracle@jakki dbs]$ cat initJAKKI.ora
*.audit_file_dest='/u01/app/oracle/admin/JAKKI/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/JAKKI/control01.ctl','/u01/app/oracle/fast_recovery_area/JAKKI/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='CUBE'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=JAKKIXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=839909376
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=JAKKI
LOG_ARCHIVE_CONFIG='DG_CONFIG=(JAKKI,CUBE)'
LOG_ARCHIVE_DEST_1=
'LOCATION=/u01/app/oracle/fast_recovery_area
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=JAKKI'
LOG_ARCHIVE_DEST_2=
'SERVICE=CUBE ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=CUBE'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=CUBE
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/CUBE/','/u01/app/oracle/oradata/JAKKI/'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/CUBE/','/u01/app/oracle/oradata/JAKKI/'
STANDBY_FILE_MANAGEMENT=AUTO
[oracle@jakki dbs]$ mkdir -p /u01/app/oracle/oradata/JAKKI/
[oracle@jakki dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area
[oracle@jakki dbs]$ mkdir -p /u01/app/oracle/admin/JAKKI/adump
[oracle@jakki admin]$ mkdir -p /u01/app/oracle/fast_recovery_area/JAKKI
启动备库至nomount状态:
[oracle@jakki dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Dec 31 15:09:38 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile;
File created.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 839282688 bytes
Fixed Size 2257880 bytes
Variable Size 545262632 bytes
Database Buffers 289406976 bytes
Redo Buffers
使用duplicate进行数据拷贝:
[oracle@cube dbs]$ rman target / auxiliary sys/windows@jakki
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Dec 31 15:11:46 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: CUBE (DBID=3147674261)
connected to auxiliary database: CUBE (not mounted)
RMAN> duplicate target database for standby from active database;
进行主备数据同步 :
[oracle@jakki dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Dec 31 15:15:56 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select status from v$instance;
STATUS
------------------------
MOUNTED
SQL> recover managed standby database disconnect;
Media recovery complete.
SQL> recover managed standby database cancel;
Media recovery complete.
SQL> alter database open;
Database altered.
SQL> recover managed standby database disconnect;
Media recovery complete.
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------------------------------------- --------------------------------
READ ONLY WITH APPLY PHYSICAL STANDBY
总结:至此 duplicate搭建dg完成;