redhat enterprise 4下遷移oracle 10g到asm

wxjzqym發表於2014-01-02

1.配置裸裝置
磁碟分割槽
查詢資料庫中每個資料檔案大小,方便後面規劃每個裸裝置大小
SQL>select tablespace_name,bytes/power(1024,2) mb from dba_data_files order by 2 desc;

TABLESPACE_NAME                        MB
------------------------------ ----------
SYSTEM                                480
SYSAUX                                240
EXAMPLE                               100
UNDOTBS1                               30
USERS                                   5

使用fdisk命令對磁碟進行分割槽
[root@dg1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): +481M

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          59      473886   83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (60-261, default 60):
Using default value 60
Last cylinder or +size or +sizeM or +sizeK (60-261, default 261):
Using default value 261

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          59      473886   83  Linux
/dev/sdb2              60         261     1622565    5  Extended

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (60-261, default 60):
Using default value 60
Last cylinder or +size or +sizeM or +sizeK (60-261, default 261): +241M 

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (90-261, default 90):
Using default value 90
Last cylinder or +size or +sizeM or +sizeK (90-261, default 261): +101M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (103-261, default 103):
Using default value 103
Last cylinder or +size or +sizeM or +sizeK (103-261, default 261): +31M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (108-261, default 108):
Using default value 108
Last cylinder or +size or +sizeM or +sizeK (108-261, default 261): +6M

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          59      473886   83  Linux
/dev/sdb2              60         261     1622565    5  Extended
/dev/sdb5              60          89      240943+  83  Linux
/dev/sdb6              90         102      104391   83  Linux
/dev/sdb7             103         107       40131   83  Linux
/dev/sdb8             108         109       16033+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

重新整理磁碟分割槽
[root@dg1 ~]# partprobe /dev/sdb


繫結裸裝置
向/etc/sysconfig/rawdevice檔案新增如下內容

[root@dg1 permissions.d]# more /etc/sysconfig/rawdevices
/dev/raw/raw1   /dev/sdb1
/dev/raw/raw2   /dev/sdb5
/dev/raw/raw3   /dev/sdb6
/dev/raw/raw4   /dev/sdb7
/dev/raw/raw5   /dev/sdb8


修改裸裝置的許可權
[root@dg1 permissions.d]# cd /etc/udev/permissions.d/
[root@dg1 permissions.d]# grep raw 50-udev.permissions
raw/*:oracle:oinstall:0660


2.建立asm例項
建立密碼檔案
[oracle@dg1 dbs]$ orapwd file=orapw+ASM password=oracle entries=5

配置asm例項的引數檔案
[oracle@dg1 dbs]$ cd $ORACLE_HOME/dbs
[oracle@dg1 dbs]$ more init+ASM.ora
INSTANCE_TYPE=ASM
ASM_DISKSTRING=/dev/raw/*

啟用css守護程式
[root@dg1 bin]# cd $ORACLE_HOME/bin
[root@dg1 bin]# ./localconfig add

啟動asm例項
oracle   29423     1  0 Oct28 ?        00:00:00 ora_q001_orcl
[oracle@dg1 dbs]$ export ORACLE_SID=+ASM
[oracle@dg1 dbs]$ sqlplus / as sysdba
SQL>startup nomount
ASM instance started

確認候選asm磁碟狀態正常
SQL>select  header_status, path from v$asm_disk;

HEADER_STATU PATH
------------ ----------------------------------------
MEMBER       /dev/raw/raw5
MEMBER       /dev/raw/raw4
MEMBER       /dev/raw/raw1
MEMBER       /dev/raw/raw2
MEMBER       /dev/raw/raw3

建立asm磁碟組
SQL>CREATE DISKGROUP data
       EXTERNAL REDUNDANCY
       DISK '/dev/raw/raw1',
            '/dev/raw/raw2',
            '/dev/raw/raw3',
            '/dev/raw/raw4',
            '/dev/raw/raw5';

Diskgroup created.

重啟例項並修改asm例項引數
向引數檔案中新增如下內容
[oracle@dg1 dbs]$ more init+ASM.ora
ASM_DISKGROUPS=data

建立spfile並重啟例項
[oracle@dg1 dbs]$ sqlplus / as sysdba
SQL>create spfile from pfile;
SQL>startup
Total System Global Area  125829120 bytes
Fixed Size                  2019000 bytes
Variable Size              98644296 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted

檢查asm磁碟組狀態
SQL>select name,state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
DATA                           MOUNTED

 

 

3.遷移資料庫到asm
copy資料庫到asm磁碟組
[oracle@dg1 dbs]$ rman target /
RMAN> run
{
     allocate channel dev1 type disk;
     allocate channel dev2 type disk;
     BACKUP AS COPY INCREMENTAL LEVEL 0 DATABASE
           FORMAT '+data'  TAG 'ORA_ASM_MIGRATION;
}

備份當前控制檔案
RMAN> backup current controlfile format '+data/tl.ctl';

備份並恢復spfile檔案到asm磁碟組
RMAN> run
{
   BACKUP AS BACKUPSET SPFILE;
   RESTORE SPFILE TO "+DISK/spfile";
}


關閉資料庫
SQL>shutdown immediate

啟動資料庫到nomount並設定合適的control_files引數
SQL> startup nomount PFILE="/tmp/pfile.ora";
SQL>alter system set control_files='+data/control01.ctl','+data/control02.ctl' scope=spfile;

使用rman恢復控制檔案到asm
RMAN> shutdown immediate
RMAN> startup nomount pfile="/tmp/pfile.ora"
RMAN> restore controlfile from '+data/tl.ctl';
RMAN> alter database mount;
RMAN> switch database to copy;
RMAN> recover database;

開啟資料庫
SQL>alter database open resetlogs;

遷移日誌檔案到asm
SQL>alter database add logfile group 4 '+data' size 50M;
SQL>alter database add logfile group 5 '+data' size 50M;
SQL>alter database add logfile group 6 '+data' size 50M;
SQL>alter system switch logfile;
SQL>alter system switch logfile;
SQL>alter system switch logfile;
SQL>alter system checkpoint;
SQL>alter database drop logfile group 1;
SQL>alter database drop logfile group 2;
SQL>alter database drop logfile group 3;

驗證遷移效果
fuck you>select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.256.830056891
+DATA/orcl/datafile/undotbs1.259.830056963
+DATA/orcl/datafile/sysaux.257.830056891
+DATA/orcl/datafile/users.260.830056973
+DATA/orcl/datafile/example.258.830056923

fuck you>select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/orcl/onlinelog/group_4.268.830090137
+DATA/orcl/onlinelog/group_5.269.830090159
+DATA/orcl/onlinelog/group_6.270.830090171

fuck you>select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DATA/control01.ctl
+DATA/control02.ctl

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20801486/viewspace-1066473/,如需轉載,請註明出處,否則將追究法律責任。

相關文章