千家信息网

Oracle 11g配置DG

发表于:2024-11-19 作者:千家信息网编辑
千家信息网最后更新 2024年11月19日,一:修改主库参数文件:*.DB_UNIQUE_NAME=PHUB*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(MECBS,PHUB)'*.LOG_ARCHIVE_DEST_2='S
千家信息网最后更新 2024年11月19日Oracle 11g配置DG

一:修改主库参数文件:

*.DB_UNIQUE_NAME=PHUB*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(MECBS,PHUB)'*.LOG_ARCHIVE_DEST_2='SERVICE=MECBS LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=MECBS'*.log_archive_dest_state_1=enable*.log_archive_dest_state_2=enable*.standby_file_management=auto*.log_archive_dest_1='location=+DATA valid_for=(all_logfiles,all_roles) db_unique_name=PHUB'

二:安装备库oracle软件:

  1. 安装操作系统:略

  2. 修改主机名和hosts文件:


  3. [root@dg ~]# more /etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1localhost.localdomain localhost::1localhost6.localdomain6 localhost6172.16.30.228dg

4.修改系统参数:

[root@dg ~]# cat >>/etc/sysctl.conf < fs.file-max = 6815744> kernel.sem = 250 32000 100 128> kernel.shmmni = 4096> kernel.shmall = 1073741824> kernel.shmmax = 4398046511104> net.core.rmem_default = 262144> net.core.rmem_max = 4194304> net.core.wmem_default = 262144> net.core.wmem_max = 1048576> fs.aio-max-nr = 1048576> net.ipv4.ip_local_port_range = 9000 65500> eof
[root@dg ~]# sysctl -pnet.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 2net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296fs.file-max = 6815744kernel.sem = 250 32000 100 128kernel.shmmni = 4096kernel.shmall = 1073741824kernel.shmmax = 4398046511104net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576fs.aio-max-nr = 1048576net.ipv4.ip_local_port_range = 9000 65500

5.修改资源限制配置文件:

[root@dg ~]# cat >>/etc/security/limits.conf < grid   soft   nofile    1024> grid   hard   nofile    65536> grid   soft   nproc    2047> grid   hard   nproc    16384> grid   soft   stack    10240> grid   hard   stack    32768> oracle   soft   nofile    1024> oracle   hard   nofile    65536> oracle   soft   nproc    2047> oracle   hard   nproc    16384> oracle   soft   stack    10240> oracle   hard   stack    32768> eof[root@dg ~]# tail -20 /etc/security/limits.conf grid   soft   nofile    1024grid   hard   nofile    65536grid   soft   nproc    2047grid   hard   nproc    16384grid   soft   stack    10240grid   hard   stack    32768oracle   soft   nofile    1024oracle   hard   nofile    65536oracle   soft   nproc    2047oracle   hard   nproc    16384oracle   soft   stack    10240oracle   hard   stack    3276

6.配置yum源并安装依赖包:

[root@dg ~]# cat /etc/yum.repos.d/local.repo [Redhat6]name= Enterpress6.5baseurl=file:///mnt/Serverenabled=1gpgcheck=0[root@dg ~]# mount /dev/sr0 /mnt/mount: block device /dev/sr0 is write-protected, mounting read-only
yum -y install binutils compat-libstdc++-33elfutils-libelf \elfutils-libelf-devel elfutils-libelf-devel-static gccgcc-c++ glibc glibc-common \glibc-devel kernel-headers ksh libaio libaio-devel libgcclibgomp libstdc++ libstdc++-devel \make numactl-devel sysstatunixODBC unixODBC-devel pdksh

7.建立用户,用户组,安装目录:

[root@dg ~]# /usr/sbin/groupadd -g 54321 oinstall[root@dg ~]# /usr/sbin/groupadd -g 54322 dba[root@dg ~]# /usr/sbin/groupadd -g 54323 oper[root@dg ~]# /usr/sbin/groupadd -g 54324 backupdba[root@dg ~]# /usr/sbin/groupadd -g 54325 dgdba[root@dg ~]# /usr/sbin/groupadd -g 54327 asmdba[root@dg ~]# /usr/sbin/groupadd -g 54328 asmoper[root@dg ~]# /usr/sbin/groupadd -g 54329 asmadmin[root@dg ~]# /usr/sbin/useradd -u 54321 -g oinstall -G asmadmin,asmdba,asmoper,dba grid[root@dg ~]# /usr/sbin/useradd -u 54322 -g oinstall -G dba,backupdba,dgdba,asmadmin,asmdba orac[root@dg ~]# passwd gridChanging password for user grid.New UNIX password: BAD PASSWORD: it is too shortRetype new UNIX password: Sorry, passwords do not match.New UNIX password: BAD PASSWORD: it is too shortRetype new UNIX password: passwd: all authentication tokens updated successfully.[root@dg ~]# passwd oracleChanging password for user oracle.New UNIX password: BAD PASSWORD: it is based on a dictionary wordRetype new UNIX password: passwd: all authentication tokens updated successfully.[root@dg ~]#  mkdir -p /u01/app/grid[root@dg ~]#  mkdir -p /u01/app/11.2.0/grid[root@dg ~]# mkdir -p /u01/app/oracle/product/11.2.0/db_1[root@dg ~]#  chown -R grid.oinstall /u01[root@dg ~]# chown -R oracle.oinstall /u01/app/oracle[root@dg ~]# chmod -R 775 /u01

8.配置环境变量:

[root@dg ~]# cat >>/home/grid/.bash_profile < eof[root@dg ~]# source /home/grid/.bash_profile[root@dg ~]# cat >>/home/oracle/.bash_profile <

9.配置ASM磁盘:

[root@dg Server]# rpm -ivh oracleasm-support-2.1.7-1.el5.x86_64.rpm warning: oracleasm-support-2.1.7-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159Preparing...                ########################################### [100%]   1:oracleasm-support      ########################################### [100%][root@dg Server]# rpm -ivh oracleasm-2.6.18-308.el5-2.0.5-1.el5.x86_64.rpm warning: oracleasm-2.6.18-308.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159Preparing...                ########################################### [100%]   1:oracleasm-2.6.18-308.el########################################### [100%][root@dg Server]# cd [root@dg ~]# rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159Preparing...                ########################################### [100%]   1:oracleasmlib           ########################################### [100%]
[root@dg ~]# /etc/init.d/oracleasm configure -iConfiguring the Oracle ASM library driver.This will configure the on-boot properties of the Oracle ASM librarydriver.  The following questions will determine whether the driver isloaded on boot and what permissions it will have.  The current valueswill be shown in brackets ('[]').  Hitting  without typing ananswer will keep that current value.  Ctrl-C will abort.Default user to own the driver interface []: gridDefault group to own the driver interface []: asmadminStart Oracle ASM library driver on boot (y/n) [n]: yScan for Oracle ASM disks on boot (y/n) [y]: yWriting Oracle ASM library driver configuration: doneInitializing the Oracle ASMLib driver:                     [  OK  ]Scanning the system for Oracle ASMLib disks:               [  OK  ]
[root@dg ~]# /etc/init.d/oracleasm createdisk CRS /dev/sdb1Marking disk "CRS" as an ASM disk:                         [  OK  ][root@dg ~]# /etc/init.d/oracleasm createdisk DATA1 /dev/sdc1 Marking disk "DATA1" as an ASM disk:                       [  OK  ][root@dg ~]# /etc/init.d/oracleasm createdisk DATA2 /dev/sdd1Marking disk "DATA2" as an ASM disk:                       [  OK  ][root@dg ~]# /etc/init.d/oracleasm scandisksScanning the system for Oracle ASMLib disks:               [  OK  ][root@dg ~]# /etc/init.d/oracleasm listdisksCRSDATA1DATA2

9.上传安装文件安装grid和oracle软件:略

二.配置DG:(主库实例PHUB,备库实例MECBS)

1.备库配置静态监听:()

在grid的监听文件中加入:

SID_LIST_LISTENER=       (SID_LIST=       (SID_DESC=       (GLOBAL_DBNAME=MECBS)       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)       (SID_NAME=MECBS)         )        )

重启监听:

Service "MECBS" has 1 instance(s).  Instance "MECBS", status UNKNOWN, has 1 handler(s) for this service...The command completed successfully

2.配置主库和备库的tns:(注意把主机名换成IP)

PHUB =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.30.228)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = PHUB)    )  )MECBS =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = MECBS)    )  )

用tnsping验证:

[oracle@cwogg admin]$ tnsping PHUBTNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 22-SEP-2015 16:20:37Copyright (c) 1997, 2013, Oracle.  All rights reserved.Used parameter files:/u01/app/oracle/product/11.2.0/db_1/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = cwogg)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PHUB)))OK (50 msec)

3.编辑备库参数文件:

[oracle@dg dbs]$ more initMECBS.ora *.db_name='PHUB'  这里和主库一样的

4.拷贝密码文件:

[oracle@cwogg dbs]$ scp orapwPHUB 172.16.30.228:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwMECBSoracle@172.16.30.228's password: orapwPHUB

100% 1536 1.5KB/s 00:00

5.编辑duplicate.sql

[oracle@cwogg ~]$ vim duplicate.sql duplicate target databasefor standbyfrom active database nofilenamecheckDORECOVERspfileset service_names='MECBS'set db_unique_name='MECBS'set log_archive_config='dg_config=(MECBS,PHUB)'set log_archive_dest_1='location=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=MECBS'set log_archive_dest_2='SERVICE=PHUB  LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHUB'set standby_file_management='AUTO'set diagnostic_dest='/u01/app/oracle'set audit_file_dest='/u01/app/oracle/admin/MECBS/adump'set fal_server='PHUB'set fal_client='MECBS'set control_files='+DATA/mecbs/controlfile/control01.ctl','+DATA/mecbs/controlfile/control02.ctl'set cluster_database='false'#set DB_FILE_NAME_CONVERT='' 数据库文件路径不一样需要详细写出来#set LOG_FILE_NAME_CONVERT=''set db_create_file_dest='+DATA'set db_recovery_file_dest='+DATA'set db_recovery_file_dest_size='4G';

6.启动备库nomount:

[oracle@dg oracle]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 22 16:43:28 2015Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to an idle instance.SQL> startup nomount;ORACLE instance started.Total System Global Area  217157632 bytesFixed Size    2251816 bytesVariable Size  159384536 bytesDatabase Buffers   50331648 bytesRedo Buffers    5189632 bytes

7.主库配置standbylog,flashback,归档模式:

[oracle@cwogg dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 22 16:45:56 2015Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, Automatic Storage Management, OLAP, Data Miningand Real Application Testing optionsSQL> select thread#,bytes/1024/1024 "SIZE(MB)",MEMBERS FROM V$LOG;   THREAD#   SIZE(MB) MEMBERS---------- ---------- ---------- 1   50       2 1   50       2 1   50       2SQL> alter database add standby logfile thread 1('+DATA') size 50M;Database altered.SQL> alter database add standby logfile thread 1('+DATA') size 50M;Database altered.SQL> alter database add standby logfile thread 1('+DATA') size 50M;Database altered.SQL> select thread#,bytes/1024/1024 "SIZE(MB)",MEMBERS FROM V$LOG;   THREAD#   SIZE(MB) MEMBERS---------- ---------- ---------- 1   50       2 1   50       2 1   50       2SQL> select thread#,bytes/1024/1024 "SIZE(MB)" FROM V$standby_LOG;   THREAD#   SIZE(MB)---------- ---------- 1   50 1   50 1   50SQL> select flashback_on from v$database;FLASHBACK_ON------------------YESSQL> archive log list;Database log mode       Archive ModeAutomatic archival       EnabledArchive destination       USE_DB_RECOVERY_FILE_DESTOldest online log sequence     25Next log sequence to archive   27Current log sequence       27

7.在主库上执行duplicate:

[oracle@cwogg ~]$ rman target / auxiliary sys/123123@172.16.30.228/MECBSRecovery Manager: Release 11.2.0.4.0 - Production on Tue Sep 22 16:50:55 2015Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.connected to target database: PHUB (DBID=536511065)connected to auxiliary database: PHUB (not mounted)RMAN> @duplicate.sqlRMAN> duplicate target database2> for standby3> from active database nofilenamecheck4> DORECOVER5> spfile6> set service_names='MECBS'7> set db_unique_name='MECBS'8> set log_archive_dest_1='location=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=MECBS'9> set log_archive_dest_2='SERVICE=PHUB  LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHUB'10> set standby_file_management='AUTO'11> set diagnostic_dest='/u01/app/oracle'12> set audit_file_dest='/u01/app/oracle/admin/MECBS/adump'13> set fal_server='PHUB'14> set fal_client='MECBS'15> set control_files='+DATA/mecbs/controlfile/control01.ctl','+DATA/mecbs/controlfile/control02.ctl'16> set cluster_database='false'17> #set DB_FILE_NAME_CONVERT='/oradata/rpt','+DATA/cwrptb/datafile','/oradata/smt','+DATA/cwrptb/datafile','/oradata/fol','+DATA/cwrptb/datafile','/oradata/acf','+DATA/cwrptb/datafile','/oradata/eol','+DATA/cwrptb/datafile','/oracle/product/ora11gr2/oradata/CWRPT','+DATA/cwrptb/datafile'18> #set LOG_FILE_NAME_CONVERT='/arch/CWRPT/onlinelog','+DATA/cwrptb/onlinelog'19> set db_create_file_dest='+DATA'20> set db_recovery_file_dest='+DATA'21> set db_recovery_file_dest_size='4G';Starting Duplicate Db at 22-SEP-15using target database control file instead of recovery catalogallocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=20 device type=DISKallocated channel: ORA_AUX_DISK_2channel ORA_AUX_DISK_2: SID=21 device type=DISKcontents of Memory Script:{   backup as copy reuse   targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPHUB' auxiliary format  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwMECBS'   targetfile  '+DATA/phub/spfilephub.ora' auxiliary format  '/u01/app/oracle/product/11.2.0/db_1/dbs/spfileMECBS.ora'   ;   sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfileMECBS.ora''";}executing Memory ScriptStarting backup at 22-SEP-15allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=9 device type=DISKallocated channel: ORA_DISK_2channel ORA_DISK_2: SID=191 device type=DISKFinished backup at 22-SEP-15sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfileMECBS.ora''contents of Memory Script:{   sql clone "alter system set  service_names =  ''MECBS'' comment= '''' scope=spfile";   sql clone "alter system set  db_unique_name =  ''MECBS'' comment= '''' scope=spfile";   sql clone "alter system set  log_archive_dest_1 =  ''location=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=MECBS'' comment= '''' scope=spfile";   sql clone "alter system set  log_archive_dest_2 =  ''SERVICE=PHUB  LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHUB'' comment= '''' scope=spfile";   sql clone "alter system set  standby_file_management =  ''AUTO'' comment= '''' scope=spfile";   sql clone "alter system set  diagnostic_dest =  ''/u01/app/oracle'' comment= '''' scope=spfile";   sql clone "alter system set  audit_file_dest =  ''/u01/app/oracle/admin/MECBS/adump'' comment= '''' scope=spfile";   sql clone "alter system set  fal_server =  ''PHUB'' comment= '''' scope=spfile";   sql clone "alter system set  fal_client =  ''MECBS'' comment= '''' scope=spfile";   sql clone "alter system set  control_files =  ''+DATA/mecbs/controlfile/control01.ctl'', ''+DATA/mecbs/controlfile/control02.ctl'' comment= '''' scope=spfile";   sql clone "alter system set  cluster_database =  false comment= '''' scope=spfile";   sql clone "alter system set  db_create_file_dest =  ''+DATA'' comment= '''' scope=spfile";   sql clone "alter system set  db_recovery_file_dest =  ''+DATA'' comment= '''' scope=spfile";   sql clone "alter system set  db_recovery_file_dest_size =  4G comment= '''' scope=spfile";   shutdown clone immediate;   startup clone nomount;}executing Memory Scriptsql statement: alter system set  service_names =  ''MECBS'' comment= '''' scope=spfilesql statement: alter system set  db_unique_name =  ''MECBS'' comment= '''' scope=spfilesql statement: alter system set  log_archive_dest_1 =  ''location=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=MECBS'' comment= '''' scope=spfilesql statement: alter system set  log_archive_dest_2 =  ''SERVICE=PHUB  LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHUB'' comment= '''' scope=spfilesql statement: alter system set  standby_file_management =  ''AUTO'' comment= '''' scope=spfilesql statement: alter system set  diagnostic_dest =  ''/u01/app/oracle'' comment= '''' scope=spfilesql statement: alter system set  audit_file_dest =  ''/u01/app/oracle/admin/MECBS/adump'' comment= '''' scope=spfilesql statement: alter system set  fal_server =  ''PHUB'' comment= '''' scope=spfilesql statement: alter system set  fal_client =  ''MECBS'' comment= '''' scope=spfilesql statement: alter system set  control_files =  ''+DATA/mecbs/controlfile/control01.ctl'', ''+DATA/mecbs/controlfile/control02.ctl'' comment= '''' scope=spfilesql statement: alter system set  cluster_database =  false comment= '''' scope=spfilesql statement: alter system set  db_create_file_dest =  ''+DATA'' comment= '''' scope=spfilesql statement: alter system set  db_recovery_file_dest =  ''+DATA'' comment= '''' scope=spfilesql statement: alter system set  db_recovery_file_dest_size =  4G comment= '''' scope=spfileOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area     835104768 bytesFixed Size                     2257840 bytesVariable Size                541068368 bytesDatabase Buffers             289406976 bytesRedo Buffers                   2371584 bytescontents of Memory Script:{   backup as copy current controlfile for standby auxiliary format  '+DATA/mecbs/controlfile/control01.ctl';   restore clone controlfile to  '+DATA/mecbs/controlfile/control02.ctl' from  '+DATA/mecbs/controlfile/control01.ctl';}executing Memory ScriptStarting backup at 22-SEP-15using channel ORA_DISK_1using channel ORA_DISK_2channel ORA_DISK_1: starting datafile copycopying standby control fileoutput file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PHUB.f tag=TAG20150922T165146 RECID=2 STAMP=891103907channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07Finished backup at 22-SEP-15Starting restore at 22-SEP-15allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=23 device type=DISKallocated channel: ORA_AUX_DISK_2channel ORA_AUX_DISK_2: SID=24 device type=DISKchannel ORA_AUX_DISK_2: skipped, AUTOBACKUP already foundchannel ORA_AUX_DISK_1: copied control file copyFinished restore at 22-SEP-15contents of Memory Script:{   sql clone 'alter database mount standby database';}executing Memory Scriptsql statement: alter database mount standby databasecontents of Memory Script:{   set newname for clone tempfile  1 to new;   switch clone tempfile all;   set newname for clone datafile  1 to new;   set newname for clone datafile  2 to new;   set newname for clone datafile  3 to new;   set newname for clone datafile  4 to new;   set newname for clone datafile  5 to new;   set newname for clone datafile  6 to new;   backup as copy reuse   datafile  1 auxiliary format new   datafile  2 auxiliary format new   datafile  3 auxiliary format new   datafile  4 auxiliary format new   datafile  5 auxiliary format new   datafile  6 auxiliary format new   ;   sql 'alter system archive log current';}executing Memory Scriptexecuting command: SET NEWNAMErenamed tempfile 1 to +DATA in control fileexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting backup at 22-SEP-15using channel ORA_DISK_1using channel ORA_DISK_2channel ORA_DISK_1: starting datafile copyinput datafile file number=00006 name=+DATA/phub/datafile/llc01.dbfchannel ORA_DISK_2: starting datafile copyinput datafile file number=00001 name=+DATA/phub/datafile/system.287.890482863output file name=+DATA/mecbs/datafile/system.259.891103927 tag=TAG20150922T165212channel ORA_DISK_2: datafile copy complete, elapsed time: 00:02:25channel ORA_DISK_2: starting datafile copyinput datafile file number=00002 name=+DATA/phub/datafile/sysaux.269.890482863output file name=+DATA/mecbs/datafile/sysaux.260.891104071 tag=TAG20150922T165212channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:55channel ORA_DISK_2: starting datafile copyinput datafile file number=00005 name=+DATA/phub/datafile/example.271.890482863output file name=+DATA/mecbs/datafile/example.261.891104187 tag=TAG20150922T165212channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:55channel ORA_DISK_2: starting datafile copyinput datafile file number=00003 name=+DATA/phub/datafile/undotbs1.272.890482863output file name=+DATA/mecbs/datafile/undotbs1.262.891104243 tag=TAG20150922T165212channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:25channel ORA_DISK_2: starting datafile copyinput datafile file number=00004 name=+DATA/phub/datafile/users.260.890482863output file name=+DATA/mecbs/datafile/users.263.891104267 tag=TAG20150922T165212channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:15output file name=+DATA/mecbs/datafile/llc.258.891103925 tag=TAG20150922T165212channel ORA_DISK_1: datafile copy complete, elapsed time: 00:08:27Finished backup at 22-SEP-15sql statement: alter system archive log currentcontents of Memory Script:{   backup as copy reuse   archivelog like  "+DATA/phub/archivelog/2015_09_22/thread_1_seq_27.325.891104439" auxiliary format  "+DATA"   ;   catalog clone start with  "+DATA";   switch clone datafile all;}executing Memory ScriptStarting backup at 22-SEP-15using channel ORA_DISK_1using channel ORA_DISK_2channel ORA_DISK_1: starting archived log copyinput archived log thread=1 sequence=27 RECID=54 STAMP=891104440output file name=+DATA/mecbs/archivelog/2015_09_22/thread_1_seq_27.264.891104435 RECID=0 STAMP=0channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01Finished backup at 22-SEP-15searching for all files that match the pattern +DATAList of Files Unknown to the Database=====================================File Name: +data/mecbs/ARCHIVELOG/2015_09_22/thread_1_seq_27.264.891104435File Name: +data/mecbs/DATAFILE/LLC.258.891103925File Name: +data/mecbs/DATAFILE/SYSTEM.259.891103927File Name: +data/mecbs/DATAFILE/SYSAUX.260.891104071File Name: +data/mecbs/DATAFILE/EXAMPLE.261.891104187File Name: +data/mecbs/DATAFILE/UNDOTBS1.262.891104243File Name: +data/mecbs/DATAFILE/USERS.263.891104267File Name: +data/ASM/ASMPARAMETERFILE/REGISTRY.253.891100399cataloging files...cataloging doneList of Cataloged Files=======================File Name: +data/mecbs/ARCHIVELOG/2015_09_22/thread_1_seq_27.264.891104435File Name: +data/mecbs/DATAFILE/LLC.258.891103925File Name: +data/mecbs/DATAFILE/SYSTEM.259.891103927File Name: +data/mecbs/DATAFILE/SYSAUX.260.891104071File Name: +data/mecbs/DATAFILE/EXAMPLE.261.891104187File Name: +data/mecbs/DATAFILE/UNDOTBS1.262.891104243File Name: +data/mecbs/DATAFILE/USERS.263.891104267List of Files Which Where Not Cataloged=======================================File Name: +data/ASM/ASMPARAMETERFILE/REGISTRY.253.891100399  RMAN-07518: Reason: Foreign database file DBID: 0  Database Name: datafile 1 switched to datafile copyinput datafile copy RECID=8 STAMP=891104436 file name=+DATA/mecbs/datafile/system.259.891103927datafile 2 switched to datafile copyinput datafile copy RECID=9 STAMP=891104436 file name=+DATA/mecbs/datafile/sysaux.260.891104071datafile 3 switched to datafile copyinput datafile copy RECID=10 STAMP=891104436 file name=+DATA/mecbs/datafile/undotbs1.262.891104243datafile 4 switched to datafile copyinput datafile copy RECID=11 STAMP=891104436 file name=+DATA/mecbs/datafile/users.263.891104267datafile 5 switched to datafile copyinput datafile copy RECID=12 STAMP=891104436 file name=+DATA/mecbs/datafile/example.261.891104187datafile 6 switched to datafile copyinput datafile copy RECID=13 STAMP=891104436 file name=+DATA/mecbs/datafile/llc.258.891103925contents of Memory Script:{   set until scn  1889761;   recover   standby   clone database    delete archivelog   ;}executing Memory Scriptexecuting command: SET until clauseStarting recover at 22-SEP-15using channel ORA_AUX_DISK_1using channel ORA_AUX_DISK_2starting media recoveryarchived log for thread 1 with sequence 27 is already on disk as file +DATA/mecbs/archivelog/2015_09_22/thread_1_seq_27.264.891104435archived log file name=+DATA/mecbs/archivelog/2015_09_22/thread_1_seq_27.264.891104435 thread=1 sequence=27media recovery complete, elapsed time: 00:00:00Finished recover at 22-SEP-15Finished Duplicate Db at 22-SEP-15
SQL> select status,instance_name from v$instance;STATUS     INSTANCE_NAME------------ ----------------MOUNTED      MECBSSQL> alter database open;Database altered.SQL> select open_mode,name from v$database;OPEN_MODE     NAME-------------------- ---------READ ONLY     PHUB

开启日志同步:

SQL> alter database recover managed standby database disconnect from session;Database altered.alter database recover managed standby database using current logfile disconnect from session 是实时应用。

把数据库注册:

[oracle@dg oracle]$ srvctl status listener -l listenerListener LISTENER is enabledListener LISTENER is running on node(s): dg[oracle@dg oracle]$ srvctl add database -d MECBS -o /u01/app/oracle/product/11.2.0/db_1/[oracle@dg oracle]$ srvctl status database -d MECBSDatabase is not running.[oracle@dg oracle]$ srvctl start database -d MECBS[oracle@dg oracle]$ srvctl status database -d MECBSDatabase is running.[oracle@dg oracle]$ su - gridPassword: [grid@dg ~]$ crsctl stat res -t--------------------------------------------------------------------------------NAME           TARGET  STATE        SERVER                   STATE_DETAILS       --------------------------------------------------------------------------------Local Resources--------------------------------------------------------------------------------ora.DATA.dg               ONLINE  ONLINE       dg                                           ora.LISTENER.lsnr               ONLINE  ONLINE       dg                                           ora.asm               ONLINE  ONLINE       dg                       Started             ora.ons               OFFLINE OFFLINE      dg                                           --------------------------------------------------------------------------------Cluster Resources--------------------------------------------------------------------------------ora.cssd      1        ONLINE  ONLINE       dg                                           ora.diskmon      1        OFFLINE OFFLINE                                                   ora.evmd      1        ONLINE  ONLINE       dg                                           ora.mecbs.db      1        ONLINE  ONLINE       dg                       Open                                  总结:忘记LOG_ARCHIVE_CONFIG 报以下错:      PING[ARC2]: Heartbeat failed to connect to standby 'MECBS'. Error is 1034.Tue Sep 22 19:41:39 2015Using STANDBY_ARCHIVE_DEST parameter default value as +DATAALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=MEMORY SID='*';Tue Sep 22 19:41:41 2015******************************************************************LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2******************************************************************LGWR: Standby redo logfile selected for thread 1 sequence 40 for destination LOG_ARCHIVE_DEST_2Thread 1 advanced to log sequence 40 (LGWR switch)  Current log# 1 seq# 40 mem# 0: +DATA/phub/onlinelog/group_1.262.890480943  Current log# 1 seq# 40 mem# 1: +DATA/phub/onlinelog/group_1.263.890480945
0