Moneycontrol Brokerage Recos

Thursday, January 29, 2015

Step by Step Oracle 10g Automatic Storage Management Setup

Automatic Storage Management:
=====================
Automatic Storage Management (ASM) is an integrated file system and volume manager expressly built for Oracle database files. ASM provides the performance of raw I/O with the easy management of a file system. It simplifies database administration by eliminating the need for you to directly manage potentially thousands of Oracle database files. It does this by enabling you to divide all available storage into disk groups. You manage a small set of disk groups and ASM automates the placement of the database files within those disk groups.

In the SQL statements that you use for creating database structures such as tablespaces, control files, and redo and archive log files, you specify file location in terms of disk groups. ASM then creates and manages the associated underlying files for you.


Why we need Automatic Storage Management to be implemented:


  • If we want to have a file bigger than the disk/mount.
  • For the best I/O throughput operations.
  • To save file system administration cost
  • For disk fault tolerance etc.


Note: I suppose, already you have your Linux machine ready and Oracle 10g RDBMS binaries installed in there.

1. First create a directory to hold raw disks on a particular location.

$ mkdir /u01/asmdisks


2. Create RAW partitions:

Note: Here I have used raw devices that have been using traditionally. We have some drawbacks of using raw devices like if our raw disk is 10GB in size and the file stored in it is 5GB then remaining 5GB space can't be reclaimed and would be a waste of storage and it has high maintenance costs.

-------------------------
[root@ora10srv bin]# dd if=/dev/zero of=/u01/asmdisks/disk1 bs=1024k count=1000
1000+0 records in
1000+0 records out

[root@ora10srv bin]# dd if=/dev/zero of=/u01/asmdisks/disk2 bs=1024k count=1000
1000+0 records in
1000+0 records out

[root@ora10srv bin]# dd if=/dev/zero of=/u01/asmdisks/disk3 bs=1024k count=1000
1000+0 records in
1000+0 records out

[root@ora10srv bin]# dd if=/dev/zero of=/u01/asmdisks/disk4 bs=1024k count=1000
1000+0 records in
1000+0 records out

-------------------------
[root@ora10srv bin]# /sbin/losetup /dev/loop1 /u01/asmdisks/disk1

[root@ora10srv bin]# /sbin/losetup /dev/loop2 /u01/asmdisks/disk2

[root@ora10srv bin]# /sbin/losetup /dev/loop3 /u01/asmdisks/disk3

[root@ora10srv bin]# /sbin/losetup /dev/loop4 /u01/asmdisks/disk4

-------------------------
[root@ora10srv bin]# raw /dev/raw/raw1 /dev/loop1
/dev/raw/raw1:  bound to major 7, minor 1

[root@ora10srv bin]# raw /dev/raw/raw2 /dev/loop2
/dev/raw/raw2:  bound to major 7, minor 2

[root@ora10srv bin]# raw /dev/raw/raw3 /dev/loop3
/dev/raw/raw3:  bound to major 7, minor 3

[root@ora10srv bin]# raw /dev/raw/raw4 /dev/loop4
/dev/raw/raw4:  bound to major 7, minor 4


Now, we need to change the permission for oracle user on the raw disks created above.

[oracle@ora10srv raw]$ cd /dev/raw

[oracle@ora10srv raw]$ chown -R oracle:oinstall *

[oracle@ora10srv raw]$ chmod 660 *

[oracle@ora10srv raw]$ ls -ltr
total 0
crw-rw----  1 oracle oinstall 162, 1 Jan 28 13:39 raw1
crw-rw----  1 oracle oinstall 162, 2 Jan 28 13:39 raw2
crw-rw----  1 oracle oinstall 162, 3 Jan 28 13:39 raw3
crw-rw----  1 oracle oinstall 162, 4 Jan 28 13:40 raw4


3. Before creating and starting ASM instance, CSS service must be up and running so in order to get your CSS service up and running just go to $ORACLE_HOME/bin and run the following command as root user to start CSS service.

[root@ora10srv bin]# ./localconfig add
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized

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.
CSS is active on these nodes.
        ora10srv
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

4. Run DBCA to create ASM Instance and database:

[oracle@ora10srv bin]$ ./dbca



Here we choose - Configure Automatic Storage Management option to create and start an ASM instance.



Provide Password for SYS and click on Next.



Click on OK to create and start ASM instance.






Click on Create New to create the Disk group to be used for database files.



Here Provide Disk Group Name - DATA and select candidate disks and click on OK.






Disk group has been created and mounted now.



Click on Yes - in order to create database further.



Now you can see +ASM Instance has been setup successfully and running.

[oracle@ora10srv bin]# ps -ef | grep asm
oracle    5788  5787  0 13:42 pts/1    00:00:15 /u01/app/oracle/product/10.2.0/db_1/jdk/jre/bin/java -Dsun.java2d.font.DisableAlgorithmicStyles=true -DORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 -DDISPLAY=:0.0 -DJDBC_PROTOCOL=thin -mx128m -classpath /u01/app/oracle/product/10.2.0/db_1/jdk/jre/lib/rt.jar:/u01/app/oracle/product/10.2.0/db_1/jdk/jre/lib/i18n.jar:/u01/app/oracle/product/10.2.0/db_1/assistants/dbca/jlib/dbca.jar:/u01/app/oracle/product/10.2.0/db_1/assistants/jlib/assistantsCommon.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/ewt3.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/ewtcompat-3_3_15.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/share.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/help4.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/jewt4.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/oracle_ice5.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/kodiak.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/swingall-1_1_1.jar:/u01/app/oracle/product/10.2.0/db_1/lib/xmlparserv2.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/orai18n.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/orai18n-mapping.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/orai18n-utility.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/orai18n-collation.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/netcfg.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/ojmisc.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/oraclepki103.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/ldapjclnt10.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/opm.jar:/u01/app/oracle/product/10.2.0/db_1/jdbc/lib/classes12.zip:/u01/app/oracle/product/10.2.0/db_1/jlib/srvm.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/srvmhas.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/srvmasm.jar:/u01/app/oracle/product/10.2.0/db_1/classes:/u01/app/oracle/product/10.2.0/db_1/jlib/oemlt-10_1_0.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/emca.jar:/u01/app/oracle/product/10.2.0/db_1/sysman/jlib/emCORE.jar:/u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/home/oc4j.jar:/u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/home/db_oc4j_deploy.jar:/u01/app/oracle/product/10.2.0/db_1/jlib/emConfigInstall.jar:/u01/app/oracle/product/10.2.0/db_1/oui/jlib/OraInstaller.jar:/u01/app/oracle/product/10.2.0/db_1/oui/jlib/OraPrereq.jar:/u01/app/oracle/product/10.2.0/db_1/inventory/prereqs/oui/OraPrereqChecks.jar:/u01/app/oracle/product/10.2.0/db_1/oui/jlib/OraPrereqChecks.jar oracle.sysman.assistants.dbca.Dbca
oracle   25656     1  0 14:39 ?        00:00:00 asm_pmon_+ASM
oracle   25658     1  0 14:39 ?        00:00:00 asm_psp0_+ASM
oracle   25660     1  0 14:39 ?        00:00:00 asm_mman_+ASM
oracle   25662     1  0 14:39 ?        00:00:01 asm_dbw0_+ASM
oracle   25664     1  0 14:39 ?        00:00:00 asm_lgwr_+ASM
oracle   25666     1  0 14:39 ?        00:00:00 asm_ckpt_+ASM
oracle   25668     1  0 14:39 ?        00:00:00 asm_smon_+ASM
oracle   25670     1  0 14:39 ?        00:00:00 asm_rbal_+ASM
oracle   25672     1  0 14:39 ?        00:00:00 asm_gmon_+ASM
root     25733  5496  0 14:42 pts/2    00:00:00 grep asm

[oracle@ora10srv bin]# ps -ef | grep pmon
oracle   25656     1  0 14:39 ?        00:00:00 asm_pmon_+ASM
root     25739  5496  0 14:43 pts/2    00:00:00 grep pmon

SQL> set linesize 220
SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME    HOST_NAME                                                        VERSION           STARTUP_T STATUS       PAR    THREAD# ARCHIVE LOG_SWITCH_WAIT LOGINS     SHU DATABASE_STATUS
--------------- ---------------- ---------------------------------------------------------------- ----------------- --------- ------------ --- ---------- ------- --------------- ---------- --- -----------------
INSTANCE_ROLE      ACTIVE_ST BLO
------------------ --------- ---
              1 +ASM             ora10srv                                                         10.2.0.3.0        28-JAN-15 STARTED      NO           0 STOPPED  ALLOWED    NO  ACTIVE
UNKNOWN            NORMAL    NO



Now, let's proceed with database creation based on Automatic Storage Management.









Here we choose Automatic Storage Management(ASM) as our storage Mechanism.


Select disk groups to be used as storage for the database.











Now, let's check with database login if our created database files are placed inside Automatic Storage Management.


[oracle@ora10srv bin]# ps -ef | grep pmon
oracle   25656     1  0 14:39 ?        00:00:00 asm_pmon_+ASM
oracle   26152     1  0 14:56 ?        00:00:00 ora_pmon_asmdb
root     26228  5496  0 15:01 pts/2    00:00:00 grep pmon

Enter user-name: sys as sysdba
Enter password:

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

SQL> set linesize 220
SQL> select name from v$datafile;

NAME
---------------------------------------------------------
+DATA/asmdb/datafile/system.256.870187759
+DATA/asmdb/datafile/undotbs1.258.870187769
+DATA/asmdb/datafile/sysaux.257.870187763
+DATA/asmdb/datafile/users.259.870187771

SQL> select name from v$controlfile;

NAME
-----------------------------------------------------------
+DATA/asmdb/controlfile/current.261.870188029
+DATA/asmdb/controlfile/current.260.870188031

Here we can see our database files are created inside Automatic Storage Management..............!!

Hope it would help someone to setup ASM based database.............!!

No comments:

Post a Comment