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

Lab 2.2: Putting the Database in ARCHIVELOG Mode 

691

Lab 2.2: Putting the Database

in ARCHIVELOG Mode

In this exercise, you will configure the database for ARCHIVELOG mode. You will then actually put the database in ARCHIVELOG mode.

1.Create a directory called c:\oracle\arch\arch.

C:\>mkdir oracle C:\>cd oracle C:\oracle>mkdir arch C:\oracle>cd arch

C:\oracle\arch>mkdir orcl C:\oracle\arch>cd orcl C:\oracle\arch\orcl>

2.Log into your database using SQL*Plus. Check the log mode the database is in by querying the LOG_MODE column in V$DATABASE.

C:\oracle\orabackup\orcl>sqlplus sys as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Aug 14 19:37:19 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Enter password: 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 log_mode from v$database; LOG_MODE

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

NOARCHIVELOG

3.Using the alter system command, set the LOG_ARCHIVE_DEST_1 parameter to point to the new directory you created in step 1.

SQL> Alter system set log_archive_dest_1=’location=c:\oracle\arch\orcl’; System altered.

4.Shut down the database using the shutdown immediate command.

SQL> shutdown immediate Database closed.

692  Appendix A  n  Lab Exercises

Database dismounted.

ORACLE instance shut down.

5.Put the database in MOUNT mode with the startup mount command. Confirm that the database is in MOUNT mode by querying the OPEN_MODE column in V$DATABASE.

SQL> startup mount

ORACLE instance started.

 

 

Total System Global Area

397557760

bytes

Fixed Size

1333452

bytes

Variable Size

272631604

bytes

Database Buffers

117440512

bytes

Redo Buffers

6152192

bytes

Database mounted.

 

 

SQL> select open_mode from v$database; OPEN_MODE

----------

MOUNTED

6.Now put the database in ARCHIVELOG mode using the alter database archivelog command.

SQL> alter database archivelog; Database altered.

7.Open the database with the alter database open command. Check the LOG_MODE parameter of the V$DATABASE view to ensure that the database is in ARCHIVELOG mode.

SQL> alter database open; Database altered.

SQL> select log_mode from v$database; LOG_MODE

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

ARCHIVELOG

8.To ensure that the database is configured correctly, force a log switch.

SQL> Alter system switch logfile; System altered.

9.Now check the directory c:\oracle\arch\orcl to ensure that the archived redo logs are being created correctly.

SQL> Host dir c:\oracle\arch\orcl Volume in drive C has no label.

 

 

Lab 2.3: Executing a Manual Online (Hot) Backup 

693

Volume Serial Number is 08DE-E1AB

 

 

 

Directory of c:\oracle\arch\orcl

 

 

 

08/14/2008

07:48 PM

<DIR>

 

.

 

08/14/2008

07:48 PM

<DIR>

 

..

 

08/14/2008

07:48 PM

1,024 ARC00003_0662757171.001

 

 

1

File(s)

 

1,024

bytes

 

 

2

Dir(s)

12,981,006,336

bytes free

 

Lab 2.3: Executing a Manual

Online (Hot) Backup

In this lab, you will perform an online/hot backup of your database, with the database still running.

1.Create a directory for the backups. In this lab, we use c:\oracle\orabackup\orcl\hot. We assume that the directory structure c:\oracle\orabackup\orcl is already created from the work you did in Lab 2.1.

C:\>cd oracle\orabackup\orcl C:\oracle\orabackup\orcl> mkdir hot

2.Log into your database using SQL*Plus. Check the log mode the database is in by querying the LOG_MODE column in V$DATABASE. It should be in ARCHIVELOG mode.

C:\oracle\orabackup\orcl>sqlplus sys as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Aug 14 19:37:19 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Enter password: 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 log_mode from v$database; LOG_MODE

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

ARCHIVELOG

3.Using the DBA_DATA_FILES view, determine the datafiles that you will need to back up.

SQL> select tablespace_name, file_name from dba_data_files;

694  Appendix A  n  Lab Exercises

TABLESPACE_NAME FILE_NAME

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

USERS C:\ORACLE\ORADATA\ORCL\USERS01.DBF UNDOTBS1 C:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF SYSAUX C:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF SYSTEM C:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF

4.Using the V$LOG view, determine which sequence is the current online redo log sequence. You must ensure that you have this log sequence and all logs generated during the backup in order to be able to restore the backup.

SQL> select group#, sequence#, status from v$log; GROUP# SEQUENCE# STATUS

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

14 CURRENT

2

2 INACTIVE

33 INACTIVE

5.Put the database in hot backup mode with the alter database begin backup command.

SQL> alter database begin backup; Database altered.

6.Copy all database datafiles (in our case, they all have an extension of .dbf) to the backup directory created in step 1.

SQL>host C:\oracle\orabackup\orcl>>Copy c:\oracle\oradata\orcl\*.dbf c:\oracle\orabackup\orcl\hot\*.*

c:\oracle\oradata\orcl\SYSAUX01.DBF

c:\oracle\oradata\orcl\SYSTEM01.DBF

c:\oracle\oradata\orcl\TEMP01.DBF

c:\oracle\oradata\orcl\UNDOTBS01.DBF

c:\oracle\oradata\orcl\USERS01.DBF 5 file(s) copied.

7.Using the V$LOG view, determine which sequence is the current online redo log sequence. You must ensure that you have this log sequence and all logs generated during the backup in order to be able to restore the backup. In our case, we need log sequences starting with 4 (the sequence when we started our backup) and continuing through log sequence 7.

SQL> select group#, sequence#, status from v$log;

GROUP# SEQUENCE# STATUS

Lab 2.3: Executing a Manual Online (Hot) Backup 

695

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

17 CURRENT

25 INACTIVE

36 INACTIVE

8.Take the database out of hot backup mode with the alter database end backup command.

SQL> alter database end backup; Database altered.

9.Use the alter system switch logfile command to force a switch from log sequence 7.

SQL> alter system switch logfile;

There may be times when you will need to use the alter system archive log all; command to get the latest archived redo-log files archived in a timely manner.

10.Check the archive-log directory to make sure log-file sequences 4 through 7 have been created. Note that we also checked the LOG_ARCHIVE_FORMAT parameter value. This is so we can know in the filename of the archived redo logs where the sequence number is.

SQL> show parameter log_archive_format

 

 

NAME

 

TYPE

VALUE

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

log_archive_format

string

ARC%S_%R.%T

SQL> show parameter log_archive_dest_1

 

 

NAME

 

TYPE

VALUE

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

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

log_archive_dest_1

string

location=c:\oracle\arch\orcl

log_archive_dest_10

string

 

SQL> host dir c:\oracle\arch\orcl

 

 

Volume in drive C has no label.

 

 

Volume Serial Number is 08DE-E1AB

 

 

Directory of c:\oracle\arch\orcl

 

 

08/16/2008

05:25 PM

<DIR>

.

 

08/16/2008

05:25 PM

<DIR>

..

 

08/14/2008

07:48 PM

1,024

ARC00003_0662757171.001

08/15/2008

05:01 AM

49,038,848

ARC00004_0662757171.001

08/15/2008

10:12 PM

48,250,880

ARC00005_0662757171.001

08/16/2008

09:00 AM

48,244,736

ARC00006_0662757171.001

08/16/2008

05:25 PM

34,351,104

ARC00007_0662757171.001

696  Appendix A  n  Lab Exercises

5

File(s)

179,886,592

bytes

 

2

Dir(s)

9,701,888,000

bytes

free

Note in this output that the filename convention has the sequence number of the archived redo log right after the ARC value. Thus we have ARC00003 for log sequence 3, ARC00004 for log sequence 4, and so on. In the preceding output, we appear to have all log sequences that are required to recover this backup.

11.Copy the archived redo logs to the backup location.

SQL> Host copy c:\oracle\arch\orcl\arc*.* c:\oracle\orabackup\orcl\hot\*.* c:\oracle\arch\orcl\ARC00003_0662757171.001 c:\oracle\arch\orcl\ARC00004_0662757171.001 c:\oracle\arch\orcl\ARC00005_0662757171.001 c:\oracle\arch\orcl\ARC00006_0662757171.001 c:\oracle\arch\orcl\ARC00007_0662757171.001

5 file(s) copied.

12.Check the backup directory to ensure that all the files needed are in place.

SQL> Host dir c:\oracle\orabackup\orcl\hot\*.*

Volume in drive C has no label.

Volume Serial Number is 08DE-E1AB

Directory of c:\oracle\orabackup\orcl\hot

08/16/2008

05:36 PM

<DIR>

.

08/16/2008

05:36 PM

<DIR>

..

08/14/2008

07:48 PM

1,024

ARC00003_0662757171.001

08/15/2008

05:01 AM

49,038,848

ARC00004_0662757171.001

08/15/2008

10:12 PM

48,250,880

ARC00005_0662757171.001

08/16/2008

09:00 AM

48,244,736

ARC00006_0662757171.001

08/16/2008

05:25 PM

34,351,104

ARC00007_0662757171.001

08/15/2008

05:40 PM

594,485,248

SYSAUX01.DBF

08/15/2008

05:40 PM

723,525,632

SYSTEM01.DBF

08/14/2008

10:03 PM

20,979,712

TEMP01.DBF

08/15/2008

05:40 PM

26,222,592

UNDOTBS01.DBF

08/15/2008

05:40 PM

5,251,072

USERS01.DBF

 

10 File(s)

1,550,350,848 bytes

 

2 Dir(s)

9,521,692,672 bytes free

Here is a checklist:

NN

Datafiles: Check

NN

Redo log sequences 4 through 7: Check

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