Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Oracle Database 11g.pdf
Скачиваний:
78
Добавлен:
10.06.2015
Размер:
12.69 Mб
Скачать

Lab 8.2: Duplicating a Database Using Backup-Based Duplication 

731

SQL*Plus: Release 11.1.0.6.0 - Production on Sun Oct 5 00:04:02 2008

 

Copyright

(c) 1982, 2007, Oracle. All rights reserved.

 

Connected

to:

 

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

 

With the Partitioning, OLAP, Data Mining

 

and Real Application Testing options

 

SQL> select name, open_mode from v$database;

 

NAME

OPEN_MODE

 

---------

----------

 

AUXDB

READ WRITE

 

Lab 8.2: Duplicating a Database Using Backup-Based Duplication to a Different Point in Time

In this exercise, you will use backup-based duplication to create a database on the same system that the target database resides on. For this exercise, your database should be running in ARCHIVELOG mode and all networking to the target database should already be configured.

1.Back up your database as shown in Exercise 4.2.

2.Start RMAN and confirm that you have a valid backup with the list backup of database summary command and the restore database validate command. Note that your output will likely look very different from ours.

C:\Documents and Settings\Robert>rman target=/ Recovery Manager: Release 11.1.0.6.0 - Production on Sat Oct 4 22:56:10 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORCL (DBID=1194923408)

RMAN> list backup of database summary;

using target database control file instead of recovery catalog

List of Backups

 

 

 

 

 

===============

 

 

 

 

 

Key

TY LV

S

Device Type Completion Time #Pieces

#Copies

Compressed Tag

-------

-- --

-

-----------

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

-------

-------

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

2

B F

A

DISK

03-OCT-08

1

1

YES

TAG20081003T135426

 

 

 

 

RMAN> restore

database validate;

 

 

 

732  Appendix A  n  Lab Exercises

Starting restore at 04-OCT-08 allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=127 device type=DISK

channel ORA_DISK_1: starting validation of datafile backup set channel ORA_DISK_1: reading from backup piece C:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_10_03 \O1_MF_NNNDF_TAG20081003T135426_4GDY3S9H_.BKP

channel ORA_DISK_1: piece handle=C:\ORACLE\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2008_10_03 \O1_MF_NNNDF_TAG20081003T135426_4GDY3S9H_.BKP tag=TAG20081003T135426 channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: validation complete, elapsed time: 00:01:36 Finished restore at 04-OCT-08

C:\Documents and Settings\Robert>set oracle_sid=orcl

3.If you are running in Windows, create the service for the new database with oradim. In this example, we are creating a new database instance called neworcl.

C:\>oradim -new -sid neworcl Instance created.

If there are any other OS-specific operations required to create a database instance, complete those now.

4.Create the password file for the neworcl instance.

C:\>orapwd file=c:\oracle\product\11.1.0\db_1\database\pwdneworcl.ora Enter password for SYS:

5.Create a temporary pfile for the neworcl auxiliary instance using your editor of choice. The pfile should be contained in the ORACLE_HOME\database directory of the auxiliary instance and should be named initneworcl.ora. The pfile should have these parameters in it:

db_name=neworcl memory_target=300m

control_files=’c:\oracle\oradata\neworcl\control01.ctl’, ‘c:\oracle\oradata\neworcl\control02.ctl’

We will do the actual file-location conversions during the duplication.

6.Create the directory c:\oracle\oradata\neworcl. mkdir c:\oracle\oradata\neworcl

Lab 8.2: Duplicating a Database Using Backup-Based Duplication 

733

7.Start up the auxiliary instance.

C:\oracle\product\11.1.0\db_1\database>set oracle_sid=neworcl C:\oracle\product\11.1.0\db_1\database>sqlplus “/ as sysdba” SQL*Plus: Release 11.1.0.6.0 - Production on Sat Oct 4 23:09:52 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup

nomount

 

 

ORACLE instance started.

 

 

Total System

Global Area

313860096

bytes

Fixed Size

 

1332892

bytes

Variable Size

 

192940388

bytes

Database Buffers

113246208

bytes

Redo Buffers

 

6340608

bytes

8.Configure service name resolution for your new auxiliary database. The method of this configuration will vary based on your site. In our case, we created an entry in the tnsnames.ora file on our server that looked like this:

NEWORCL = (DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521)) (CONNECT_DATA =

(SERVER = DEDICATED) (SERVICE_NAME = neworcl)

) )

9.Now you will need to hard-code the instance name into the listener.ora file until the duplication of the database has been completed. You will get network errors if you do not hard-code the auxiliary instance in the listener.ora file. Here’s an example of the entry in our listener.ora:

SID_LIST_LISTENER = (SID_LIST = (SID_DESC =

(ORACLE_HOME=C:\oracle\product\11.1.0\db_1\NETWORK\ADMIN) (SID_NAME=neworcl)

) )

LISTENER = (DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

) )

734  Appendix A  n  Lab Exercises

10.Test the network connectivity to the auxiliary instance.

C:\oracle\product\11.1.0\db_1\database>sqlplus sys/robert@neworcl as sysdba SQL*Plus: Release 11.1.0.6.0 - Production on Sat Oct 4 23:17:50 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining

and Real Application Testing options

SQL> select instance_name from v$instance; INSTANCE_NAME

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

neworcl

If the connection fails, review the network configuration and ensure that the new auxiliary instance is running.

11.Connect to the ORCL database using the scott account.

C:\Documents and Settings\Robert>sqlplus scott/tiger

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Oct 11 14:43:14 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining

and Real Application Testing options SQL>

If you are using a new database, you may need to unlock the scott account.

SQL> alter user scott account unlock; User altered.

SQL> alter user scott identified by tiger; User altered.

12.In the scott schema, create a table called DUPE_TABLE.

SQL> create table dupe_table(id number, the_date date); Table created.

13.Insert a record in the DUPE_TABLE table and commit.

SQL> Insert into dupe_table values (1, sysdate); 1 row created.

SQL> commit; Commit complete.

Lab 8.2: Duplicating a Database Using Backup-Based Duplication 

735

14.Wait for a minute or so. Insert a second record in the DUPE_TABLE table and commit.

SQL> Insert into dupe_table values (1, sysdate); 1 row created.

SQL> commit; Commit complete.

15.Select from the DUPE_TABLE table.

SQL> select * from dupe_table; ID THE_DATE

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

1 10/11/2008 14:46:14

1 10/11/2008 14:48:25

16.Connect as sys and force a log switch. This is because database duplications from backup will use only archived redo logs to recover a database. Online redo logs are not used. This is not true with active database duplications.

SQL> connect sys/robert as sysdba Connected.

SQL> alter system switch logfile; System altered.

17.Start RMAN and connect to the target and the auxiliary databases.

C:\oracle\product\11.1.0\db_1\database>Set oracle_sid=orcl C:\oracle\product\11.1.0\db_1\database>Rman target=/ auxiliary=sys/Robert@neworcl

Recovery Manager: Release 11.1.0.6.0 - Production on Sat Oct 4 23:19:55 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORCL (DBID=1194923408) connected to auxiliary database: NEWORCL (not mounted)

18.We are now ready to start the database duplication. Issue the duplicate database command, recovering the database to a time in between the two insert records. We recommend you recover to about 5 seconds before the second record, as shown here:

duplicate target database to neworcl

until time “to_date(‘10/11/2008 14:48:20’,’mm/dd/yyyy hh24:mi:ss’)“ nofilenamecheck

spfile set control_files= ‘c:\oracle\oradata\neworcl\control01.ctl’,

736  Appendix A  n  Lab Exercises

‘c:\oracle\oradata\neworcl\control02.ctl’ set db_file_name_convert

’c:\oracle\oradata\orcl’,’c:\oracle\oradata\neworcl’ set log_file_name_convert ’c:\oracle\oradata\orcl’,’c:\oracle\oradata\neworcl’;

This command does the following:

NN

It starts the duplication process.

NNIt starts the duplication process restoring the database to the specific point in time using backups of the database and archived redo logs. The restore will be to the point in time listed in the until time clause.

NNThe SPFILE parameter will result in the target database spfile being copied over to the duplicate database. The duplicate database will use this spfile.

NNThe set commands (set control_files, set db_file_name_convert, and set log_file_name_convert) modify or add parameters to the spfile being copied to the duplicate database.

This duplicate command will result in a great deal of output, which we have decided not to include here as it seems a great waste of a perfectly good tree. Here is the output that you hopefully will see at the end of the database duplication:

database opened

Finished Duplicate Db at 04-OCT-08

19.Connect to the duplicated database to verify that it is open.

C:\oracle\product\11.1.0\db_1\database>set oracle_sid=neworcl C:\oracle\product\11.1.0\db_1\database>sqlplus sys/Robert as sysdba SQL*Plus: Release 11.1.0.6.0 - Production on Sun Oct 5 00:04:02 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining

and Real Application Testing options

SQL> select name, open_mode from v$database;

NAME

OPEN_MODE

---------

----------

AUXDB

READ WRITE

20.Connect to the scott schema. Query the DUPE_TABLE and ensure that only one record now exists.

SQL> connect scott/tiger Connected.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]