手動創建ASM實例并把數據文件從文件系統遷移到ASM上

手動創建ASM實例并把數據文件從文件系統遷移到ASM上

確認操作系統內核版本:
# uname -r
2.6.18-53.el5xen
操作系統
下載所需的rpm包:
oracleasm-2.6.18-53.el5xen-2.0.4-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.3-1.el5.i386.rpm


#  /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface [oracle]:
Default group to own the driver interface [oinstall]:
Start Oracle ASM library driver on boot (y/n) [y]:
Scan for Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [  OK  ]
Scanning the system for Oracle ASMLib disks:              [  OK  ]

使用rawdevice不需創建ASM disk這步:
# oracleasm createdisk d1 /dev/sda3
Writing disk header: done
Instantiating disk: done
查看剛創建的ASM disk:
# oracleasm listdisks
D1

連接數據庫,創建ASM實例:
$ export ORACLE_SID=+ASM
vi /u01/app/oracle/product/10.2.0/db_1/dbs/init+ASM.ora 添加以下內容:
instance_type=ASM

[oracle10@testh dbs]$ sqlplus / as sysdba
SQL> startup nomount;
ORA-29701: unable to connect to Cluster Manager
?上面的??以root用??行$ORACLE_HOME/bin下的localconfig添加CSS服?即可解?
# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized

Cleaning up Network socket directories
Setting up Network socket directories
Adding to inittab
Startup will be queued to init within 30 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
Cluster Synchronization Services is active on these nodes.
       testh
Cluster Synchronization Services is active on all the nodes.
Oracle CSS service is installed and running under init(1M)
再次啟動到nomount下,發現再無錯誤提示:

創建spfile,并使用spfile開啟ASM實例:
SQL> create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/init+ASM.ora';
File created.
啟動ASM實例到nomount:
SQL> startup nomount;
ASM instance started
Total System Global Area   79691776 bytes
Fixed Size                  1217812 bytes
Variable Size              53308140 bytes
ASM Cache                  25165824 bytes
創建diskgroup:
修改asm_diskstring參數,使開機自動尋找ASM磁盤:
SQL> alter system set asm_diskstring='/dev/oracleasm/disks/D*';
System altered.

SQL> create diskgroup dgroup1 external redundancy disk
  2  '/dev/oracleasm/disks/D1' ;
Diskgroup created.

SQL> select disk_number ,mount_status,total_mb from v$asm_disk;
DISK_NUMBER MOUNT_S   TOTAL_MB
----------- ------- ----------
          0 CACHED       48210

針對ORCL部份,10G R1上說必須指定, 從以上測試中可以發現在10G R2中不是必須的.
SQL> drop diskgroup dgroup1;
Diskgroup dropped.

SQL> alter system set asm_diskstring = 'ORCL:D*';
System altered.

SQL> create diskgroup dgroup1 external redundancy disk
  2  'ORCL:D1' ;
Diskgroup created.

測試修改asm_diskstring后如何:
SQL> drop diskgroup dgroup1;
Diskgroup dropped.

SQL> alter system set asm_diskstring = '/dev/oracleasm/disks/D*';
System altered.

SQL> create diskgroup dgroup1 external redundancy disk 'ORCL:D1' ;
create diskgroup dgroup1 external redundancy disk 'ORCL:D1'
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15031: disk specification 'ORCL:D1' matches no disks
ORA-15014: location 'ORCL:D1' is not in the discovery set

SQL> create diskgroup dgroup1 external redundancy disk
  2  '/dev/oracleasm/disks/D1';
Diskgroup created.


配置好ASM實例和DiskGroup后,遷移datafile,tablespace,及DB到ASM上:

轉儲單個表空間:
SQL> alter database open;
Database altered.

RMAN> sql 'alter tablespace TBS_LMAS offline';
sql statement: alter tablespace TBS_LMAS offline


RMAN> backup as copy tablespace TBS_LMAS format '+DGROUP1';
Starting backup at 04-FEB-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=299 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=308 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00072 name=/u02/oradata/qhdb01/tbs_lmas01.dbf
output filename=+DGROUP1/qhdb01/datafile/tbs_lmas.257.710092707 tag=TAG20100204T155827 recid=75 stamp=710092713
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 04-FEB-10

RMAN> switch tablespace TBS_LMAS to copy;
datafile 72 switched to datafile copy "+DGROUP1/qhdb01/datafile/tbs_lmas.257.710092707"

RMAN> recover tablespace TBS_LMAS;
Starting recover at 04-FEB-10
using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 04-FEB-10

RMAN> sql ' alter tablespace TBS_LMAS online';
sql statement:  alter tablespace TBS_LMAS online

RMAN> report schema;
72   128      TBS_LMAS             ***     +DGROUP1/qhdb01/datafile/tbs_lmas.257.710092707

轉儲單個數據文件:
RMAN>  backup as copy datafile 31 format '+DGROUP1';
Starting backup at 04-FEB-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=318 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=324 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00031 name=/u02/oradata/qhdb01/tbs_sfcdata04.dbf
output filename=+DGROUP1/qhdb01/datafile/tbs_sfcdata.258.710098059 tag=TAG20100204T172738 recid=77 stamp=710098082
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
Finished backup at 04-FEB-10

RMAN> switch datafile 31 to copy;
datafile 31 switched to datafile copy "+DGROUP1/qhdb01/datafile/tbs_sfcdata.258.710098059"

RMAN> recover tablespace tbs_sfcdata ;

RMAN> sql ' alter tablespace tbs_sfcdata online';
sql statement:  alter tablespace tbs_sfcdata online

轉儲整個DB的數據文件到ASM:
修改datafile存儲的位置:
SQL> alter system set db_create_file_dest ='+DGROUP1';
System altered.
修改控制文件存儲位置:
SQL>  alter system set control_files ='+DGROUP1/qhdb01/control01.ctl' scope=spfile;
System altered.

關閉數據庫并開啟到nomount下:
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area     218103808 bytes
Fixed Size                     1218580 bytes
Variable Size                 79693804 bytes
Database Buffers             130023424 bytes
Redo Buffers                   7168000 bytes

RMAN> restore controlfile from '/u01/oradata/qhdb01/control01.ctl';
Starting restore at 04-FEB-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=+DGROUP1/qhdb01/control01.ctl
Finished restore at 04-FEB-10
Mount數據庫:
RMAN> alter database mount;
using target database control file instead of recovery catalog
database mounted
轉儲datafile到ASM,用Rman切換DB到ASM上:
RMAN> report schema;

Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    710      SYSTEM               ***     /u02/oradata/qhdb01/system01.dbf
2    510      UNDOTBS1             ***     /u02/oradata/qhdb01/undotbs01.dbf
3    2250     SYSAUX               ***     /u02/oradata/qhdb01/sysaux01.dbf
4    5        USERS                ***     /u02/oradata/qhdb01/users01.dbf
.
.
.
72   128      TBS_LMAS             ***     /u02/oradata/qhdb01/tbs_lmas01.dbf
73   128      NDX_LMAS             ***     /u02/oradata/qhdb01/ndx_lmas01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    46       TEMP                 32767       /u02/oradata/qhdb01/temp01.dbf

啟動數據庫到mount下:
RMAN>  backup as copy database format '+DGROUP1';
RMAN>  switch database to copy;
RMAN> alter database open;
不過聯機日誌和temp表空間不會遷移過去,需要我們手動遷移.

遷移temp表空間有兩種方式可以讓我們選擇:
1,添加tempfile并刪除舊的tempfile.
2,添加temp02表空間,刪除temp表空間.
我選第一種方式:
SQL> alter tablespace temp add tempfile '+DGROUP1' size 50M;
Tablespace altered.

SQL> alter database tempfile '/u02/oradata/qhdb01/temp01.dbf' drop;
Database altered.

遷移redolog,首先要查看狀態是否為INACTIVE,如果不是則需要切換.不可對狀態為active和current操作,
SQL> select GROUP# ,MEMBERS, STATUS from v$log;
    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 INACTIVE
         2          2 INACTIVE
         3          2 CURRENT
SQL> alter database drop logfile group 1;
SQL> alter database add logfile group 1 size 100M;
SQL> alter system switch logfile;
以下省略.

多元化控制文件:
SQL> alter database backup controlfile to '+DGROUP1/qhdb01/control02.ctl';
SQL> alter database backup controlfile to '+DGROUP1/qhdb01/control03.ctl';
SQL> alter system set control_files='+DGROUP1/qhdb01/control01.ctl','+DGROUP1/qhdb01/control02.ctl','+DGROUP1/qhdb01/control03.ctl' scope=spfile;
重新啟動DB即可.
RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    710      SYSTEM               ***     +DGROUP1/qhdb01/datafile/system.263.710162297
2    510      UNDOTBS1             ***     +DGROUP1/qhdb01/datafile/undotbs1.267.710162429
3    2250     SYSAUX               ***     +DGROUP1/qhdb01/datafile/sysaux.259.710161827
4    5        USERS                ***     +DGROUP1/qhdb01/datafile/users.326.710163001
.
.
.
72   128      TBS_LMAS             ***     +DGROUP1/qhdb01/datafile/tbs_lmas.320.710162959
73   128      NDX_LMAS             ***     +DGROUP1/qhdb01/datafile/ndx_lmas.321.710162975

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
2    50       TEMP                 50          +DGROUP1/qhdb01/tempfile/temp.327.710163375

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13023909/viewspace-627059/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/13023909/viewspace-627059/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值