Chinaunix首页 | 论坛 | 博客
  • 博客访问: 561572
  • 博文数量: 49
  • 博客积分: 8051
  • 博客等级: 中将
  • 技术积分: 1846
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-27 12:05
文章分类

全部博文(49)

文章存档

2011年(1)

2010年(4)

2009年(18)

2008年(26)

我的朋友

分类: Oracle

2009-03-26 17:01:55

格式化ASM分区,必须选P,# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 910 7309543+ 83 Linux
/dev/sda2 911 1170 2088450 82 Linux swap
/dev/sda3 1171 2610 11566800 83 Linux
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 512 524272 83 Linux
Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 391 3140676 83 Linux
Disk /dev/sdd: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 391 3140676 83 Linux
Disk /dev/sde: 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/sde1 1 261 2096451 83 Linux

安装ASM对应的包

Install oracleasmlib package. Download the ASM library from OTN and install the ASM RPM as the
root user.
# rpm -Uvh oracleasmlib-2.0.2-1.i386.rpm
Preparing...
########################################### [100%]
1:oracleasmlib
########################################### [100%]
At this stage, you should already have the following ASM packages installed.
[root@rac1 swdl]# rpm -qa | grep oracleasm
oracleasm-support-2.0.3-2
oracleasm-2.6.9-42.0.0.0.1.ELsmp-2.0.3-2
oracleasmlib-2.0.2-1

映射相应磁盘用于创建ASM组
Map raw devices for ASM disks. A raw device mapping is required only if you are planning on
creating ASM disks using standard Linux I/O. An alternative to creating ASM disks is to use the ASM
library driver provided by Oracle. You will configure ASM disks using ASM library driver later.
Perform the following tasks to map the raw devices to the shared partitions created earlier. The raw
devices have to bind with the block devices each time a cluster node boots.
Add the following lines in /etc/sysconfig/rawdevices.
/etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdc1
/dev/raw/raw2 /dev/sdd1
/dev/raw/raw3 /dev/sde1
To make the mapping effective immediately, execute the following commands as the root user:
# /sbin/service rawdevices restart
Assigning devices:
/dev/raw/raw1 --> /dev/sdc1
/dev/raw/raw1: bound to major 8, minor 33
/dev/raw/raw2 --> /dev/sdd1
/dev/raw/raw2: bound to major 8, minor 49
/dev/raw/raw3 --> /dev/sde1
/dev/raw/raw3: bound to major 8, minor 65
done
# chown oracle:dba /dev/raw/raw[1-3]
# chmod 660 /dev/raw/raw[1-3]
# ls -lat /dev/raw/raw*
crw-rw---- 1 oracle dba 162, 3 Nov 4 07:04 /dev/raw/raw3
crw-rw---- 1 oracle dba 162, 2 Nov 4 07:04 /dev/raw/raw2
crw-rw---- 1 oracle dba 162, 1 Nov 4 07:04 /dev/raw/raw1
As the oracle user, execute

rac1-> ln -sf /dev/raw/raw1 /u01/oradata/devdb/asmdisk1
rac1-> ln -sf /dev/raw/raw2 /u01/oradata/devdb/asmdisk2
rac1-> ln -sf /dev/raw/raw3 /u01/oradata/devdb/asmdisk3
Modify /etc/udev/permissions.d/50-udev.permissions. Raw devices are remapped on boot. The
ownership of the raw devices will change to the root user by default upon boot. ASM will have problem
accessing the shared partitions if the ownership is not the oracle user. Comment the original line,
“raw/*:root:disk:0660” in /etc/udev/permissions.d/50-udev.permissions and add a new line,
“raw/*:oracle:dba:0660.”
/etc/udev/permissions.d/50-udev.permissions
# raw devices
ram*:root:disk:0660
#raw/*:root:disk:0660
raw/*:oracle:dba:0660

在操作系统级别配置ASM
 Configure Oracle Automatic Storage Management (ASM)
Oracle ASM is tightly integrated with Oracle Database and works with Oracle’s suite of data
management tools. It simplifies database storage management and provides the performance of raw disk
I/O.
Configure ASMLib. Configure the ASMLib as the root user on both nodes.
# /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 []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]


Create ASM disks. Create the ASM disks on any one node as the root user.
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [ OK ]
Verify that the ASM disks are visible from every node.
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3


通过DBCA创建ASM instance

Storage Options:
Select Automatic Storage Management (ASM).
13.
Create ASM Instance:
SYS password: .
Select Create initialization parameter file (IFILE).
14.
ASM Disk Groups:
Click on Create New.
15.
Create Disk Group:
Create two disk groups – DG1 and RECOVERYDEST.
Disk Group Name: DG1
Select Normal redundancy.
Select Disk Path, ORCL:VOL1 and ORCL:VOL2. If you have configured the ASM disks
using standard Linux I/O, you will select /u01/oradata/devdb/asmdisk1 and
/u01/oradata/devdb/asmdisk2 instead.
Click on OK.
16.

开始从文件系统到ASM的移植
note 252219.1
RMAN> connect target 

connected to target database: asmmy (not mounted)

RMAN> RESTORE CONTROLFILE FROM '/u01/app1/oracle/asmmy/control01.ctl';

Starting restore at 25-MAR-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=+DG1/control01.ctl
output filename=+DG1/control02.ctl
output filename=+DG1/control03.ctl
Finished restore at 25-MAR-09

RMAN> BACKUP AS COPY DATABASE FORMAT '+DG1';

Starting backup at 25-MAR-09
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/app1/oracle/asmmy/system01.dbf
output filename=+DG1/asmmy/datafile/system.259.682423803 tag=TAG20090325T101000 recid=2 stamp=682423850
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:57
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u01/app1/oracle/asmmy/sysaux01.dbf
output filename=+DG1/asmmy/datafile/sysaux.260.682423863 tag=TAG20090325T101000 recid=3 stamp=682423891
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
channel ORA_DISK_1: starting datafile copy
input datafile fno=00006 name=/u01/app1/oracle/asmmy/expasm.dbf
output filename=+DG1/asmmy/datafile/expasm.261.682423901 tag=TAG20090325T101000 recid=4 stamp=682423922
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:27
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app1/oracle/asmmy/example01.dbf
output filename=+DG1/asmmy/datafile/example.262.682423931 tag=TAG20090325T101000 recid=5 stamp=682423943
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u01/app1/oracle/asmmy/undotbs01.dbf
output filename=+DG1/asmmy/datafile/undotbs1.263.682423949 tag=TAG20090325T101000 recid=6 stamp=682423960
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/app1/oracle/asmmy/users01.dbf
output filename=+DG1/asmmy/datafile/users.264.682423967 tag=TAG20090325T101000 recid=7 stamp=682423968
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+DG1/asmmy/controlfile/backup.265.682423977 tag=TAG20090325T101000 recid=8 stamp=682423980
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08
Finished backup at 25-MAR-09

RMAN> SWITCH DATABASE TO COPY
2> ;

datafile 1 switched to datafile copy "+DG1/asmmy/datafile/system.259.682423803"
datafile 2 switched to datafile copy "+DG1/asmmy/datafile/undotbs1.263.682423949"
datafile 3 switched to datafile copy "+DG1/asmmy/datafile/sysaux.260.682423863"
datafile 4 switched to datafile copy "+DG1/asmmy/datafile/users.264.682423967"
datafile 5 switched to datafile copy "+DG1/asmmy/datafile/example.262.682423931"
datafile 6 switched to datafile copy "+DG1/asmmy/datafile/expasm.261.682423901"

RMAN> run{
2> set newname for tempfile 1 to '+DG1';
3> switch tempfile all;
4> }

executing command: SET NEWNAME

renamed temporary file 1 to +DG1 in control file

RMAN> alter database open;

database opened
RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT rows
ORACLE error from target database: 
ORA-06502: PL/SQL: numeric or value error: character to number conversion error



SQL> conn / as sysdba;  
Connected.
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DG1' to group 1;

Database altered.

SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DG1' to group 2;

Database altered.

SQL> ALTER DATABASE DROP LOGFILE MEMBER 

SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DG1' to group 3;

Database altered.


开始从ASM到文件系统的移植。
from ASM to file system

[oraasm@rac1 dbs]$ export ORACLE_SID=+ASM
[oraasm@rac1 dbs]$ sqlplus '/as sysdba';

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 25 16:17:19 2009

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

Connected to an idle instance.

SQL> startup;
ASM instance started

Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted

change initASMMY.ora 

RMAN> connect target

connected to target database: asmmy (not mounted)


RMAN> RESTORE CONTROLFILE FROM '+DG1/control01.ctl';

Starting restore at 25-MAR-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=/u01/app1/oracle/asmmy/control01.ctl
output filename=/u01/app1/oracle/asmmy/control02.ctl
output filename=/u01/app1/oracle/asmmy/control03.ctl
Finished restore at 25-MAR-09

SQL> alter database mount;

Database altered.


RMAN> connect target

connected to target database: ASMMY (DBID=167034454, not open)

RMAN> BACKUP AS COPY DATABASE format '/u01/app1/oracle/asmmy/%U';

Starting backup at 25-MAR-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=+DG1/asmmy/datafile/system.259.682423803
output filename=/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-SYSTEM_FNO-1_08kaql4h tag=TAG20090325T165335 recid=15 stamp=682448069
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:56
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=+DG1/asmmy/datafile/sysaux.260.682423863
output filename=/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-SYSAUX_FNO-3_09kaql6a tag=TAG20090325T165335 recid=16 stamp=682448098
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26
channel ORA_DISK_1: starting datafile copy
input datafile fno=00006 name=+DG1/asmmy/datafile/expasm.261.682423901
output filename=/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-EXPASM_FNO-6_0akaql74 tag=TAG20090325T165335 recid=17 stamp=682448118
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=+DG1/asmmy/datafile/example.262.682423931
output filename=/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-EXAMPLE_FNO-5_0bkaql7v tag=TAG20090325T165335 recid=18 stamp=682448138
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=+DG1/asmmy/datafile/undotbs1.263.682423949
output filename=/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-UNDOTBS1_FNO-2_0ckaql8f tag=TAG20090325T165335 recid=19 stamp=682448149
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=+DG1/asmmy/datafile/users.264.682423967
output filename=/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-USERS_FNO-4_0dkaql8n tag=TAG20090325T165335 recid=20 stamp=682448152
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=/u01/app1/oracle/asmmy/cf_D-ASMMY_id-167034454_0ekaql8p tag=TAG20090325T165335 recid=21 stamp=682448153
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 25-MAR-09

RMAN> SWITCH DATABASE TO COPY;

datafile 1 switched to datafile copy "/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-SYSTEM_FNO-1_08kaql4h"
datafile 2 switched to datafile copy "/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-UNDOTBS1_FNO-2_0ckaql8f"
datafile 3 switched to datafile copy "/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-SYSAUX_FNO-3_09kaql6a"
datafile 4 switched to datafile copy "/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-USERS_FNO-4_0dkaql8n"
datafile 5 switched to datafile copy "/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-EXAMPLE_FNO-5_0bkaql7v"
datafile 6 switched to datafile copy "/u01/app1/oracle/asmmy/data_D-ASMMY_I-167034454_TS-EXPASM_FNO-6_0akaql74"


RMAN> run {
2> set newname for tempfile 1 to '/u01/app1/oracle/asmmy/tem01.dbf';
3> switch tempfile all; 
4> }

executing command: SET NEWNAME

renamed temporary file 1 to /u01/app1/oracle/asmmy/tem01.dbf in control file


SQL> ALTER DATABASE ADD LOGFILE MEMBER '/u01/app1/oracle/asmmy/redo01.log ' to group 2;

Database altered.

SQL> ALTER DATABASE ADD LOGFILE MEMBER '/u01/app1/oracle/asmmy/redo03.log' to group 3;

Database altered.

SQL> ALTER DATABASE ADD LOGFILE MEMBER '/u01/app1/oracle/asmmy/redo04.log' to group 4;


SQL> alter system switch logfile;

System altered.


SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter database drop logfile member '+DG1/asmmy/onlinelog/group_3.269.682425609';

Database altered.

SQL> alter database drop logfile member '+DG1/asmmy/onlinelog/group_4.267.682426255';

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> alter database drop logfile member '+DG1/asmmy/onlinelog/group_2.268.682425175';

Database altered.








阅读(1572) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~