Monday, July 25, 2011

Creating ASM DISK & RAW DISK using Devices

login as: root
root@192.168.1.3's password:
Last login: Wed Jun 29 10:10:50 2011 from 192.168.1.2
[root@linux11g ~]# rpm -qa oracleasm*
oracleasm-support-2.0.3-2
oracleasm-2.6.9-67.0.0.0.1.ELsmp-2.0.3-2
[root@linux11g ~]# cd /software
[root@linux11g software]# ls -l
total 36
drwx------ 2 oracle oinstall 16384 Dec 21 2010 lost+found
-rw-r--r-- 1 root root 12945 Oct 7 2009 oracleasmlib-2.0.4-1.el4.i386.rpm
[root@linux11g software]# rm -ivh oracleasmlib-2.0.4-1.el4.i386.rpm
rm: invalid option -- h
Try `rm --help' for more information.
[root@linux11g software]# rpm -ivh oracleasmlib-2.0.4-1.el4.i386.rpm
Preparing... ########################################### [100%]
1:oracleasmlib ########################################### [100%]
[root@linux11g /]# rpm -qa oracleasm*
oracleasm-support-2.0.3-2
oracleasm-2.6.9-67.0.0.0.1.ELsmp-2.0.3-2
oracleasmlib-2.0.4-1.el4
[root@linux11g ~]# fdisk

Usage: fdisk [-l] [-b SSZ] [-u] device
E.g.: fdisk /dev/hda (for the first IDE disk)
or: fdisk /dev/sdc (for the third SCSI disk)
or: fdisk /dev/eda (for the first PS/2 ESDI drive)
or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)
...
[root@linux11g ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

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

Disk /dev/sdc doesn't contain a valid partition table


[root@linux11g ~]# 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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

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

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@linux11g ~]# fdisk /dev/sdb

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

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

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@linux11g ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 327 2626596 83 Linux
/dev/sdb2 328 632 2449912+ 83 Linux

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

Disk /dev/sdc doesn't contain a valid partition table
[root@linux11g ~]# fdisk /dev/sdc
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): +500M

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

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

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

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@linux11g ~]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 327 2626596 83 Linux
/dev/sdb2 328 632 2449912+ 83 Linux

Disk /dev/sdc: 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/sdc1 1 62 497983+ 83 Linux
/dev/sdc2 63 124 498015 83 Linux
/dev/sdc3 125 186 498015 83 Linux
/dev/sdc4 187 261 602437+ 83 Linux
[root@linux11g ~]# /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) [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 ]
[root@linux11g ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [ OK ]
[root@linux11g ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdb2
Marking disk "/dev/sdb2" as an ASM disk: [ OK ]
[root@linux11g ~]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
[root@linux11g ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
[root@linux11g ~]# raw /dev/sdc1
raw device '/dev/sdc1' is not a character dev
[root@linux11g ~]# raw /dev/raw/raw1 /dev/sdc1
/dev/raw/raw1: bound to major 8, minor 33
[root@linux11g ~]# raw /dev/raw/raw2 /dev/sdc2
/dev/raw/raw2: bound to major 8, minor 34
[root@linux11g ~]# raw /dev/raw/raw3 /dev/sdc3
/dev/raw/raw3: bound to major 8, minor 35
[root@linux11g ~]# raw /dev/raw/raw4 /dev/sdc4
/dev/raw/raw4: bound to major 8, minor 36
[root@linux11g ~]# vi /etc/sysconfig/rawdevices
[root@linux11g ~]# vi /etc/hosts
[root@linux11g ~]# cd $ORACLE_HOME
[root@linux11g ~]# pwd
/root
[root@linux11g ~]# cd /u01/app/oracle/product/11.1.0/db_1/bin/localconfig add
-bash: cd: /u01/app/oracle/product/11.1.0/db_1/bin/localconfig: Not a directory
[root@linux11g ~]# /u01/app/oracle/product/11.1.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.
linux11g
Cluster Synchronization Services is active on all the nodes.
Oracle CSS service is installed and running under init(1M)
[root@linux11g ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.0G 616M 87% /
/dev/sda1 494M 17M 453M 4% /boot
none 506M 254M 252M 51% /dev/shm
/dev/sda3 2.0G 36M 1.9G 2% /software
/dev/sda6 494M 11M 458M 3% /tmp
/dev/sda7 15G 13G 1.3G 92% /u01
[root@linux11g ~]# umount tmpfs
umount: tmpfs: not found
[root@linux11g ~]# df -k /dev/shm
Filesystem 1K-blocks Used Available Use% Mounted on
none 517280 259444 257836 51% /dev/shm
[root@linux11g ~]# umount none
[root@linux11g ~]# mount -t tmpfs shmfs -o size=1200m /dev/shm
[root@linux11g ~]# df -k /dev/shm
Filesystem 1K-blocks Used Available Use% Mounted on
none 1228800 0 1228800 0% /dev/shm
[root@linux11g ~]# vi /etc/fstab
Add the below in fstab file:-

tmpfs /dev/shm tmpfs size=1200m 0 0

[root@linux11g etc]# chown oracle:dba /dev/raw/raw[1-4]
[root@linux11g etc]# ls -l /dev/raw*
crw------- 1 root root 162, 0 Jul 26 2011 /dev/rawctl

/dev/raw:
total 0
crw-rw---- 1 oracle dba 162, 1 Jul 26 08:32 raw1
crw-rw---- 1 oracle dba 162, 2 Jul 26 08:32 raw2
crw-rw---- 1 oracle dba 162, 3 Jul 26 08:32 raw3
crw-rw---- 1 oracle dba 162, 4 Jul 26 08:32 raw4
[root@linux11g etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.0G 616M 87% /
/dev/sda1 494M 17M 453M 4% /boot
none 1.2G 410M 791M 35% /dev/shm
/dev/sda3 2.0G 36M 1.9G 2% /software
/dev/sda6 494M 11M 458M 3% /tmp
/dev/sda7 15G 13G 1.3G 92% /u01
shmfs 1.2G 410M 791M 35% /dev/shm
[root@linux11g etc]# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 327 2626596 83 Linux
/dev/sdb2 328 632 2449912+ 83 Linux

Disk /dev/sdc: 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/sdc1 1 62 497983+ 83 Linux
/dev/sdc2 63 124 498015 83 Linux
/dev/sdc3 125 186 498015 83 Linux
/dev/sdc4 187 261 602437+ 83 Linux
[root@linux11g etc]# su - oracle
[oracle@linux11g ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 26-JUL-2011 10:05:22

Copyright (c) 1991, 2007, Oracle. All rights reserved.

Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.1.0.6.0 - Production
System parameter file is /u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/linux11g/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux11g.manzoor.com)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.1.0.6.0 - Production
Start Date 26-JUL-2011 10:05:22
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/linux11g/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux11g.manzoor.com)(PORT=1521)))
The listener supports no services
The command completed successfully

[oracle@linux11g ~]$ tnsping test11g

TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 26-JUL-2011 10:05:39

Copyright (c) 1997, 2007, Oracle. All rights reserved.

Used parameter files:
/u01/app/oracle/product/11.1.0/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = linux11g.manzoor.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test11g)))
OK (0 msec)
[oracle@linux11g ~]$ sqlplus sys/admin@test11g as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Jul 26 10:05:47 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> create tablespace manzoor datafile '+DATA1' size 100m;

Tablespace created.

SQL> create tablespace usingraw datafile '/dev/raw/raw3' size 400m;

Tablespace created.

SQL> drop tablespace usingraw including contents and datafiles;

Tablespace dropped.

SQL> create tablespace usingraw_1 datafile '/dev/raw/raw3' size 400m;

Tablespace created.

SQL> create tablespace usingraw_2 datafile '/dev/raw/raw4' size 400m;

Tablespace created.

SQL> exit

[oracle@linux11g ~]$ rman target /

Recovery Manager: Release 11.1.0.6.0 - Production on Tue Jul 26 10:04:43 2011

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

connected to target database: TEST11G (DBID=904564690)

RMAN> backup tablespace usingraw_1;

Starting backup at 26-JUL-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=131 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=130 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=129 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=126 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/dev/raw/raw3
channel ORA_DISK_1: starting piece 1 at 26-JUL-11
channel ORA_DISK_1: finished piece 1 at 26-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/TEST11G/backupset/2011_07_26/o1_mf_nnndf_TAG20110726T100450_72wjzlfp_.bkp tag=TAG20110726T100450 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-JUL-11

RMAN> sql 'alter tablespace USINGRAW_1 offline immediate';

sql statement: alter tablespace USINGRAW_1 offline immediate

RMAN> restore tablespace USINGRAW_1;

Starting restore at 26-JUL-11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to /dev/raw/raw3
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/TEST11G/backupset/2011_07_26/o1_mf_nnndf_TAG20110726T100450_72wjzlfp_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/TEST11G/backupset/2011_07_26/o1_mf_nnndf_TAG20110726T100450_72wjzlfp_.bkp tag=TAG20110726T100450
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 26-JUL-11


RMAN> recover tablespace USINGRAW_1;

Starting recover at 26-JUL-11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 26-JUL-11

RMAN> sql 'alter tablespace USINGRAW_1 online';

sql statement: alter tablespace USINGRAW_1 online

RMAN> backup tablespace manzoor;

Starting backup at 26-JUL-11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA1/test11g/datafile/manzoor.256.757504713
channel ORA_DISK_1: starting piece 1 at 26-JUL-11
channel ORA_DISK_1: finished piece 1 at 26-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/TEST11G/backupset/2011_07_26/o1_mf_nnndf_TAG20110726T102018_72wkwk70_.bkp tag=TAG20110726T102018 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-JUL-11

RMAN> sql 'alter tablespace manzoor offline immediate';

sql statement: alter tablespace manzoor offline immediate

RMAN> restore tablespace manzoor;

Starting restore at 26-JUL-11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to +DATA1/test11g/datafile/manzoor.256.757504713
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/TEST11G/backupset/2011_07_26/o1_mf_nnndf_TAG20110726T102018_72wkwk70_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/TEST11G/backupset/2011_07_26/o1_mf_nnndf_TAG20110726T102018_72wkwk70_.bkp tag=TAG20110726T102018
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 26-JUL-11

RMAN> recover tablespace manzoor;

Starting recover at 26-JUL-11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 26-JUL-11

RMAN> sql 'alter tablespace manzoor online';

sql statement: alter tablespace manzoor online

RMAN> exit

No comments:

Post a Comment