Wednesday, January 9, 2008

Migration ASM from /dev/sdc to /dev/sdb

1. Startup ASM on sdc
[root@oracle01 ~]# fdisk -l /dev/sdc

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 487 3911796 83 Linux
/dev/sdc2 488 974 3911827+ 83 Linux
[root@oracle01 ~]# su - oracle
[oracle@oracle01.myserver.com /home/oracle]
$ export ORACLE_SID=+ASM
[oracle@oracle01.myserver.com /home/oracle]
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 9 22:10:09 2008

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

Connected to an idle instance.

SQL> startup mount
ASM instance started

Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@oracle01.myserver.com /home/oracle]
$ asmcmd
ASMCMD> lsdg
State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED NORMAL N N 512 4096 1048576 7640 5284 0 2642 0 DATA/
ASMCMD> exit

2. Create filesystem onto sdb and do a dd sdc[1-2] to files (data_lun1, data_lun2)

[root@oracle01 ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 83 Linux
[root@oracle01 ~]# mkfs /dev/sdb1
mke2fs 1.35 (28-Feb-2004)
max_blocks 2683489280, rsv_groups = 81894, rsv_gdb = 639
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2620595 blocks
131029 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
inode.i_blocks = 46016, i_size = 4243456
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@oracle01 ~]# mount /dev/sdb1 /mydata/
[root@oracle01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
7.3G 3.5G 3.5G 51% /
/dev/sda1 99M 9.0M 85M 10% /boot
none 126M 0 126M 0% /dev/shm
/dev/sdb1 9.9G 23M 9.4G 1% /mydata
[root@oracle01 ~]# dd if=/dev/sdc1 of=/mydata/data_lun1 bs=1M
3820+1 records in
3820+1 records out
[root@oracle01 ~]# dd if=/dev/sdc2 of=/mydata/data_lun2 bs=1M
3820+1 records in
3820+1 records out

3. Shutdown ASM

[root@oracle01 ~]# su - oracle
[oracle@oracle01.myserver.com /home/oracle]
$ export ORACLE_SID=+ASM
[oracle@oracle01.myserver.com /home/oracle]
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 9 22:20:36 2008

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown

4. Delete /dev/sdc1 and /dev/sdc2. Create a filesystem of 9.9G.

[root@oracle01 ~]# fdisk /dev/sdc

The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305): 1305

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@oracle01 ~]# partprobe
Warning: Unable to open /dev/hdc read-write (Read-only file system). /dev/hdc has been opened read-only.
[root@oracle01 ~]# mkfs /dev/sdc1
mke2fs 1.35 (28-Feb-2004)
max_blocks 2683489280, rsv_groups = 81894, rsv_gdb = 639
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2620595 blocks
131029 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
inode.i_blocks = 46016, i_size = 4243456
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@oracle01 ~]# mkdir /mydata2
[root@oracle01 ~]# mount /dev/sdc1 /mydata2
[root@oracle01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
7.3G 3.5G 3.5G 51% /
/dev/sda1 99M 9.0M 85M 10% /boot
none 126M 0 126M 0% /dev/shm
/dev/sdb1 9.9G 7.5G 1.9G 81% /mydata
/dev/sdc1 9.9G 23M 9.4G 1% /mydata2

5. Move data_lun[1-2] to this filesystem /mydata2

[root@oracle01 ~]# cp /mydata/* /mydata2/
cp: omitting directory `/mydata/lost+found'
[root@oracle01 ~]# cd /mydata2
[root@oracle01 mydata2]# ls -sh
total 7.5G
3.8G data_lun1 3.8G data_lun2 16K lost+found


6. Creating /dev/sdb[1-2]

[root@oracle01 mydata2]# fdisk /dev/sdb

The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 83 Linux

Command (m for help): d
Selected partition 1

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

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

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

Calling ioctl() to re-read partition table.

7. dd the data_lun[1-2] back to /dev/sdb[1-2]

[root@oracle01 mydata2]# fdisk -l /dev/sdb

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 487 3911796 83 Linux
/dev/sdb2 488 974 3911827+ 83 Linux

[root@oracle01 mydata2]# dd if=/mydata2/data_lun1 of=/dev/sdb1 bs=1M
3820+1 records in
3820+1 records out
[root@oracle01 mydata2]# dd if=/mydata2/data_lun2 of=/dev/sdb2 bs=1M
3820+1 records in
3820+1 records out
[root@oracle01 asm]# ln -s /dev/sdb1 /u02/oradata/asm/data_lun1
[root@oracle01 asm]# ln -s /dev/sdb2 /u02/oradata/asm/data_lun2
[root@oracle01 asm]# chown -R oracle:oinstall /u02/oradata/asm/data_lun*
[root@oracle01 asm]# chmod -R 660 /u02/oradata/asm/data_lun*

8. Start and mount ASM on /dev/sdb[1-2]

[root@oracle01 asm]# su - oracle
[oracle@oracle01.myserver.com /home/oracle]
$ export ORACLE_SID=+ASM
[oracle@oracle01.myserver.com /home/oracle]
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 9 22:58:11 2008

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

Connected to an idle instance.

SQL> startup mount
ASM instance started

Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@oracle01.myserver.com /home/oracle]
$ asmcmd
ASMCMD> lsdg
State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED NORMAL N N 512 4096 1048576 7640 5284 0 2642 0 DATA/
ASMCMD>

9. Start Database instance

[oracle@oracle01.myserver.com /home/oracle]
$ export ORACLE_SID=testdb
[oracle@oracle01.myserver.com /home/oracle]
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 9 23:00:00 2008

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

Connected to an idle instance.

SQL> startup open
ORACLE instance started.

Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 71305460 bytes
Database Buffers 92274688 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.

SQL>