2 Ocak 2013 Çarşamba

              Migrate Database From File System to ASM
 1)İlk olarak sistemimizde bulunan spfile ASM içerisine taşımalı ve spfile parametresini yeni spfile gösterecek şekilde set etmeliyiz.İlk olarak var olan spfile ASM içerisine alıyoruz.Bu işlemi gerçekleştirmek için ilk olarak spfile backup alırız.

RMAN> backup as backupset spfile;
Starting backup at 02-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 02-JAN-13
channel ORA_DISK_1: finished piece 1 at 02-JAN-13
piece handle=/u01/app/oracle/fast_recovery_area/YADB/backupset/2013_01_02/o1_mf_nnsnf_TAG20130102T103154_8g7w3tnm_.bkp tag=TAG20130102T103154 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-JAN-13



Daha sonra database mount modda açarız.
SQL>Shutdown immediate
SQL>Startup mount;


RMAN> restore spfile to '+DATA/YADB/spfileyadb.ora';
Starting restore at 02-JAN-13
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring SPFILE
output file name=+DATA/YADB/spfileyadb.ora
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/YADB/backupset/2013_01_02/o1_mf_nnsnf_TAG20130102T103154_8g7w3tnm_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/YADB/backupset/2013_01_02/o1_mf_nnsnf_TAG20130102T103154_8g7w3tnm_.bkp tag=TAG20130102T103154
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 02-JAN-13
RMAN>


Bu şekilde spfile ASM içerisine  restore ettikten sonra spfile kullanarak  pfile create ederiz ve spfile bulunduğu yeni path bilgisini  bu pfile ekleriz.$oracle_home/dbs altında bulunan spfileyadb.ora dosyasını kaldırırız.
SQL>create pfile from spfile;-->pfile dosyası özel olarak bir path belirtilmezse spfile bulunduğu yere koyulur.
Oluşan pfile dosyasına spfile=+DATA/YADB/spfileyadb.ora satırını ekleriz.Ve database kapatıp  pfile dosyasını kullanarak açarız.
$mv spfileyadb.ora spfileyadb.ora.org
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/inityadb.ora'
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size                  2228904 bytes
Variable Size            1040190808 bytes
Database Buffers          603979776 bytes
Redo Buffers                7118848 bytes
Database mounted.
Database opened.
SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/yadb/spfileyadb.ora

Database artık ASM içerisinde bulunan spfile kullanıyor.

2)İkinci olarak control file ASM içerisine taşırız.
SQL>show parameter contol_files
                control_files                        string      /u01/app/oracle/oradata/yadb/control01.ctl,
                                                                         /u01/app/oracle/fast_recovery_area/yadb/control02.ctl


ASM içerisinde control file oluştururuz.İlk önce database nomount modda çalıştırırız.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size                  2228904 bytes
Variable Size            1040190808 bytes
Database Buffers          603979776 bytes
Redo Buffers                7118848 bytes


RMAN> restore controlfile to '+DATA' from '/u01/app/oracle/oradata/yadb/control01.ctl';
Starting restore at 02-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK
channel ORA_DISK_1: copied control file copy
output file name=+DATA/yadb/control01.ctl
Finished restore at 02-JAN-13
RMAN>


Daha sonra control_files initialization parametresini ASM içerisindeki control file gösterecek şekilde set etmeliyiz.
 SQL> alter system set control_files='+DATA/YADB/control01.ctl' scope=spfile;
 SQL> alter database mount;
Database altered.
SQL> alter database open;
Database altered


Database tekrar kapatıp açtıktan sonra control file değiştiğini görürüz.
SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      +DATA/yadb/control01.ctl



3)db_create_file_dest db_recovery_file dest parametrelerini ASM gösterecek şekilde set etmeliyiz.
SQL>alter system set db_create_file_dest='+DATA' scope=spfile;
SQL>alter system set db_recovery_file_dest_size=5000M scope=spfile;
SQL>alter system set db_recovery_file_dest='+DATA' scope=spfile;

Database yeniden başlattıktan sonra bu değişiklikler geçerli olacaktır.

4)Datafile taşıma işlemini gerçekleştiririz.İlk olarak database mount mod da açarız.

SQL> startup mount;
ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size                  2228904 bytes
Variable Size            1040190808 bytes
Database Buffers          603979776 bytes
Redo Buffers                7118848 bytes
Database mounted.


RMAN> backup as copy database format '+DATA';  
Starting backup at 02-JAN-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/yadb/system01.dbf
output file name=+DATA/yadb/datafile/system.307.803648229 tag=TAG20130102T113708 RECID=3 STAMP=803648248
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/yadb/sysaux01.dbf
output file name=+DATA/yadb/datafile/sysaux.308.803648253 tag=TAG20130102T113708 RECID=4 STAMP=803648273
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/yadb/undotbs01.dbf
output file name=+DATA/yadb/datafile/undotbs1.309.803648279 tag=TAG20130102T113708 RECID=5 STAMP=803648293
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=+DATA/yadb/controlfile/backup.310.803648295 tag=TAG20130102T113708 RECID=6 STAMP=803648294
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/yadb/users01.dbf
output file name=+DATA/yadb/datafile/users.311.803648295 tag=TAG20130102T113708 RECID=7 STAMP=803648295
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 02-JAN-13
channel ORA_DISK_1: finished piece 1 at 02-JAN-13
piece handle=+DATA/yadb/backupset/2013_01_02/nnsnf0_tag20130102t113708_0.312.803648297 tag=TAG20130102T113708 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-JAN-13


Bu işlem ile datafile kopyaları ASM içerisinde oluşturuldu.Şimdi database bu yeni oluşturulan datafile switch etmeliyiz.
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/yadb/datafile/system.307.803648229"
datafile 2 switched to datafile copy "+DATA/yadb/datafile/sysaux.308.803648253"
datafile 3 switched to datafile copy "+DATA/yadb/datafile/undotbs1.309.803648279"
datafile 4 switched to datafile copy "+DATA/yadb/datafile/users.311.803648295"


5)Temp file ASM içerisinde oluşturmalıyız.İlk önce sistemimizde varolan tempfile kontrol ederiz.

SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/yadb/temp01.dbf


Daha sonra sistemimizde varolan temp file siler yerine yenisini oluştururuz.

SQL> alter database tempfile '/u01/app/oracle/oradata/yadb/temp01.dbf' drop including datafiles
SQL>alter tablespace TEMP add tempfile size 100M autoextend on;

Tablespace altered.
SQL> select * from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
   FILE_ID TABLESPACE_NAME                     BYTES     BLOCKS STATUS
---------- ------------------------------ ---------- ---------- -------
RELATIVE_FNO AUT   MAXBYTES  MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS
------------ --- ---------- ---------- ------------ ---------- -----------
+DATA/yadb/tempfile/temp.314.803649747
         1 TEMP                            104857600      12800 ONLINE

           1 YES 3.4360E+10    4194302        12800  103809024       12672

Yeni temp tablespace +DATA/yadb/tempfile klasöründe bulunmaktadır.

6)Redo log file ASM içerisine taşırız.En başta sistemimizde varolan redolog file görüntüleriz.

SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/yadb/redo01.log
/u01/app/oracle/oradata/yadb/redo02.log
/u01/app/oracle/oradata/yadb/redo03.log

SQL> select group#,thread#,status from v$log;
    GROUP#    THREAD# STATUS
---------- ---------- ----------------
         1          1 INACTIVE
         2          1 INACTIVE
         3          1 CURRENT


Bu işlemi yaparken inactive olan redolog siler yenilerini oluştururuz.

SQL> alter database drop logfile group 2;
Database altered.
SQL> select group#,thread#,status from v$log;
    GROUP#    THREAD# STATUS
---------- ---------- ----------------
         1          1 INACTIVE
         3          1 CURRENT

Database çalışması için en az 2 tane redolog gerektiğinde 3. redolog oluşturmadan birisini daha silmeye izin vermeyecektir.
SQL> alter database add  logfile group 2;
SQL> alter database drop logfile group 1;
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC
---------- ---------- ---------- ---------- ---------- ---------- ---
STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------------- ------------- --------- ------------ ---------
         2          1          0  104857600        512          2 YES
UNUSED                       0                      0

         3          1         72   52428800        512          1 NO
CURRENT                 996792 02-JAN-13   2.8147E+14
SQL> alter database add logfile group 1;
Database altered.


Şu anda sistemimizde 3 tane redolog file var 1 ve 2 ASM içerisinde 3 normal file system içerisinde bulunuyor.Current redolog olduğu için onu silemeyiz. İlk önce inactive durumuna almalıyız. Bunun için ;
SQL>alter system switch logfile;->bu komut ile current logfile arşivlenir ve bir sonraki redolog current olur. Bir süre sonra 3. redolog ta incative duruma  geçecektir.

SQL> alter database drop logfile group 3
  2  ;
Database altered.
SQL> alter database add logfile group 3;
Database altered.

Artık bütün redolog file ASM içerisinde yer alıyor
SQL> select group#,status, member,type from v$logfile;

    GROUP# STATUS  MEMBER                         TYPE
---------- ------- ------------------------------ -------
         1         +DATA/yadb/onlinelog/group_1.3 ONLINE
                   16.803659521

         2         +DATA/yadb/onlinelog/group_2.3 ONLINE
                   15.803659401

         3         +DATA/yadb/onlinelog/group_3.3 ONLINE
                   18.803660321

         2         +DATA/yadb/onlinelog/group_2.3 ONLINE
                   13.803659403

    GROUP# STATUS  MEMBER                         TYPE
---------- ------- ------------------------------ -------

         1         +DATA/yadb/onlinelog/group_1.3 ONLINE
                   17.803659521

         3         +DATA/yadb/onlinelog/group_3.3 ONLINE
                   19.803660323

Hiç yorum yok: