溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

RMAN配置DataGuard from Active database with ASM

發(fā)布時(shí)間:2020-06-18 10:48:06 來源:網(wǎng)絡(luò) 閱讀:605 作者:jason_125 欄目:數(shù)據(jù)庫

一、  環(huán)境

主庫:安裝grid軟件及創(chuàng)建磁盤組;安裝數(shù)據(jù)庫軟件并創(chuàng)建數(shù)據(jù)庫,

備庫:僅安裝grid軟件并創(chuàng)建asm磁盤組,同時(shí)安裝數(shù)據(jù)庫軟件即可。

 

主機(jī)名

數(shù)據(jù)庫版本

dbname

db_unique_name

ip地址

系統(tǒng)版本

server1(主)

 

oracle11204

 

Jason

 

jason

192.168.1.250

 

rhel6.6_x86_64

server2(備)

jason2

192.168.1.252

二、  主庫配置

1.  確定主數(shù)據(jù)庫開啟強(qiáng)制LOGGING模式

[oracle@server1 ~]$ sqlplus /nolog

 

SQL*Plus: Release 11.2.0.4.0 Production on Thu Jul 14 20:45:33 2016

 

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

 

SQL> conn /as sysdba

Connected.

 

SQL> ALTER DATABASE FORCE LOGGING;

 

Database altered.

 

SQL> select force_logging from v$database;

 

FOR

---

YES

2.  開啟歸檔

SQL> archive log list;

Database log mode             Archive Mode

Automatic archival            Enabled

Archive destination            +DATA

Oldest online log sequence     24

Next log sequence to archive   26

Current log sequence           26

3.  創(chuàng)建standby日志組

1).standby redo log的文件大小與primary 數(shù)據(jù)庫online redo log 文件大小相同

2).standby redo log日志文件組的個(gè)數(shù)依照下面的原則進(jìn)行計(jì)算

    Standby redo log組數(shù)公式>=(每個(gè)instance日志組個(gè)數(shù)+1)*instance個(gè)數(shù)

    例如在我的環(huán)境中,只有一個(gè)節(jié)點(diǎn),這個(gè)節(jié)點(diǎn)有三組redo,所以

    Standby redo log組數(shù)公式>=(3+1)*1  == 4

    所以需要?jiǎng)?chuàng)建4組Standby redo log

3).每一日志組為了安全起見,可以包含多個(gè)成員文件。

查看主數(shù)據(jù)庫的日志組個(gè)數(shù)與大小,創(chuàng)建standy日志組,大小不能小于在線日志大小。

SQL> select member from v$logfile;

MEMBER

------------------------------------------------------------------------

+DATA/jason/onlinelog/group_3.263.919631585

+DATA/jason/onlinelog/group_2.262.919631583

+DATA/jason/onlinelog/group_1.261.919631583

3 rows selected.

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

 

    GROUP# BYTES/1024/1024

---------- ---------------

         1              50

         3              50

         2              50

在主數(shù)據(jù)庫創(chuàng)建standby日志組,位置與原日志組相同的路徑。

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 50M;

 

Database altered.

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 SIZE 50M;

 

Database altered.

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 SIZE 50M;

 

Database altered.

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 SIZE 50M;

 

Database altered.

 

SQL> select group#,status,type,member from v$logfile;

 

    GROUP# STATUS  TYPE   MEMBER

---------- ------- ------- --------------------------

         3         ONLINE +DATA/jason/onlinelog/group_3.263.919631585

         2         ONLINE +DATA/jason/onlinelog/group_2.262.919631583

         1         ONLINE +DATA/jason/onlinelog/group_1.261.919631583

         4         STANDBY+DATA/jason/onlinelog/group_4.269.919707467

         5         STANDBY+DATA/jason/onlinelog/group_5.270.919707475

         6         STANDBY +DATA/jason/onlinelog/group_6.271.919707483

         7         STANDBY+DATA/jason/onlinelog/group_7.272.919707491

 

7 rows selected.

SQL>

4.  主庫參數(shù)文件配置

在主庫上修改dataguard配置相關(guān)的各個(gè)參數(shù),各參數(shù)的具體含義可以參考o(jì)racle在線文檔。

alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(JASON,JASON2)' SCOPE=SPFILE;

alter system set STANDBY_FILE_MANAGEMENT='AUTO' SCOPE=SPFILE;

alter system set LOG_ARCHIVE_DEST_1='LOCATION=+DATAVALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=JASON' scope=spfile;

alter system set LOG_ARCHIVE_DEST_2='SERVICE=JASON2 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)DB_UNIQUE_NAME=JASON2'scope=spfile;

alter system set LOG_ARCHIVE_DEST_STATE_1='ENABLE' scope=spfile;

alter system set LOG_ARCHIVE_DEST_STATE_2='ENABLE' scope=spfile;

alter system set FAL_SERVER='JASON2' scope=spfile;

主庫的DB_UNIQUE_NAME不設(shè)置,默認(rèn)與數(shù)據(jù)庫名一致。

SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(JASON,JASON2)'SCOPE=SPFILE;

 

System altered.

 

SQL> alter system set STANDBY_FILE_MANAGEMENT='AUTO' SCOPE=SPFILE;

 

System altered.

 

SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=+DATAVALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=JASON' scope=spfile;

 

System altered.

 

SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=JASON2 ASYNCVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=JASON2'scope=spfile;

 

System altered.

 

SQL> alter system set LOG_ARCHIVE_DEST_STATE_1='ENABLE' scope=spfile;

 

System altered.

 

SQL> alter system set LOG_ARCHIVE_DEST_STATE_2='ENABLE' scope=spfile;

 

System altered.

 

SQL> alter system set FAL_SERVER='JASON2' scope=spfile;

 

System altered.

 

SQL>

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area 409194496 bytes

Fixed Size                 2253744 bytes

Variable Size             310381648bytes

Database Buffers          92274688 bytes

Redo Buffers               4284416 bytes

Database mounted.

Database opened.

5.  配置監(jiān)聽及tnsname

grid用戶創(chuàng)建監(jiān)聽,如下:

[grid@server1 ~]$ cd /u01/app/11.2.0/grid/network/admin/

[grid@server1 admin]$ cat 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 = server1)(PORT = 1521))

    )

  )

 

ADR_BASE_LISTENER = /u01/app/grid

 

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

oracle用戶下tnsname.ora配置如下

[oracle@server1 ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/

[oracle@server1 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File:/u01/app/11.2.0/grid/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

JASON =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL =TCP)(HOST = 192.168.1.250)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = JASON)

    )

  )

 

JASON2 =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL =TCP)(HOST = 192.168.1.252)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = JASON2)

    )

  )

 

[oracle@server1 admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 12-AUG-201622:43:25

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNRfor Linux: Version 11.2.0.4.0 - Production

Start Date               12-AUG-2016 17:56:24

Uptime                    0 days 4 hr. 47 min. 0 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/server1/listener/alert/log.xml

Listening Endpoints Summary...

 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=server1)(PORT=1521)))

Services Summary...

Service "+ASM" has 1 instance(s).

  Instance "+ASM",status READY, has 1 handler(s) for this service...

Service "JASON" has 1 instance(s).

  Instance "JASON",status READY, has 1 handler(s) for this service...

Service "JASONXDB" has 1 instance(s).

  Instance "JASON",status READY, has 1 handler(s) for this service...

The command completed successfully

[oracle@server1 admin]$

6.  生成pfile文件,同步相應(yīng)文件至備庫

在主數(shù)據(jù)庫生成pfile文件。

SQL> create pfile=’/home/oracle/pfile.ora’ from spfile;

File created.

同步密碼認(rèn)證文件至備機(jī)。

[oracle@jason1 dbs]$ pwd

/u01/app/oracle/product/11.2.0/dbhome_1/dbs

[oracle@jason1 dbs]$ scp initJASON.ora orapwJASON 192.168.1.252:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/

The authenticity of host '192.168.1.100 (192.168.1.100)' can't beestablished.

RSA key fingerprint is 25:ca:65:90:d3:30:fa:68:ed:11:64:b2:0e:b0:39:a7.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.1.100' (RSA) to the list of knownhosts.

oracle@192.168.1.252's password:   

initJASON.ora                                                                                       100%1415     1.4KB/s   00:00  

orapwJASON                                                                                          100% 1536     1.5KB/s   00:00      

[oracle@jason1 dbs]

三、  備庫配置

7.  創(chuàng)建對應(yīng)目錄

備庫上創(chuàng)建相關(guān)目錄

[oracle@server2 oracle]$ mkdir -p /u01/app/oracle/admin/JASON2/adump

8.  備庫參數(shù)文件配置

備庫上修改初始參數(shù)文件,配置DG所需參數(shù)如下。

JASON.__db_cache_size=104857600

JASON.__java_pool_size=4194304

JASON.__large_pool_size=8388608

JASON.__pga_aggregate_target=180355072

JASON.__sga_target=230686720

JASON.__shared_io_pool_size=0

JASON.__shared_pool_size=104857600

JASON.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/JASON2/adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_files='+DATA'

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain=''

*.db_name='JASON'

*.DB_UNIQUE_NAME='JASON2'

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=JASONXDB)'

*.fal_server='JASON'

*.log_archive_config='DG_CONFIG=(JASON,JASON2)'

*.log_archive_dest_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=JASON2'

*.log_archive_dest_2='SERVICE=JASON ASYNCVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=JASON'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=411041792

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.standby_file_management='AUTO'

*.undo_tablespace='UNDOTBS1'

9.配置監(jiān)聽                                                                                

grid用戶創(chuàng)建監(jiān)聽,備庫監(jiān)聽必須配置為靜態(tài)監(jiān)聽。如下:

[grid@server2 admin]$ cat listener.ora

# listener.ora Network Configuration File:/u01/app/11.2.0/grid/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = JASON2)

      (ORACLE_HOME =/u01/app/oracle/product/11.2.0/dbhome_1)

      (SID_NAME = JASON)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL =IPC)(KEY = EXTPROC1521))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL =TCP)(HOST = server2)(PORT = 1521))

    )

  )

 

ADR_BASE_LISTENER = /u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

oracle用戶下tnsname.ora配置如下

[oracle@server1 ~]$ cd/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/

[oracle@server1 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File:/u01/app/11.2.0/grid/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

JASON =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL =TCP)(HOST = 192.168.1.250)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = JASON)

    )

  )

 

JASON2 =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL =TCP)(HOST = 192.168.1.252)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = JASON2)

    )

  )

10.創(chuàng)建備庫

將備庫啟動(dòng)到nomount狀態(tài),然后在備機(jī)連接主庫進(jìn)行duplicate操作。

[oracle@server2 dbs]$ rman target sys/system@JASON auxiliarysys/system@JASON2

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Aug 12 18:35:212016

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

connected to target database: JASON (DBID=2143845850)

connected to auxiliary database: JASON (not mounted)

RMAN> duplicate target database for standby nofilenamecheck fromactive database;

Starting Duplicate Db at 12-AUG-16

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=23 device type=DISK

 

contents of Memory Script:

{

   backup as copy reuse

   targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwJASON' auxiliaryformat

 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwJASON'   ;

}

executing Memory Script

 

Starting backup at 12-AUG-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=45 device type=DISK

Finished backup at 12-AUG-16

 

contents of Memory Script:

{

   backup as copy currentcontrolfile for standby auxiliary format '+DATA/jason2/controlfile/current.256.919708533';

   sql clone "create spfilefrom memory";

   shutdown clone immediate;

   startup clone nomount;

   sql clone "alter systemset  control_files =

 ''+DATA/jason2/controlfile/current.256.919708533'' comment=

 ''Set by RMAN''scope=spfile";

   shutdown clone immediate;

   startup clone nomount;

}

executing Memory Script

 

Starting backup at 12-AUG-16

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

copying standby control file

output filename=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_JASON.ftag=TAG20160812T183533 RECID=1 STAMP=919708533

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

Finished backup at 12-AUG-16

 

sql statement: create spfile from memory

 

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area    409194496 bytes

 

Fixed Size                    2253744 bytes

Variable Size               318770256 bytes

Database Buffers              83886080 bytes

Redo Buffers                  4284416 bytes

 

sql statement: alter system set control_files =  ''+DATA/jason2/controlfile/current.256.919708533'' comment= ''Set byRMAN'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)

Oracle instance started

Total System Global Area    409194496 bytes

Fixed Size                    2253744 bytes

Variable Size               318770256 bytes

Database Buffers             83886080 bytes

Redo Buffers                   4284416 bytes

 

contents of Memory Script:

{

   sql clone 'alter database mountstandby database';

}

executing Memory Script

 

sql statement: alter database mount standby database

 

contents of Memory Script:

{

   set newname for clonetempfile  1 to new;

   switch clone tempfile all;

   set newname for clonedatafile  1 to new;

   set newname for clonedatafile  2 to new;

   set newname for clonedatafile  3 to new;

   set newname for clonedatafile  4 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

   ;

   sql 'alter system archive logcurrent';

}

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 12-AUG-16

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

input datafile file number=00001name=+DATA/jason/datafile/system.256.919631481

output file name=+DATA/jason2/datafile/system.257.919708567tag=TAG20160812T183605

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35

channel ORA_DISK_1: starting datafile copy

input datafile file number=00002name=+DATA/jason/datafile/sysaux.257.919631481

output file name=+DATA/jason2/datafile/sysaux.258.919708603tag=TAG20160812T183605

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00003name=+DATA/jason/datafile/undotbs1.258.919631481

output file name=+DATA/jason2/datafile/undotbs1.259.919708627tag=TAG20160812T183605

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting datafile copy

input datafile file number=00004name=+DATA/jason/datafile/users.259.919631483

output file name=+DATA/jason2/datafile/users.260.919708631tag=TAG20160812T183605

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 12-AUG-16

 

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=1 STAMP=919708632 filename=+DATA/jason2/datafile/system.257.919708567

datafile 2 switched to datafile copy

input datafile copy RECID=2 STAMP=919708632 filename=+DATA/jason2/datafile/sysaux.258.919708603

datafile 3 switched to datafile copy

input datafile copy RECID=3 STAMP=919708633 filename=+DATA/jason2/datafile/undotbs1.259.919708627

datafile 4 switched to datafile copy

input datafile copy RECID=4 STAMP=919708633 filename=+DATA/jason2/datafile/users.260.919708631

Finished Duplicate Db at 12-AUG-16

RMAN>

備注:創(chuàng)建備庫后,數(shù)據(jù)庫處于mount狀態(tài),數(shù)據(jù)打開時(shí)將會初始化臨時(shí)表空間、在線日志、standby日志。

11.開啟ADG

將備庫置于active dataguard模式下,備庫創(chuàng)建成功后默認(rèn)為mount狀態(tài),需要手動(dòng)打開。

[oracle@server2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 12 18:51:54 2016

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bitProduction

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 

SQL> alter database open;

 

Database altered.

 

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

 

Database altered.

 

SQL> select open_mode,database_role,db_unique_name from v$database;

 

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME

-------------------- ---------------- ------------------------------

READ ONLY WITH APPLY PHYSICAL STANDBY JASON2

 

SQL> select protection_mode,protection_level from v$database;

 

PROTECTION_MODE     PROTECTION_LEVEL

-------------------- --------------------

MAXIMUM PERFORMANCE  MAXIMUMPERFORMANCE

 

SQL>

 

SQL> select status from v$standby_log;

 

STATUS

----------

UNASSIGNED

ACTIVE

UNASSIGNED

UNASSIGNED

 

SQL> select group#,status,type,member from v$logfile;

 

    GROUP# STATUS  TYPE   MEMBER

---------- ------- ------- --------------------------

         3         ONLINE +DATA/jason2/onlinelog/group_3.263.919708637

         2         ONLINE +DATA/jason2/onlinelog/group_2.262.919708637

         1         ONLINE +DATA/jason2/onlinelog/group_1.261.919708633

         4         STANDBY+DATA/jason2/onlinelog/group_4.264.919708637

         5         STANDBY+DATA/jason2/onlinelog/group_5.265.919708639

         6         STANDBY+DATA/jason2/onlinelog/group_6.266.919708639

         7        STANDBY +DATA/jason2/onlinelog/group_7.267.919708641

 

7 rows selected.

 

SQL>

主庫查看數(shù)據(jù)庫狀態(tài)

[oracle@server1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 12 18:34:16 2016

 

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bitProduction

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

SQL> select open_mode,database_role,db_unique_name from v$database;

 

OPEN_MODE           DATABASE_ROLE    DB_UNIQUE_NAME

-------------------- ---------------- ------------------------------

READ WRITE           PRIMARY          JASON

 

SQL> select protection_mode,protection_level from v$database;

 

PROTECTION_MODE     PROTECTION_LEVEL

-------------------- --------------------

MAXIMUM PERFORMANCE  MAXIMUMPERFORMANCE

 

SQL>

12.創(chuàng)建spfile文件

備庫創(chuàng)建結(jié)束后,需要?jiǎng)?chuàng)建spfile文件。

修改pfile文件control_files參數(shù),指定備庫的控制文件,查看asm磁盤組獲取控制文件名及位置。如下:

control_files='+DATA/jason2/controlfile/current.256.919708533',

創(chuàng)建spfile.

SQL> create SPFILE='+DATA/JASON2/spfileJASON.ora'from pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initJASON.ora';

File created.

創(chuàng)建pfile文件指向

[oracle@server2dbs]$ cat initJASON.ora

SPFILE='+DATA/JASON2/spfileJASON.ora'

[oracle@server2dbs]$

spfile文件創(chuàng)建成功后,備庫重啟將使用spfile文件啟動(dòng)數(shù)據(jù)庫

使用ALTERDATABASE RECOVER MANAGED STANDBY DATABASE CANCEL取消日志恢復(fù),關(guān)閉數(shù)據(jù)庫,再次打開,再開啟日志應(yīng)用。

SQL> showparameter spfile

 

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

spfile                               string      +DATA/jason2/spfilejason.ora

SQL>

四、  測試

13.主備庫查看日志

主庫切換日志

SQL> alter system switch logfile;

 

System altered.

 

SQL> /

 

System altered.

 

SQL> /

 

System altered.

 

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOGORDER BY SEQUENCE#;

 

 SEQUENCE# APPLIED

---------- ---------

         5 NO

         6 NO

         7 NO

         8 NO

         9 NO

        10 NO

        10 YES

        11 NO

        11 YES

        12 NO

        12 YES

 

 SEQUENCE# APPLIED

---------- ---------

        13 NO

        13 YES

        14 NO

        14 YES

        15 NO

        15 NO

 

17 rows selected.

SQL>

備庫查看日志

SQL>  SELECTSEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 

 SEQUENCE# APPLIED

---------- ---------

        10 YES

        11 YES

        12 YES

        13 YES

        14 YES

        15IN-MEMORY

 

6 rows selected.

SQL>

14.switch_over測試

主庫切換

SQL> SELECTSWITCHOVER_STATUS FROM V$DATABASE;

 

SWITCHOVER_STATUS

--------------------

TO STANDBY

 

SQL> ALTERDATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

 

Database altered.

 

SQL> startup

ORACLE instancestarted.

 

Total System GlobalArea  409194496 bytes

Fixed Size                  2253744 bytes

Variable Size             322964560 bytes

DatabaseBuffers           79691776 bytes

Redo Buffers                4284416 bytes

Database mounted.

Database opened.

SQL> selectopen_mode,database_role,db_unique_name from v$database;

 

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME

------------------------------------ ------------------------------

READ ONLY            PHYSICAL STANDBY JASON

 

 

SQL> ALTERDATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROMSESSION;

 

Database altered.

 

SQL>                   

 

備庫切換

SQL> SELECTSWITCHOVER_STATUS FROM V$DATABASE;

 

SWITCHOVER_STATUS

--------------------

TO PRIMARY

 

SQL> ALTERDATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

 

Database altered.

 

SQL> selectopen_mode,database_role,db_unique_name from v$database;

 

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME

------------------------------------ ------------------------------

MOUNTED              PRIMARY          JASON2

 

SQL> alterdatabase open;

 

Database altered.

 

SQL> selectopen_mode,database_role,db_unique_name from v$database;

 

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME

------------------------------------ ------------------------------

READ WRITE           PRIMARY          JASON2

 

SQL>

五、  報(bào)錯(cuò)處理

15.報(bào)錯(cuò)1

[oracle@server2 ~]$rman  target sys/system@JASON auxiliarysys/system@jason2

Recovery Manager:Release 11.2.0.4.0 - Production on Wed Aug 10 07:37:33 2016

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

 

connected to target database:JASON (DBID=2143699214)

connected toauxiliary database: JASON (not mounted)

 

RMAN> duplicatetarget database for standby nofilenamecheck from active database;

 

Starting DuplicateDb at 10-AUG-16

using targetdatabase control file instead of recovery catalog

allocated channel:ORA_AUX_DISK_1

channelORA_AUX_DISK_1: SID=22 device type=DISK

 

contents of MemoryScript:

{

   backup as copy reuse

   targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwJASON' auxiliaryformat

 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwJASON'   ;

}

executing MemoryScript

 

Starting backup at10-AUG-16

allocated channel:ORA_DISK_1

channel ORA_DISK_1:SID=51 device type=DISK

Finished backup at10-AUG-16

 

contents of MemoryScript:

{

   backup as copy current controlfile forstandby auxiliary format  '+DATA/jason2/controlfile/current.256.919708533';

}

executing MemoryScript

 

Starting backup at10-AUG-16

using channelORA_DISK_1

channel ORA_DISK_1:starting datafile copy

copying standby controlfile

RMAN-00571:===========================================================

RMAN-00569:=============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571:===========================================================

RMAN-03002: failureof Duplicate Db command at 08/10/2016 07:38:20

RMAN-05501: abortingduplication of target database

RMAN-03015: erroroccurred in stored script Memory Script

RMAN-03009: failureof backup command on ORA_DISK_1 channel at 08/10/2016 07:38:20

ORA-17628: Oracleerror 19505 returned by remote Oracle server

RMAN>

錯(cuò)誤分析:該錯(cuò)誤mos也給出了對應(yīng)解決方法,由于主備庫目錄不一致未使用參數(shù)db_file_name_convert,LOG_FILE_NAME_CONVERT參數(shù)導(dǎo)致。本案例中主備庫都是用+data磁盤組,同時(shí)使用OMF管理文件。因此不適用本案例。在創(chuàng)建數(shù)據(jù)庫期間,警告日志報(bào)如下錯(cuò)誤:

ORA-15025: could not open disk"/dev/asm-diskb"

ORA-27041: unable to open file

Linux-x86_64 Error: 13: Permissiondenied

Additional information: 9

Wed Aug 10 07:38:19 2016

SUCCESS: diskgroup DATA wasdismounted

ERROR: diskgroup DATA was notmounted

Errors in file/u01/app/oracle/diag/rdbms/jason2/JASON/trace/JASON_ora_3131.trc:

ORA-19505:failed to identify file "+DATA/jason2/controlfile/current.256.919708533"

ORA-17502:ksfdcre:3 Failed to create file +DATA/jason2/controlfile/current.256.919708533

ORA-15001: diskgroup"DATA" does not exist or is not mounted

ORA-15040: diskgroup is incomplete

備庫磁盤組存在,且查看主庫磁盤組與備庫磁盤組權(quán)限一致,那么可能是其他原因?qū)е?。最終發(fā)現(xiàn)主庫的/u01/app/oracle/product/11.2.0/dbhome_1/bin/oracle文件權(quán)限不一致。

主庫

[root@server1 bin]# ll oracle

-rwsr-s--x 1 oracle asmadmin239626731 Aug 11 20:06 oracle

備庫

[root@server2 bin]# ll oracle

-rwsr-s--x 1 oracle oinstall239626731 Aug 11 20:06 oracle

主備庫唯一的區(qū)別在于備庫是通過rman復(fù)制創(chuàng)建。測試發(fā)現(xiàn)在dbca創(chuàng)建數(shù)據(jù)庫后將會修改該文件權(quán)限。以下為測試過程:

安裝grid,數(shù)據(jù)庫軟件時(shí),未創(chuàng)建數(shù)據(jù)庫時(shí)

[root@server1 dbhome_1]# cd bin/

[root@server1 bin]# ll oracle

-rwsr-s--x 1 oracle oinstall239626731 Aug 11 20:06 oracle

[root@server1 bin]#

dbca創(chuàng)建數(shù)據(jù)庫之后

[root@server1 trace]# cd/u01/app/oracle/product/11.2.0/dbhome_1/bin/

[root@server1 bin]# ll oracle

-rwsr-s--x 1 oracle asmadmin239626731 Aug 11 20:06 oracle

[root@server1 bin]#

因此修改備庫該文件權(quán)限,問題解決。

[root@server2 bin]#chown oracle:asmadminoracle

[root@server2 bin]#chmod 6751 oracle

[root@server2 bin]# ll oracle

-rwsr-s--x 1 oracle asmadmin239626731 Aug 11 20:06 oracle

16.報(bào)錯(cuò)2

備用數(shù)據(jù)庫啟動(dòng)時(shí)報(bào)如下錯(cuò)誤

ERROR: failed to establish dependency between database JASON2 anddiskgroup resource ora.DATA.dg

查看噶日志信息是因?yàn)閭鋷煳醋匀隒RS啟動(dòng)時(shí)報(bào)錯(cuò)。同時(shí)備機(jī)重啟僅ASM實(shí)例與crs啟動(dòng),CRS無法啟動(dòng)數(shù)據(jù)庫。因此注冊備庫至CRS中。

以oracle用戶執(zhí)行

[oracle@server2 dbs]$ srvctl add database -d JASON2 -o/u01/app/oracle/product/11.2.0/dbhome_1 -p +DATA/JASON2/spfileJASON.ora -i jason -r PHYSICAL_STANDBY -n jason

[oracle@server2 dbs]$ srvctl modify database -d JASON2 -a 'data'

[oracle@server2 dbs]$ srvctl config database -d jason2 -a

Database unique name: JASON2

Database name: jason

Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/JASON2/spfileJASON.ora

Domain:

Start options: open

Stop options: immediate

Database role: PHYSICAL_STANDBY

Management policy: AUTOMATIC

Database instance: jason

Disk Groups: DATA

Services:

Database is enabled

[oracle@server2 dbs]$

 


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI