天天看点

两个Oracle 11g 单实例+ASM搭建DG环境

两个Oracle 11g 单实例+ASM搭建DG环境

本文主要介绍如何搭建两个单实例+ASM存储环境之间的DG,通过rman duplicate来搭建。实际上和RAC+RAC的DG搭建没有本质区别,如果两个节点的RAC,那么需要通知配置两个节点的配置,如:监听、TNS,参数等。

环境介绍

由于是资源限制,采用的两个单节点的RAC环境(实际上就是单实例+ASM),具体信息如下:

主机IP 角色 版本 SID DB UNIQUE NAME TNS NAME
192.168.20.100 11.2.0.4 lei lei_p lei_primary
192.168.20.101 11.2.0.4 lei lei_s lei_standby

搭建环境

搭建单实例+ASM和单实例没有区别,只是通过GI来管理而已。

安装过程略。。。

安装GI时注意,选择standalone,如:

[外链图片转存失败(img-B98OLB1u-1564017095783)(./pictures/1.jpg)]

安装DB和GRID所需的rpm包

##安装常用软件:
yum -y install autoconf automake binutils-devel bison cpp dos2unix ftp gcc gcc-c++ lrzsz python-devel

##安装Oracle必需软件:
yum -y install      

主库修改配置

主要修改主库的相关参数,如:force_logging,归档模式,归档路径等相关参数。

启用归档,启用force_logging

启用归档需要在mount模式下修改,而启用force_logging在线修改即可。

注:只需要在一个节点操作即可。

查看当前归档模式和FORCE_LOGGING状态:

SQL>  select name,log_mode,force_logging from gv$database;

NAME                        LOG_MODE                             FORCE_LOG
--------------------------- ------------------------------------ ---------
LEI                         NOARCHIVELOG                         NO      

启用归档:

SQL> shutdown immediate
SQL> startup mount;
SQL> alter database archivelog;      

启用force_logging:

SQL> alter database force logging;      

检查修改结果:

SQL> select name,log_mode,force_logging from gv$database;

NAME                        LOG_MODE                             FORCE_LOG
--------------------------- ------------------------------------ ---------      

创建standby redo

通常情况下创建和当前redo log一样大小的日志并且组数要多一组。

如下,默认是三组50m大小的redo

SQL> select thread#,group#,bytes/1024/1024 from v$log;

   THREAD#     GROUP# BYTES/1024/1024
---------- ---------- ---------------
         1          1              50
         1          2              50
         1          3              50
         2          4              50
         2          5              50
         2          6              50      

查看当前redo存储位置

SQL> col member for a50
SQL> select group#,member from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         3 +DATA/lei/onlinelog/group_3.266.1319463779
         3 +DATA/lei/onlinelog/group_3.267.1319463779
         2 +DATA/lei/onlinelog/group_2.264.1319463779
         2 +DATA/lei/onlinelog/group_2.265.1319463779
         1 +DATA/lei/onlinelog/group_1.262.1319463777
         1 +DATA/lei/onlinelog/group_1.263.1319463777      

所以要创建每个线程四组standby redo,创建单独的目录用于存储standby redo:​

​+DATA/lei/standbylog/​

ASMCMD> cd data/lei
ASMCMD> mkdir standbylog
ASMCMD> cd standbylog
ASMCMD> pwd
+data/lei/standbylog      

创建standby redo

alter database add standby logfile thread 1 group 7 '+DATA/lei/standbylog/std_redo07.log' size 50m;
alter database add standby logfile thread 1 group 8 '+DATA/lei/standbylog/std_redo08.log' size 50m;
alter database add standby logfile thread 1 group 9 '+DATA/lei/standbylog/std_redo09.log' size 50m;
alter database add standby logfile thread 1 group 10 '+DATA/lei/standbylog/std_redo10.log' size 50m;

#如果是RAC环境,则还需要执行以下SQL
alter database add standby logfile thread 2 group 11 '+DATA/lei/standbylog/std_redo11.log' size 50m;
alter database add standby logfile thread 2 group 12 '+DATA/lei/standbylog/std_redo12.log' size 50m;
alter database add standby logfile thread 2 group 13 '+DATA/lei/standbylog/std_redo13.log' size 50m;
alter database add standby logfile thread 2 group 14 '+DATA/lei/standbylog/std_redo14.log' size 50m;      

确认standby redo信息

select group#,sequence#,status, bytes/1024/1024 from v$standby_log;

select group#,member from v$logfile;      

修改配置

以下配置,除了只有​

​db_file_name_convert​

​​和​

​log_file_name_convert​

​需要重启数据库之外,其他参数均不需要重启。

需要修改的参数如下:

alter system set fal_server='lei_s' sid='*' scope=both;
alter system set fal_client='lei'  sid='*' scope=both;
alter system set db_file_name_convert='+DATA/lei_s/','+DATA/lei/' sid='*' scope=spfile;
alter system set log_file_name_convert='+DATA/lei_s/','+DATA/lei/' sid='*' scope=spfile;
alter system set standby_file_management='auto'  sid='*' scope=both;
alter system set log_archive_config='dg_config=(lei,lei_s)' sid='*' scope=both;
alter system set log_archive_dest_1='location=+DATA/lei/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lei' sid='*' scope=both;
alter system set log_archive_dest_2='service=lei_standby valid_for=(online_logfiles,primary_role) db_unique_name=lei_s' sid='*' scope=both; #service为TNS NAME
alter system set log_archive_dest_state_1=enable sid='*' scope=both;
alter system set log_archive_dest_state_2=enable sid='*' scope=both;      

重启数据库使参数生效。

srvctl stop database -d lei
srvctl start database -d lei      

配置静态监听和TNS

注意:listener.ora文件是GIRD_ORACLE下的,而tnsname.ora文件是在ORACLE_HOME下的。

可通过netmgr工具配置,也可以手动修改listener.ora文件。但是效果都是一样,最终的文件内容如下:

# listener.ora Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac-p)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

# 新增的
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = lei)
    (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)    # DB的ORACLE_HOME
    (SID_NAME = lei1)   --第二节点改为lei2
  )
)      

重启监听

rac-p-> srvctl stop listener -l LISTENER
rac-p-> srvctl start listener -l LISTENER

rac-p-> lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 20-JAN-2029 16:43:14

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                20-JAN-2029 13:23:31
Uptime                    0 days 3 hr. 19 min. 44 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/rac-p/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac-p)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "lei" has 2 instance(s).
  Instance "lei", status UNKNOWN, has 1 handler(s) for this service...
  Instance "lei", status READY, has 1 handler(s) for this service...
Service "leiXDB" has 1 instance(s).
  Instance "lei", status READY, has 1 handler(s) for this service...
The command      

UNKNOWN表示启用了静态监听。

配置TNS

主备库的TNS文件内容完全相同,配置一个复制即可。

内容如下:

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LEI_PRIMARY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.100)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lei)
    )
  )

LEI_STANDBY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.101)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lei_s)
    )
  )      

拷贝密码文件到备库

随便将一个节点的密码文件拷贝到备库即可。

scp orapwlei1 192.168.20.101:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwlei1
scp      

至此主库的相关配置就完成了!

备库修改配置

备库主要修改监听、参数文件、TNS文件。

配置静态监听

内容和主库没有什么区别。如下:

# listener.ora Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac-s)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

# 新增的
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = lei_s)
    (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)  # DB的ORACLE_HOME
    (SID_NAME = lei1)   --第二节点改为lei2
  )
)      

重启监听。

配置TNS文件

将主库的TNS文件拷贝过来即可

修改pfile文件

从主库创建一个pfile文件

SQL> create pfile='/tmp/lei.ora' from spfile;

File created.      

然后修改以下参数即可,仅列出需要修改的参数

*.audit_file_dest='/u01/app/oracle/admin/lei_s/adump'
*.control_files='+DATA/lei_s/controlfile/control01.ctl','+DATA/lei_s/controlfile/control02.ctl'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lei_sXDB)'
*.db_file_name_convert='+DATA/lei_s/','+DATA/lei/'
*.fal_client='lei_s'
*.fal_server='lei'
*.db_unique_name='lei_s'
*.log_archive_config='dg_config=(racdb,lei_s)'
*.log_archive_dest_1='location=+DATA/lei_s/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lei_s'
*.log_archive_dest_2='service=lei_primary valid_for=(online_logfiles,primary_role) db_unique_name=lei'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_file_name_convert='+DATA/lei/','+DATA/lei_s/'
*.db_file_name_convert='+DATA/lei/datafile/','+DATA/lei_s/datafile/'      

创建目录:

实际上所有pfile文件中出现的目录都需要创建

mkdir -p /u01/app/oracle/admin/lei/adump


rac-s-> asmcmd
ASMCMD> ls
DATA/
ASMCMD> cd data
ASMCMD> ls
ASM/
ASMCMD> mkdir lei_s
ASMCMD> cd lei_s
ASMCMD> mkdir standbylog
ASMCMD> mkdir controlfile
ASMCMD> mkdir spfile
ASMCMD> mkdir      

利用pfile启动到nomount状态

SQL> startup nomount pfile='/tmp/lei_s.ora';      
注意:不要提前创建磁盘组中的SPFILE并启动数据库到nomount状态,这样可能会造成后面DUPLICATE报错(ORA-17628)。

RMAN DUPLICATE

如果数据库比较大并且业务不忙或者凌晨时,可以指定多个通道并行处理,如下:

run {
allocate channel channel1 type disk;
allocate channel channel2 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database for standby from active database
spfile
set audit_file_dest='/u01/app/oracle/admin/lei_s/adump'
set control_files='+DATA/lei_s/controlfile/control01.ctl','+DATA/lei_s/controlfile/control02.ctl'
set dispatchers='(PROTOCOL=TCP) (SERVICE=lei_sXDB)'
set db_file_name_convert='+DATA/lei/datafile/','+DATA/lei_s/datafile/'
set fal_client='lei_s'
set fal_server='lei'
set db_unique_name='lei_s'
set log_archive_config='dg_config=(lei,lei_s)'
set log_archive_dest_1='location=+DATA/lei_s/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lei_s'
set log_archive_dest_2='service=lei_primary valid_for=(online_logfiles,primary_role) db_unique_name=lei'
set log_archive_dest_state_1='ENABLE'
set log_archive_dest_state_2='ENABLE'
set log_file_name_convert='+DATA/lei/','+DATA/lei_s/'
nofilenamecheck;
release channel channel1;
release channel channel2;
release channel stby1;
}      

输出信息如下:

rac-s-> rman target sys/oracle@lei_primary auxiliary sys/oracle@lei_standby

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jan 21 12:53:43 2029

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: LEI (DBID=2502834590)
connected to auxiliary database: LEI (not mounted)

RMAN>

RMAN> run {
allocate channel channel1 type disk;
allocate channel channel2 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database for standby from active database
spfile
set audit_file_dest='/u01/app/oracle/admin/lei_s/adump'
set control_files='+DATA/lei_s/controlfile/control01.ctl','+DATA/lei_s/controlfile/control02.ctl'
set dispatchers='(PROTOCOL=TCP) (SERVICE=lei_sXDB)'
set db_file_name_convert='+DATA/lei/datafile/','+DATA/lei_s/datafile/'
set fal_client='lei_s'
set fal_server='lei'
set db_unique_name='lei_s'
set log_archive_config='dg_config=(lei,lei_s)'
set log_archive_dest_1='location=+DATA/lei_s/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lei_s'
set log_archive_dest_2='service=lei valid_for=(online_logfiles,primary_role) db_unique_name=lei'
set log_archive_dest_state_1='ENABLE'
set log_archive_dest_state_2='ENABLE'
set log_file_name_convert='+DATA/lei/','+DATA/lei_s/'
nofilenamecheck;
release channel channel1;
release channel channel2;
release channel stby1;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24>

using target database control file instead of recovery catalog
allocated channel: channel1
channel channel1: SID=53 device type=DISK

allocated channel: channel2
channel channel2: SID=46 device type=DISK

allocated channel: stby1
channel stby1: SID=25 device type=DISK

Starting Duplicate Db at 2029/01/21 12:53:56

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwlei' auxiliary format
 '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwlei'   targetfile
 '+DATA/lei/spfilelei.ora' auxiliary format
 '/u01/app/oracle/product/11.2.0/db_1/dbs/spfilelei.ora'   ;
   sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfilelei.ora''";
}
executing Memory Script

Starting backup at 2029/01/21 12:53:56
Finished backup at 2029/01/21 12:53:58

sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfilelei.ora''

contents of Memory Script:
{
   sql clone "alter system set  audit_file_dest =
 ''/u01/app/oracle/admin/lei_s/adump'' comment=
 '''' scope=spfile";
   sql clone "alter system set  control_files =
 ''+DATA/lei_s/controlfile/control01.ctl'', ''+DATA/lei_s/controlfile/control02.ctl'' comment=
 '''' scope=spfile";
   sql clone "alter system set  dispatchers =
 ''(PROTOCOL=TCP) (SERVICE=lei_sXDB)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_file_name_convert =
 ''+DATA/lei/datafile/'', ''+DATA/lei_s/datafile/'' comment=
 '''' scope=spfile";
   sql clone "alter system set  fal_client =
 ''lei_s'' comment=
 '''' scope=spfile";
   sql clone "alter system set  fal_server =
 ''lei'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''lei_s'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_config =
 ''dg_config=(lei,lei_s)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_1 =
 ''location=+DATA/lei_s/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lei_s'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_2 =
 ''service=lei valid_for=(online_logfiles,primary_role) db_unique_name=lei'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_state_1 =
 ''ENABLE'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_state_2 =
 ''ENABLE'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_file_name_convert =
 ''+DATA/lei/'', ''+DATA/lei_s/'' comment=
 '''' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  audit_file_dest =  ''/u01/app/oracle/admin/lei_s/adump'' comment= '''' scope=spfile

sql statement: alter system set  control_files =  ''+DATA/lei_s/controlfile/control01.ctl'', ''+DATA/lei_s/controlfile/control02.ctl'' comment= '''' scope=spfile

sql statement: alter system set  dispatchers =  ''(PROTOCOL=TCP) (SERVICE=lei_sXDB)'' comment= '''' scope=spfile

sql statement: alter system set  db_file_name_convert =  ''+DATA/lei/datafile/'', ''+DATA/lei_s/datafile/'' comment= '''' scope=spfile

sql statement: alter system set  fal_client =  ''lei_s'' comment= '''' scope=spfile

sql statement: alter system set  fal_server =  ''lei'' comment= '''' scope=spfile

sql statement: alter system set  db_unique_name =  ''lei_s'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_config =  ''dg_config=(lei,lei_s)'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_dest_1 =  ''location=+DATA/lei_s/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lei_s'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_dest_2 =  ''service=lei valid_for=(online_logfiles,primary_role) db_unique_name=lei'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_dest_state_1 =  ''ENABLE'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_dest_state_2 =  ''ENABLE'' comment= '''' scope=spfile

sql statement: alter system set  log_file_name_convert =  ''+DATA/lei/'', ''+DATA/lei_s/'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1286066176 bytes

Fixed Size                     2252904 bytes
Variable Size                402657176 bytes
Database Buffers             872415232 bytes
Redo Buffers                   8740864 bytes
allocated channel: stby1
channel stby1: SID=23 device type=DISK

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '+DATA/lei_s/controlfile/control01.ctl';
   restore clone controlfile to  '+DATA/lei_s/controlfile/control02.ctl' from
 '+DATA/lei_s/controlfile/control01.ctl';
}
executing Memory Script

Starting backup at 2029/01/21 12:54:04
channel channel1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_lei.f tag=TAG20290121T125404 RECID=4 STAMP=1319547244
channel channel1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 2029/01/21 12:54:08

Starting restore at 2029/01/21 12:54:08

channel stby1: copied control file copy
Finished restore at 2029/01/21 12:54:09

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database
RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.

contents of Memory Script:
{
   set newname for tempfile  1 to
 "+data";
   switch clone tempfile all;
   set newname for datafile  1 to
 "+data";
   set newname for datafile  2 to
 "+data";
   set newname for datafile  3 to
 "+data";
   set newname for datafile  4 to
 "+data";
   backup as copy reuse
   datafile  1 auxiliary format
 "+data"   datafile
 2 auxiliary format
 "+data"   datafile
 3 auxiliary format
 "+data"   datafile
 4 auxiliary format
 "+data"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to +data in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 2029/01/21 12:54:15
channel channel1: starting datafile copy
input datafile file number=00001 name=+DATA/lei/datafile/system.256.1319463695
channel channel2: starting datafile copy
input datafile file number=00002 name=+DATA/lei/datafile/sysaux.257.1319463695
output file name=+DATA/lei_s/datafile/sysaux.260.1319547255 tag=TAG20290121T125414
channel channel2: datafile copy complete, elapsed time: 00:00:15
channel channel2: starting datafile copy
input datafile file number=00003 name=+DATA/lei/datafile/undotbs1.258.1319463695
output file name=+DATA/lei_s/datafile/system.259.1319547255 tag=TAG20290121T125414
channel channel1: datafile copy complete, elapsed time: 00:00:15
channel channel1: starting datafile copy
input datafile file number=00004 name=+DATA/lei/datafile/users.259.1319463695
output file name=+DATA/lei_s/datafile/users.262.1319547271 tag=TAG20290121T125414
channel channel1: datafile copy complete, elapsed time: 00:00:01
output file name=+DATA/lei_s/datafile/undotbs1.261.1319547271 tag=TAG20290121T125414
channel channel2: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2029/01/21 12:54:32

sql statement: alter system archive log current

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=1319547272 file name=+DATA/lei_s/datafile/system.259.1319547255
datafile 2 switched to datafile copy
input datafile copy RECID=5 STAMP=1319547272 file name=+DATA/lei_s/datafile/sysaux.260.1319547255
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=1319547272 file name=+DATA/lei_s/datafile/undotbs1.261.1319547271
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=1319547272 file name=+DATA/lei_s/datafile/users.262.1319547271
Finished Duplicate Db at 2029/01/21 12:54:36

released channel: channel1

released channel: channel2

released channel: stby1      

创建SPFILE

生成新的pfile文件

SQL> create pfile='/tmp/lei_s.ora' from spfile;

File created.      

文件内容如下:

SQL> !more '/tmp/lei_s.ora'
lei.__db_cache_size=872415232
lei.__java_pool_size=16777216
lei.__large_pool_size=83886080
lei.__oracle_base='/u01/app/grid'#ORACLE_BASE set from environment
lei.__pga_aggregate_target=436207616
lei.__sga_target=1291845632
lei.__shared_io_pool_size=0
lei.__shared_pool_size=301989888
lei.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/lei_s/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='+DATA/lei_s/controlfile/control01.ctl','+DATA/lei_s/controlfile/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_name_convert='+DATA/lei/datafile/','+DATA/lei_s/datafile/'
*.db_name='lei'
*.db_recovery_file_dest='+DATA'
*.db_recovery_file_dest_size=4385144832
*.db_unique_name='lei_s'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lei_sXDB)'
*.fal_client='lei_s'
*.fal_server='lei'
*.log_archive_config='dg_config=(lei,lei_s)'
*.log_archive_dest_1='location=+DATA/lei_s/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=lei_s'
*.log_archive_dest_2='service=lei_primary valid_for=(online_logfiles,primary_role) db_unique_name=lei'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_file_name_convert='+DATA/lei/','+DATA/lei_s/'
*.open_cursors=300
*.pga_aggregate_target=425721856
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1277165568
*.standby_file_management='auto'
*.undo_tablespace='UNDOTBS1'      

通过新的pfile文件,创建新的SPFILE文件

SQL> create spfile='+DATA/lei_s/parameterfile/spfilelei_s.ora' from pfile='/tmp/lei_s.ora';

File created.      

编辑本地pfile文件指定到磁盘组中SPFILE

rac-s-> cat initlei.ora
SPFILE='+DATA/lei_s/parameterfile/spfilelei_s.ora'      

删除本地的SPFILE

[root@rac-s dbs]# rm /u01/app/oracle/product/11.2.0/db_1/dbs/spfilelei.ora
rm: remove regular file `spfilelei.ora'? yes      

使用SPFILE启动数据库

SQL>      

验证

启动MRP

SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL> selEct process,status from v$managed_standby;
PROCESS                     STATUS
--------------------------- ------------------------------------      

主库:

SQL> create tablespace lei datafile '+DATA' SIZE 10M;

Tablespace created.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/lei/datafile/system.256.1319463695
+DATA/lei/datafile/sysaux.257.1319463695
+DATA/lei/datafile/undotbs1.258.1319463695
+DATA/lei/datafile/users.259.1319463695
+DATA/lei/datafile/lei.283.1319559783

SQL> alter system switch logfile;

System altered.      

备库:

SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/lei_s/datafile/system.259.1319547255
+DATA/lei_s/datafile/sysaux.260.1319547255
+DATA/lei_s/datafile/undotbs1.261.1319547271
+DATA/lei_s/datafile/users.262.1319547271
+DATA/lei_s/datafile/lei.276.1319559823      

日志同步情况

主库:

SQL> select sequence,applied from (select sequence# sequence,applied from v$archived_log order by sequence# desc) where rownum <=10;

  SEQUENCE APPLIED
---------- ---------------------------
        15 NO
        15 YES
        14 NO
        14 YES
        13 NO
        13 YES
        12 NO
        11 NO
        10 NO
         9 NO

10 rows selected.      
SQL> select sequence,applied from (select sequence# sequence,applied from v$archived_log order by sequence# desc) where rownum <=10;

  SEQUENCE APPLIED
---------- ---------------------------
        15 YES
        14 YES
        13