20 Şubat 2013 Çarşamba

      Migrate Database to Another Platform using Rman
Database başka bir platforma taşımadan önce bazı gereksinimlerini kontrol etmeliyiz.Transport işlemini geçekleştirebilmek için iki sistem de aynı endian format biçimine sahip olmalıdır.

1)İlk olarak migrate işlemi için sistemlerin birbirlerine uyumluluğunu öğrenebilmek için platform_name ve  endian formatlarını kontrol ederiz.Ayrıca v$transportable_platforms view kontrol ederek varolan sistem için transport işleminin desteklenip desteklenmediğini öğrenmeliyiz.
Source system
SQL> select platform_name from v$database;
PLATFORM_NAME
--------------------------------------------------------------------------------
Linux x86 64-bit

SQL> SELECT PLATFORM_ID, PLATFORM_NAME, ENDIAN_FORMAT
  2  FROM   V$TRANSPORTABLE_PLATFORM
  3  WHERE UPPER(PLATFORM_NAME) LIKE '%LINUX IA%';
PLATFORM_ID PLATFORM_NAME                  ENDIAN_FORMAT
----------- ------------------------------                             --------------
         10         Linux IA (32-bit)                          Little
         11         Linux IA (64-bit)                           Little


Destination system
SQL> select platform_name from v$database;
PLATFORM_NAME
--------------------------------------------------------------------------------
Microsoft Windows x86 64-bit

SQL> select platform_name,endian_format from v$transportable_platform where plat
form_name LIKE '%Microsoft%';
PLATFORM_NAME                  ENDIAN_FORMAT
------------------------------ --------------
Microsoft Windows IA (32-bit)  Little
Microsoft Windows IA (64-bit)  Little
Microsoft Windows x86 64-bit   Little

2)İkinci olarak işlemler bittiğinde  transport işleminin başarılı bir şekilde gerçekleştiğini kontrol etmek için source database içerisinde bazı objeler oluştururuz.

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/demodb/system01.dbf
/u01/app/oracle/oradata/demodb/sysaux01.dbf
/u01/app/oracle/oradata/demodb/undotbs01.dbf
/u01/app/oracle/oradata/demodb/users01.dbf
SQL> create tablespace deneme datafile '/u01/app/oracle/oradata/demodb/student.dbf'  size 10M;
Tablespace created.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/demodb/system01.dbf
/u01/app/oracle/oradata/demodb/sysaux01.dbf
/u01/app/oracle/oradata/demodb/undotbs01.dbf
/u01/app/oracle/oradata/demodb/users01.dbf
/u01/app/oracle/oradata/demodb/student.dbf

SQL> create user aaa identified by aaa default tablespace deneme;
User created.
SQL> grant resource,connect to aaa;
Grant succeeded.
SQL> conn aaa
Enter password:
Connected.
SQL> show user
USER is "AAA"
SQL> create table info(id number);
Table created.
SQL> insert into info values(91231312);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from info;
        ID
----------
  91231312


3)Gerekli prerequests kontrol ettikten  sonra datafiles target platforma uygun olacak şekilde convert ederiz.Convert işlemini gerçekleştirmeden önce database read only modda açarız.

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

Total System Global Area  943669248 bytes
Fixed Size                  2234000 bytes
Variable Size             255854960 bytes
Database Buffers          679477248 bytes
Redo Buffers                6103040 bytes
Database mounted.
SQL> alter database open read only;
Database altered.


 Convert işlemi sonucunda oluşacak dosyalar için bir directory oluştururuz.
[oracle@localhost ~]$ mkdir /home/oracle/demodbfile


RMAN> convert database
2> new database 'targetdb'(target sistemde oluşturulacak olan database sid)
3> transport script '/home/oracle/demodbfile/transport.sql'(transport işlemiiçin oluşturulacak sql script.)
4> to platform 'Microsoft Windows x86 64-bit'(target platform name)
5>format '/home/oracle/demodbfile/targetdb'
6>db_file_name_convert '/u01/app/oracle/oradata/demodb/'(source sistemde datafile bulunduğu location) '/home/oracle/demodbfile/'(convert edilecek olan file konulacağı location.);

Starting conversion at source at 06-FEB-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK

Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.XMLDIR found in the database
User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=/u01/app/oracle/oradata/demodb/system01.dbf
converted datafile=/home/oracle/demodbfile/system01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00002 name=/u01/app/oracle/oradata/demodb/sysaux01.dbf
converted datafile=/home/oracle/demodbfile/sysaux01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=/u01/app/oracle/oradata/demodb/undotbs01.dbf
converted datafile=/home/oracle/demodbfile/undotbs01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00005 name=/u01/app/oracle/oradata/demodb/student.dbf
converted datafile=/home/oracle/demodbfile/student.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=/u01/app/oracle/oradata/demodb/users01.dbf
converted datafile=/home/oracle/demodbfile/users01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Edit init.ora file /home/oracle/demodbfile/init_targetdb.ora. This PFILE will be used to create the database on the target platform

Run SQL script /home/oracle/demodbfile/transport.sql on the target platform to create database
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 06-FEB-13


4)Convert işleminden son init_sid.ora, datafile ve transport.sql dosyası daha önceden create ettiğimiz /home/oracle/demodbfile directory içerisinde  oluşur.Bunları target sisteme taşırız.init_sid.ora dosyasında bulunan aşağıdaki parametrelerin değerleri yeni sisteme uygun
olacak şekilde değiştirilir.Bu dosya set parametreler için belirtilen directory oluşturulur.Bu dosyayı edit ettikten sonra $ORACLE_HOME\dbs klasörüne taşınır.

control_files='C:\app\Administrator\oradata\targetdb\control01.ctl'
db_recovery_file_dest='C:\app\Administrator\flash_recovery_area'
audit_file_dest='C:\app\Administrator\admin\targetdb\adump' 

Daha sonra transport.sql dosyası düzenlenir.

[oracle@localhost demodbfile]$ cat transport.sql
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.

-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT PFILE='/home/oracle/demodbfile/init_targetdb.ora'(yeni sisteme göre uygun path yazılır)
CREATE CONTROLFILE REUSE SET DATABASE "TARGETDB" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE

(redo log yeni path yazılır.)
  GROUP 1 '/home/oracle/demodbfile/targetdb' 
SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/home/oracle/demodbfile/targetdb' 
SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/home/oracle/demodbfile/targetdb' 
SIZE 50M BLOCKSIZE 512
DATAFILE

(datafile yeni path yazılır.)
  '/home/oracle/demodbfile/system01.dbf',

  '/home/oracle/demodbfile/sysaux01.dbf',

  '/home/oracle/demodbfile/undotbs01.dbf',
  '/home/oracle/demodbfile/users01.dbf',
  '/home/oracle/demodbfile/student.dbf'
CHARACTER SET WE8MSWIN1252
;

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.

(Temp file için path yazılır)
ALTER TABLESPACE TEMP ADD TEMPFILE '/home/oracle/demodbfile/targetdb/temp01.dbf'
     SIZE 20971520  AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.

set echo off
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt * Your database has been created successfully!
prompt * There are many things to think about for the new database. Here
prompt * is a checklist to help you stay on track:
prompt * 1. You may want to redefine the location of the directory objects.
prompt * 2. You may want to change the internal database identifier (DBID)
prompt *    or the global database name for this database. Use the
prompt *    NEWDBID Utility (nid).
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SHUTDOWN IMMEDIATE

(kullanılan pfile path yazılır)
STARTUP UPGRADE PFILE='/home/oracle/demodbfile/init_targetdb.ora'
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP PFILE='/home/oracle/demodbfile/init_targetdb.ora'
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;

5)Target sistemde boş bir instance oluşturulur.
C:\>oradim -new -sid targetdb
C:\> set ORACLE_SID=targetdb
C:\>sqlplus / as sysdba

SQL>@C:\app\Administrator\oradata\targetdb\trasnport.sql
 En sonunda source database oluşturduğumuz table sorgulayaca transport işlemini başarılı olp oladığını kontrol edebiliriz.

Hiç yorum yok: