Приветствую Вас Гость | RSS

DBA.UCOZ.RU

Понедельник, 20.11.2017, 18:40
Главная » Статьи » СУБД » Oracle

RMAN в примерах - Быстрый старт. Глава 1.

1-1. Режим архивации

Включение режима архивации базы данных

C:\sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on Wed Jul 22 11:43:36 2009

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  612368384 bytes
Fixed Size                  1292036 bytes
Variable Size             234883324 bytes
Database Buffers          369098752 bytes
Redo Buffers                7094272 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

Проверка установки  режима архивации

SQL> archive log list;

Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     43
Next log sequence to archive   45
Current log sequence           45

1-2. Подключение к RMAN

Локальное подключение

C:\>rman target /

Recovery Manager: Release 10.2.0.3.0 - Production on Thu Jul 16 16:07:22 2009

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

connected to target database: ORCL (DBID=1220050019)

Локальное подключение с использованием имени и пароля

При подключении используется файл паролей.

C:\>rman target sys/test

Recovery Manager: Release 10.2.0.3.0 - Production on Wed Jul 22 12:11:40 2009

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

connected to target database: ORCL (DBID=1220050019)

Удалённое подключение

Подключение возможно только для пользователей с sysdba привилегией.

C:\rman.exe target sys/test@alfa

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jul 22 12:51:14 2009

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

connected to target database: ORCL (DBID=1220050019)

1-3. Копирование базы

Копирование всей базы

RMAN> backup database;

Starting backup at 23-JUL-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=145 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
input datafile fno=00005 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 23-JUL-09
channel ORA_DISK_1: finished piece 1 at 23-JUL-09
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2009_07_23\O1_MF_NNNDF_TAG20090723T114059_56J50D1J_.BKP tag=TAG20090723T114059 com
ment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 23-JUL-09
channel ORA_DISK_1: finished piece 1 at 23-JUL-09
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2009_07_23\O1_MF_NCSNF_TAG20090723T114059_56J51TOK_.BKP tag=TAG20090723T114059 com
ment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 23-JUL-09

Просмотр информации об копии

RMAN> list backup;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6       Full    678.65M    DISK        00:00:42     23-JUL-09
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20090723T114059
        Piece Name: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2009_07_23\O1_MF_NNNDF_TAG20090723T114059_56J50D1J_.BKP
  List of Datafiles in backup set 6
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1727560    23-JUL-09 C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
  2       Full 1727560    23-JUL-09 C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
  3       Full 1727560    23-JUL-09 C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
  4       Full 1727560    23-JUL-09 C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
  5       Full 1727560    23-JUL-09 C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    6.80M      DISK        00:00:01     23-JUL-09
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20090723T114059
        Piece Name: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2009_07_23\O1_MF_NCSNF_TAG20090723T114059_56J51TOK_.BKP
  Control File Included: Ckp SCN: 1727589      Ckp time: 23-JUL-09
  SPFILE Included: Modification time: 22-JUL-09

1-4. Симуляция отказа

Просмотр расположения файлов базы данных

RMAN> report schema;

Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    500      SYSTEM               ***     C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
2    360      UNDOTBS1             ***     C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
3    310      SYSAUX               ***     C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
4    5        USERS                ***     C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
5    100      EXAMPLE              ***     C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    29       TEMP                 32767       C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF

Остановка базы данных

RMAN> shutdown immediate;

database closed
database dismounted
Oracle instance shut down

RMAN> exit


Recovery Manager complet
e.

Переименование файла базы данных

C:\10.2.0\oradata\orcl>move example01.dbf example01.bk
Перемещено файлов:         1.

Запуск  базы данных

C:\>rman target /

Recovery Manager: Release 10.2.0.3.0 - Production on Thu Jul 23 12:01:40 2009

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

connected to target database (not started)

RMAN> startup;

Oracle instance started
database mounted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 07/23/2009 12:01:58
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF'

1-5. Восстановление базы данных

Восстановление  всех файлов базы данных из копии

RMAN> restore database;

Starting restore at 23-JUL-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
restoring datafile 00002 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
restoring datafile 00003 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
restoring datafile 00004 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
restoring datafile 00005 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2009_07_23\O1_MF_NNNDF_TAG20090723T114059_56J50D1
J_.BKP
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\BACKUPSET\2009_07_23\O1_MF_NNNDF_TAG20090723T114059_56J50D1J_.BKP tag=TAG20090723T114059
channel ORA_DISK_1: restore complete, elapsed time: 00:01:06
Finished restore at 23-JUL-09

Применение изменений к файлам базы данных

RMAN> recover database;

Starting recover at 23-JUL-09
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:03

Finished recover at 23-JUL-09

Открытие базы

RMAN> alter database open;

database opened

cd r диски всех типов и производителей!


Категория: Oracle | Добавил: dba (23.07.2009) | Автор: Жилин Сергей Валентинович
Просмотров: 12347 | Комментарии: 2 | Рейтинг: 5.0/3
Всего комментариев: 2
2  

1  
Все мои статьи в pdf формате можно скачать здесь

Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]