ASM -
ASM i.e. Automatic Storage Management simplifies administration of Oracle related files by allowing the administrator to reference disk groups rather than individual disks and files, which ASM manages internally. On Linux, ASM is capable of referencing disks as raw devices or by using the ASMLib software.
==================================================================================================================
In this article, we assume that you have configured a RHEL system along with Oracle Database Software on it. To install Oracle 10g Database Software, you can follow this link. Do not create any database now, only install the Oracle Software.
We have configured the system with below details,
Hostname - asm10g IP address eth0 - 192.168.0.4 Gateway eth0 - 192.168.0.1
Also we have 3 raw devices available for ASM configuration (sdb, sdc, sdd). We will see the configuration of both, ASMLib as well as RAW devces in the below article.
==================================================================================================================
1) Partition the Disks:
# fdisk /dev/sdb
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):
Using default value 1305
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):
Using default value 1305
Command (m for help): w
The partition table has been altered!
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Syncing disks.
Always create the raw devices as primary partition and allocate the whole disk. Don’t make multiple primary partitions on a single disk for ASM installation. It might not work properly.
Do the above steps for ‘/dev/sdc’ and ‘/dev/sdd’ device also.
To update the kernel, run the below command,
# partprobe
# partprobe
Now check whether you are able to see the newly created raw devices.
# fdisk -l
# fdisk -l
==================================================================================================================
2) ASMLib Configuration:
- Determine your kernel version and accordingly dowload the ASMLib software from OTN.
# uname -r
# uname -r
- The below packages were downloaded which were suitable for my kernel.
oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.7-1.el5.i386.rpm
oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.7-1.el5.i386.rpm
- Install the packages.
# rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm oracleasmlib-2.0.4-1.el5.i386.rpm oracleasm-support-2.1.7-1.el5.i386.rpm
# rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm oracleasmlib-2.0.4-1.el5.i386.rpm oracleasm-support-2.1.7-1.el5.i386.rpm
- Now configure the ASM kernel module.
# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
# /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.
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 ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module “oracleasm”: [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
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 ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module “oracleasm”: [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
- Once the ASM kernel module is configured, now create the disks.
# /etc/init.d/oracleasm createdisk DATAGRP /dev/sdb1
Marking disk “/dev/sdb1″ as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk DATAGRP /dev/sdb1
Marking disk “/dev/sdb1″ as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk ARCHGRP /dev/sdc1
Marking disk “/dev/sdc1″ as an ASM disk: [ OK ]
Marking disk “/dev/sdc1″ as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk LOGGRP /dev/sdd1
Marking disk “/dev/sdd1″ as an ASM disk: [ OK ]
Marking disk “/dev/sdd1″ as an ASM disk: [ OK ]
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
Scanning system for ASM disks: [ OK ]
- To list the disks configured.
# /etc/init.d/oracleasm listdisks
ARCHGRP
DATAGRP
LOGGRP
# /etc/init.d/oracleasm listdisks
ARCHGRP
DATAGRP
LOGGRP
The ASM disks are now ready for use.
==================================================================================================================
==================================================================================================================
3) RAW Device Setup:
- Edit the file ‘/etc/sysconfig/rawdevices’, and add the below lines:
# vi /etc/sysconfig/rawdevices
# vi /etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdc1
/dev/raw/raw3 /dev/sdd1
/dev/raw/raw2 /dev/sdc1
/dev/raw/raw3 /dev/sdd1
- Now restart the service.
# service rawdevices restart
# service rawdevices restart
Assigning devices: /dev/raw/raw1 --> /dev/sdb1 /dev/raw/raw1: bound to major 8, minor 17 /dev/raw/raw2 --> /dev/sdc1 /dev/raw/raw2: bound to major 8, minor 33 /dev/raw/raw3 --> /dev/sdd1 /dev/raw/raw3: bound to major 8, minor 49 done
- Change the ownership and permissions of raw devices
# chown oracle.oinstall /dev/raw/raw1
# chown oracle.oinstall /dev/raw/raw2
# chown oracle.oinstall /dev/raw/raw3
# chown oracle.oinstall /dev/raw/raw1
# chown oracle.oinstall /dev/raw/raw2
# chown oracle.oinstall /dev/raw/raw3
# chmod 600 /dev/raw/raw1
# chmod 600 /dev/raw/raw2
# chmod 600 /dev/raw/raw3
# chmod 600 /dev/raw/raw2
# chmod 600 /dev/raw/raw3
The ASM raw disks are configured. You can start your database creation now.
==================================================================================================================
==================================================================================================================
4) Create ASM Instance:
- Creation of the ASM instance is the same, whether you make use of ASMLib or RAW devices. When using ASMLib, the candidate disks are listed using the stamp associated with them, while the raw devices are listed using their device name.
- Login as oracle user and start Database Configuration Assistant.
$ dbca
$ dbca
- WELCOME Screen
Click on Next to continue.
- OPERATIONS Screen
Select ‘Configure Automatic Storage Management’ option click on Next to continue.
A warning message will get displayed saying that ‘Oracle Cluster Syncronization Service (CSS)’ is not currently running.
Open a new terminal and login as root.
Execute the command shown in the warning window.
# /u01/app/oracle/product/10.2.0/db/bin/localconfig add
Execute the command shown in the warning window.
# /u01/app/oracle/product/10.2.0/db/bin/localconfig add
When the execution is complete, click on OK button and again click Next to continue.
- CREATE ASM INSTANCE Screen
Enter password that will be used for ASM instance.
Click on Next.
Click on Next.
A confirmation window will get open for creating the ASM instance.
Click on OK and ASM instance will get created as shown in below pic.
Click on OK and ASM instance will get created as shown in below pic.
- ASM DISK GROUPS Screen
Initially the window will be blank as shown above.
Click on “Create New” and CREATE DISK GROUP screen will get open.
Enter Disk Group Name: DATAGRP
Select Redundancy: External
Enter Disk Group Name: DATAGRP
Select Redundancy: External
- When using ASMLib, the Disk Path column will contain values as given below
ORCL:DATAGRP
ORCL:ARCHGRP
ORCL:LOGGRP
ORCL:DATAGRP
ORCL:ARCHGRP
ORCL:LOGGRP
- When using raw devices, the Disk Path column will contain candidate disks
/dev/raw/raw1
/dev/raw/raw2
/dev/raw/raw3
/dev/raw/raw1
/dev/raw/raw2
/dev/raw/raw3
Since we are using raw devices, select 1st raw device i.e. /dev/raw/raw1
Click on OK and the ASM Disk Creation will start.
Click on OK and the ASM Disk Creation will start.
- Similarly create ARCHGRP and LOGGRP disk groups as shown in above steps.
- Once all disk groups are configured, you should see 3 disk groups similar to the below pic.
Now on ASM DISK GROUPS Screen, click on Finish. You will get a popup window. Click on No to continue.
- Now the ASM instance has been configured. You can check the ASM instance running as below.
$ ps -ef | grep pmon
$ ps -ef | grep pmon
==================================================================================================================
5) Listener Configuration:
- Before starting with the database creation, configure the listener and register ASM instance with it.
$ netca
$ netca
- If you don’t see the ASM instance register with the listener service, then do the below steps
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> alter system register;
SQL> exit
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> alter system register;
SQL> exit
$ lsnrctl status
Now you will see that the ASM instance has been registered with the listener service.
==================================================================================================================
Now you will see that the ASM instance has been registered with the listener service.
==================================================================================================================
6) Create Database:
- Start DBCA.
$ dbca
$ dbca
- WELCOME Screen
Click on Next to continue.
- OPERATIONS Screen
Select “Create a Database” and click on Next to continue.
- DATABASE TEMPLATES Screen
Click on Next to continue.
- DATABASE IDENTIFICATION Screen
Enter the DB name and click on Next to continue.
- MANAGEMENT OPTIONS Screen
If you want to configure your database with Enterprise Manager, then check the option “Configure the database with Enterprise Manager” else uncheck it.
Click on Next to continue.
Click on Next to continue.
- DATABASE CREDENTIALS Screen
Enter common password for all accounts and click on Next to continue.
- STORAGE OPTIONS Screen
Select “Automatic Storage Management (ASM)”
Click on Next to continue. It will prompt you for sys password of ASM.
Click on Next to continue. It will prompt you for sys password of ASM.
Enter the password that you configured while creating ASM instance.
- ASM DISK GROUPS Screen
Select all the disk groups click on Next.
- DATABASE FILE LOCATIONS Screen
Select “Use Oracle-Managed Files” and enter path as +DATAGRP
Click on “Multiplex Redo Logs and Control Files…” and enter path as shown below,
Click on “Multiplex Redo Logs and Control Files…” and enter path as shown below,
- RECOVERY CONFIGURATION Screen
If you want to enable Flash logs, check the “Specify Flash Recovery Area” and enter the details as shown.
If you want to enable archiving mode, select “Enable Archiving” and click “Edit Archive Mode Parameters”. Enter the path as shown below.
If you want to enable archiving mode, select “Enable Archiving” and click “Edit Archive Mode Parameters”. Enter the path as shown below.
Click on Next to continue.
- DATABASE CONTENT Screen
Click on Next to continue.
- INITIALIZATION PARAMETERS Screen
Click on Character Sets tab,
Select Character Set as Unicode (AL32UTF8).
Select Default Date Format as India.
Click on Next to continue.
Select Character Set as Unicode (AL32UTF8).
Select Default Date Format as India.
Click on Next to continue.
- DATABASE STORAGE Screen
You can see the OMF file format for datafiles, controlfiles and redolog files. Click on Next to continue.
- CREATION OPTIONS Screen
By default, the “Create Database” option is selected.
If you want to create scripts, select the “Generate Database Creation Scripts” option.
Click on Finish.
If you want to create scripts, select the “Generate Database Creation Scripts” option.
Click on Finish.
- CONFIRMATION Screen
Click on OK to start the installation.
- GENERATION OF SCRIPTS Screen
Since we had selected the option to generate the database creation scripts, before starting the database creation the scripts get generated.
Click on OK.
Click on OK.
- DATABASE CREATION PROGRESS Screen
You can observe the Database creation.
- END OF DATABASE CREATION Screen
- The Database has been created using ASM as storage option. You can verify the location of database files as below,
$ ps -ef | grep pmon
$ ps -ef | grep lsn
$ export ORACLE_SID=asmdb
$ sqlplus / as sysdba
$ sqlplus / as sysdba
SQL> select name from v$datafile;
SQL> select name from v$tempfile;
SQL> select name from v$controlfile;
SQL> select member from v$logfile;
SQL> show parameter log_archive_file_dest;
SQL> show parameter db_recover;
==================================================================================================================
==================================================================================================================
7) Switching from Raw Devices to ASMLib:
If you prefer to use ASMLIB rather than RAW devices, follow the below steps. This is just an extra activity which you might try.
- Shutdown any databases using the ASM instance, but leave the ASM instance itself running.
- Now connect to the ASM instance.
- Now connect to the ASM instance.
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
$ sqlplus / as sysdba
- Alter the ASM disk string to exclude the raw devices used earlier, then shutdown the ASM instance.
SQL> ALTER SYSTEM SET asm_diskstring = ‘ORCL:DISK*’ SCOPE=SPFILE;
System altered.
System altered.
SQL> SHUTDOWN IMMEDIATE;
ASM diskgroups dismounted
ASM instance shutdown
SQL>
ASM diskgroups dismounted
ASM instance shutdown
SQL>
- At this point the disks will not be used by ASM because they are not stamped. Now issue the renamedisk command as the root user for each disk.
# /etc/init.d/oracleasm renamedisk /dev/sdb1 DISK1
Renaming disk “/dev/sdb1″ to “VOL1″: [ OK ]
# /etc/init.d/oracleasm renamedisk /dev/sdb1 DISK1
Renaming disk “/dev/sdb1″ to “VOL1″: [ OK ]
# /etc/init.d/oracleasm renamedisk /dev/sdc1 DISK2
Renaming disk “/dev/sdc1″ to “VOL2″: [ OK ]
Renaming disk “/dev/sdc1″ to “VOL2″: [ OK ]
# /etc/init.d/oracleasm renamedisk /dev/sdd1 DISK3
Renaming disk “/dev/sdd1″ to “VOL3″: [ OK ]
Renaming disk “/dev/sdd1″ to “VOL3″: [ OK ]
Notice, the stamp matches the discovery string set earlier. The ASM instance can now be started.
SQL> STARTUP
ASM instance started
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>
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL>
The ASM instance is now using ASMLib, rather than raw devices. All dependent databases can now be started.
==================================================================================================================
==================================================================================================================
8) Switching from ASMLib to Raw Devices:
- Shutdown any databases using the ASM instance, but leave the ASM instance itself running.
- Now connect to the ASM instance.
- Now connect to the ASM instance.
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
$ sqlplus / as sysdba
- Alter the ASM disk string to match the raw devices that you want to use, then shutdown the ASM instance.
SQL> ALTER SYSTEM SET asm_diskstring = ‘/dev/raw/raw*’ SCOPE=SPFILE;
System altered.
System altered.
SQL> SHUTDOWN IMMEDIATE;
ASM diskgroups dismounted
ASM instance shutdown
SQL>
ASM diskgroups dismounted
ASM instance shutdown
SQL>
- Perform all the steps listed in the Raw Device Setup, then start the ASM instance.
SQL> STARTUP
ASM instance started
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>
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL>
The ASM instance is now using the disks as raw devices, rather than as ASMLib disks. All dependent databases can now be started
No comments:
Post a Comment