Friday, October 23, 2015

How To Setup ASM & ASMLIB On Native Linux Multipath Mapper disks

This note apply to Oracle Database using ASM and linux S.O.

After installed and configured the Multipath, follow bellow:

2. Check the disks :
ls -l /dev/mapper
brw-rw---- 1 root disk 253, 46 Jul 27 17:19 Prod_Orcl01
brw-rw---- 1 root disk 253, 67 Jul 27 17:59 Prod_Orcl02
brw-rw---- 1 root disk 253, 36 Jul 27 17:19 Prod_Orcl03
brw-rw---- 1 root disk 253, 58 Jul 27 18:00 Prod_Orcl04

3. Create the ASMLIB disks on mapper partitions as follow:
/etc/init.d/oracleasm createdisk DSKORA1  /dev/mapper/Prod_Orcl01
/etc/init.d/oracleasm createdisk DSKORA2  /dev/mapper/Prod_Orcl02
After create the disks, the ASM put a mark on the disks to know which are your own.

4. If this is a RAC configuration, then from each node execute:
/etc/init.d/oracleasm scandisks
/etc/init.d/oracleasm listdisks

5. Configure ASMLIB to use multipath  (from each node on RAC environments):
By any path the ASMLIB can found the disks, but, the best path is using the multipath :
Modify in /etc/sysconfig/oracleasm :
ORACLEASM_SCANORDER=”dm”
ORACLEASM_SCANEXCLUDE=”sd”
note: The Oracle ASMLib configuration file is located at /etc/sysconfig/oracleasm. It is a link to file /etc/sysconfig/oracleasm-_dev_oracleasm.
Restart ASMLIB (from each node on RAC environments):
/etc/init.d/oracleasm stop
/etc/init.d/oracleasm start

6. Verify if the configuration is correct:
6.1 During the disk discovery, ASMLIB uses file /proc/partitions, see :
# cat /proc/partitions
   8     0  877264896 sda
   8     1     104391 sda1
   8     2  877157032 sda2
   8    16  209715200 sdb
   8    32  382730240 sdc
   8    48  379596800 sdd
   8    64    2097152 sde
   8    80    2097152 sdf
   8    96 1169776640 sdg
 253     6  209715200 dm-6
 253     7  382730240 dm-7
 253     8  379596800 dm-8
 253     9    2097152 dm-9
 253    10    2097152 dm-10

6.2 The ASMLIB mount disks at /dev/oracleasm/disks, see:
# ls -la /dev/oracleasm/disks
brw-rw---- 1 grid asmadmin 253,  6 Ago 16 16:33 DSKORA1
brw-rw---- 1 grid asmadmin 253,  7 Ago 16 16:33 DSKORA2

6.3 Check if major and minor of disks “dm” not “sd”, is the same in /proc/partitions  and /dev/oracleasm/disks , see “253″ and “6″ bellow:
/proc/partitions 253     6  209715200 dm-6
/dev/oracleasm/disks
brw-rw---- 1 grid asmadmin 253,  6 Ago 16 16:33 DSKORA1
You can check using querydisk too :
# /etc/init.d/oracleasm querydisk -d DSKORA1
Disk "DSKORA1" is valid ASM disk on device [253, 6]

Friday, October 2, 2015

ASMLib and EMC PowerPath Multipathing

Problem - ASMLib picks the first disk device it finds for a particular ASM disk and uses that device. This usually means that ASM is NOT using the multipath emcpower device.

ASMLib picks the first disk device it finds for a particular ASM disk and uses that device. This usually means that ASM is NOT using the multipath emcpower device. 
Let's pick an ASMLib disk on my server - in this case I choose a disk that has been named  ORA_FPF_90GB_EMCP022 .
root@fpfkxtdb02 ~# /etc/init.d/oracleasm  querydisk ORA_FPF_90GB_EMCP022 
Disk "ORA_FPF_90GB_EMCP022" is a valid ASM disk 
There are lots of possible paths to the disk. ASM picks the first one it finds and ignores the rest. What paths are there for our disk?? 
root@fpfkxtdb02 ~# /etc/init.d/oracleasm querydisk -p ORA_FPF_90GB_EMCP022 
Disk "ORA_FPF_90GB_EMCP022" is a valid ASM disk 
/dev/sdn1: LABEL="ORA_FPF_90GB_EMCP022" TYPE="oracleasm" 
/dev/sdav1: LABEL="ORA_FPF_90GB_EMCP022" TYPE="oracleasm" 
/dev/sdcd1: LABEL="ORA_FPF_90GB_EMCP022" TYPE="oracleasm" 
/dev/sddk1: LABEL="ORA_FPF_90GB_EMCP022" TYPE="oracleasm" 
/dev/emcpowerm1: LABEL="ORA_FPF_90GB_EMCP022" TYPE="oracleasm" 
Lots of paths.

Lets see what device path is actually being used for our ASMLib disk: 
root@fpfkxtdb02 ~# /etc/init.d/oracleasm querydisk -d ORA_FPF_90GB_EMCP022 
Disk "ORA_FPF_90GB_EMCP022" is a valid ASM disk on device [8, 209] 
Device [8, 209]  is the first disk in the path list - /dev/sdn1 - NOT the emcpower device. 
root@fpfkxtdb02 ~# ls -l /dev/sdn1 
brw-r----- 1 root disk 8, 209 Oct 24 12:15 /dev/sdn1 
We want ASMLib to be using THIS device: 
root@fpfkxtdb02 ~# ls -l /dev/emcpowerm1 
brw-r----- 1 root disk 120, 193 Oct 24 12:15 /dev/emcpowerm1 
HOW TO FIX IT SO THAT THE EMCPOWER DEVICE IS THE DEVICE THAT ASMLIB USES

Edit ORACLEASM_SCANORDER and ORACLEASM_SCANEXCLUDE!

root@fpfkxtdb02 ~# vim /etc/sysconfig/oracleasm 
Change

# ORACLEASM_SCANORDER: Matching patterns to order disk scanning 
ORACLEASM_SCANORDER="" 
# ORACLEASM_SCANEXCLUDE: Matching patterns to exclude disks from scan 
ORACLEASM_SCANEXCLUDE="" 

TO

# ORACLEASM_SCANORDER: Matching patterns to order disk scanning 
ORACLEASM_SCANORDER="emcpower" 
# ORACLEASM_SCANEXCLUDE: Matching patterns to exclude disks from scan 
ORACLEASM_SCANEXCLUDE="sd dm" 


Unload, reload ASM and scandisks
root@fpfkxtdb02 ~# oracleasm exit 
Unmounting ASMlib driver filesystem: /dev/oracleasm 
Unloading module "oracleasm": oracleasm 
root@fpfkxtdb02 ~# oracleasm init 
Loading module "oracleasm": oracleasm 
Mounting ASMlib driver filesystem: /dev/oracleasm 
root@fpfkxtdb02 ~# /etc/init.d/oracleasm scandisks 
Scanning the system for Oracle ASMLib disks:               [  OK  ] 

Check that ASM is now using the emcpower device:

root@fpfkxtdb02 ~# /etc/init.d/oracleasm querydisk -d ORA_FPF_90GB_EMCP022 
Disk "ORA_FPF_90GB_EMCP022" is a valid ASM disk on device [120, 193] 

Done

Source: http://www.oracletech.com.au/2012/02/asmlib-and-emc-powerpath-multipathing.html

Mapping ASM disks to Physical Devices

Sometimes you may need to map ASM Disks to its physical devices. 

If they are based on ASMLib you will see their ASM name, ie: ORCL:VOL1 when querying v$asm_disk

When running oracleasm querydisk VOL1 you will get in addition the major - minor numbers, that can be used to match the physical device, ie:
[root@orcldb2 ~]# /etc/init.d/oracleasm querydisk VOL1
Disk "VOL1" is a valid ASM disk on device [8, 97]

[root@orcldb2 ~]# ls -l /dev | grep 8, | grep 97
brw-rw----   1 root disk     8,      81 Nov  4 13:02 sdg1
This script can do the job for a group of ASM Disks:

---------- start  here ------------
#!/bin/ksh
for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk $i | awk  '{print $2}'`
v_minor=`/etc/init.d/oracleasm querydisk $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk '{print $1}'`
v_major=`/etc/init.d/oracleasm querydisk $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk '{print $2}'`
v_device=`ls -la /dev | grep $v_minor | grep $v_major | awk '{print $10}'`
echo "ASM disk $v_asmdisk based on /dev/$v_device  [$v_minor $v_major]"
done
---------- finish here ------------

The output looks like this:

ASM disk "VOL1" based on /dev/sdg1  [8, 97]
ASM disk "VOL10" based on /dev/sdp1  [8, 241]
ASM disk "VOL2" based on /dev/sdh1  [8, 113]
ASM disk "VOL3" based on /dev/sdk1  [8, 161]
ASM disk "VOL4" based on /dev/sdi1  [8, 129]
ASM disk "VOL5" based on /dev/sdl1  [8, 177]
ASM disk "VOL6" based on /dev/sdj1  [8, 145]
ASM disk "VOL7" based on /dev/sdn1  [8, 209]
ASM disk "VOL8" based on /dev/sdo1  [8, 225]
ASM disk "VOL9" based on /dev/sdm1  [8, 193]

If you are using multi-path, you will need an additional step to map the physical device to the multi-path device, for instance if using EMC Powerpath if you want to map sdf1

[root@orclp ~]# /etc/init.d/oracleasm querydisk vol1
Disk "VOL1" is a valid ASM disk on device [8, 81]

[root@orclp ~]# ls -l /dev | grep 8,| grep 81
brw-rw----   1 root disk     8,      81 Oct 29 20:42 sdf1

[root@orclp ~]# powermt display dev=all
...
...
Pseudo name=emcpowerg
Symmetrix ID=000290101698
Logical device ID=0214
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
### HW Path                 I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   1 qla2xxx                   sdf       FA  7bB   active  alive      0      0
   2 qla2xxx                   sdq       FA 10bB   active  alive      0      0
...
...

The last step is to check the partition assigned to the emcpower device, ie:

[root@orclp ~]# ls -l /dev/emcpowerg*
brw-------  1 root root 120, 96 Oct 29 20:41 /dev/emcpowerg
brw-------  1 root root 120, 97 Nov 15 13:08 /dev/emcpowerg1

Source: https://blogs.oracle.com/AlejandroVargas/entry/mapping_asm_disks_to_physical

Saturday, November 1, 2014

Steps to shut down or reboot an Exadata storage cell without affecting ASM

To provide steps to power down or reboot an Exadata Storage cell without affecting ASM.
SOLUTION

Steps to power down or reboot a cell without affecting ASM:
When performing maintenance on Exadata Cells, it may be necessary to power down or reboot the cell. If a storage server is to be shut down when one or more databases are running, then verify that taking the storage server offline will not impact Oracle ASM disk group and database availability. The ability to take Oracle Exadata Storage Server offline without affecting database availability depends on the level of Oracle ASM redundancy used on the affected disk groups, and the current status of disks in other Oracle Exadata Storage Servers that have mirror copies of data as Oracle Exadata Storage Server to be taken offline.
============================================
1)  By default, ASM drops a disk shortly after it is taken offline; however, you can set the DISK_REPAIR_TIME attribute to prevent this operation by specifying a time interval to repair the disk and bring it back online. The default DISK_REPAIR_TIME attribute value of 3.6h should be adequate for most environments.
(a) To check repair times for all mounted disk groups – log into the ASM instance and perform the following query:
SQL> select dg.name,a.value from v$asm_diskgroup
dg, v$asm_attribute a where dg.group_number=a.group_number and
a.name='disk_repair_time';
(b) If you need to offline the ASM disks for more than the default time of 3.6 hours then adjust the parameter by issuing the command below as an example:
SQL> ALTER DISKGROUP DATA SET ATTRIBUTE 'DISK_REPAIR_TIME'='8.5H';
2)  Next you will need to check if ASM will be OK if the grid disks go OFFLINE. The following command should return ‘Yes’ for the grid disks being listed:
cellcli -e list griddisk attributes name,asmmodestatus,asmdeactivationoutcome
3) If one or more disks return asmdeactivationoutcome=’No’, you should wait for some time and repeat step #2. Once all disks return return asmdeactivationoutcome=’Yes’, you can proceed with taking the griddisk offline in step #4.
Note: Taking the storage server offline when one or more grid disks return asmdeactivationoutcome=’No’ will cause Oracle ASM to dismount the affected disk group, causing the databases to shut down abruptly.
4) Run cellcli command to Inactivate all grid disks on the cell you wish to power down/reboot:
cellcli -e alter griddisk all inactive

* Please note – This action could take 10 minutes or longer depending on activity. It is very important to make sure you were able to offline all the disks successfully before shutting down the cell services. Inactivating the grid disks will automatically OFFLINE the disks in the ASM instance. 
5) Confirm that the griddisks are now offline by performing the following actions:
(a) Execute the command below and the output should show either asmmodestatus=OFFLINE or asmmodestatus=UNUSED and asmdeactivationoutcome=Yes for all griddisks once the disks are offline in ASM. Only then is it safe to proceed with shutting down or restarting the cell:
cellcli -e list griddisk attributes name,asmmodestatus,asmdeactivationoutcome
( there has also been a reported case of asmmodestatus= OFFLINE: Means Oracle ASM has taken this grid disk offline. This status is also fine and can proceed with remaining instructions)
(b) List the griddisks to confirm all now show inactive:
cellcli -e list griddisk
6) You can now reboot the cell. Oracle Exadata Storage Servers are powered off and rebooted using the Linux shutdown command.
(a) The following command will shut down Oracle Exadata Storage Server immediately: (as root):
#shutdown -h now
(When powering off Oracle Exadata Storage Servers, all storage services are automatically stopped.)
(b) The following command will reboot Oracle Exadata Storage Server immediately and force fsck on reboot:
#shutdown -F -r now
7) Once the cell comes back online – you will need to reactive the griddisks:
cellcli -e alter griddisk all active
8) Issue the command below and all disks should show ‘active':
cellcli -e list griddisk
9)  Verify grid disk status:
(a) Verify all grid disks have been successfully put online using the following command:
cellcli -e list griddisk attributes name, asmmodestatus
(b) Wait until asmmodestatus is ONLINE for all grid disks. Each disk will go to a ‘SYNCING’ state first then ‘ONLINE’. The following is an example of the output:
DATA_CD_00_dm01cel01 ONLINE
DATA_CD_01_dm01cel01 SYNCING
DATA_CD_02_dm01cel01 OFFLINE
DATA_CD_03_dm01cel01 OFFLINE
DATA_CD_04_dm01cel01 OFFLINE
DATA_CD_05_dm01cel01 OFFLINE
DATA_CD_06_dm01cel01 OFFLINE
DATA_CD_07_dm01cel01 OFFLINE
DATA_CD_08_dm01cel01 OFFLINE
DATA_CD_09_dm01cel01 OFFLINE
DATA_CD_10_dm01cel01 OFFLINE
DATA_CD_11_dm01cel01 OFFLINE
(c) Oracle ASM synchronization is only complete when all grid disks show asmmodestatus=ONLINE.
( Please note:  this operation uses Fast Mirror Resync operation – which does not trigger an ASM rebalance. The Resync operation restores only the extents that would have been written while the disk was offline.)
10) Before taking another storage server offline, Oracle ASM synchronization must complete on the restarted Oracle Exadata Storage Server. If synchronization is not complete, then the check performed on another storage server will fail. The following is an example of the output:
CellCLI> list griddisk attributes name where asmdeactivationoutcome != 'Yes'
DATA_CD_00_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_01_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_02_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_03_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_04_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_05_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_06_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_07_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_08_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_09_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_10_dm01cel02 "Cannot de-activate due to other offline disks in the diskgroup"
DATA_CD_11_dm01cel02 "Cannot de-activate due to other offline disks in the diskgr

Sunday, July 27, 2014

What is Exadata ? Architecture, Components and Four Main Features of Exadata Storage Server

Now a days Exadata is a buzz word in Database world. So, I decide to simplify What is Exadata It's components and what are four main features of Exadata ?

To understand Exadata, Let's start with Traditional Database System having High Availability (RAC).

Current RAC Environment Setup:

To setup a RAC database Below are the Hardware and Software requirements.

1. Database Nodes or Database Server.
2. Storage Server.
3. Network equipments.


DBA has got Hardware. Next step is to setup Software. Database Administrator has to do following:

1. Eanble SSH between Database Nodes and Storage Server.
2. Real Application Cluster Installation.
3. ASM Installation.
4. Presenting Disks to ASM and creating Disk groups etc.
5. Installing Database Software.


Finally, System is ready for RAC database creation, but during all this process DBA has to work with Different teams like Hardware, Networking and storage and there are different-2 vendors involved for each of these components. Remote DBA also responsible to make sure that each component is compatible with each other and finally compatible with Oracle RAC, ASM and Database Software. So it has became a tedious task for DBA and takes a lot of time to set up a RAC environment.

To solve all these challenges Oracle has come up with a new product call Exadata, Which is a bundle of Hardware from Oracle SUN and Installed S/W Like RAC, ASM, Database Software. Exadata Machine is ready to use within few hours of Delivery. but Exadata is not about providing bundled Hardware and Software to customer but as an Hardware with Intelligence.

To Know Hardware with Intelligence, Let's take another scenario, Remote DBA has set up a RAC environment which is working fine. In RAC env Database is stored at Shared Storage Server and to get output of any query data has to transfer from Shared Storage server to Database Node and then DB node will process data and provide results. 
Limitations of Current RAC and Storage Servers
As we know, the database for organizations are increasing day by day and we have limited network bandwidth between DB node and Storage Server (Limitations comes at Hardware level). So after a certain limit we can't optimize our speed of processing data because of Hardware limitation of database nodes, storage Server and Network equipments.

Suppose a simple query Select * from order where Order_type='new' which returns only 1 Million rows is executed on the database machine and the order table has 100 Million rows. So, in that case whole 100 Million rows will come from Storage server to DB node for processing and after processing by DB node DBA will get query output. This whole process take lot of time and resources from all RAC components.

How about if Storage Server only return 1 Million rows which were requested in where clause of the query ?

This is what Exadata Software does i.e. Filtering at Storage Level. Of course this is one of the mail feature of Exadata Software. A DBA can easily estimate the impact of this change. Technically this term is called as Exadata Smart Scan.

So, Here is What is Exadata ?

1. A bundle of Hardware and Software from Oracle Itself and ready to use immediately.
2. An Intelligent Storage Server to optimize Database Performance. In order to achieve this intelligent a software called Exadata is installed on  all storage servers.

In Exadata Terms, A single storage server is called Cell or Cell server. So I will be referring storage server and cell server interchangeably in this article. I might be referring DB Server, DB Node for Database Server.

Architecture of Exadata Database Machine:


In above diagram, there are three DB nodes, which are connect with two cell servers. Each storage server has it components.

Component of Exadata Storage Server:

It's another storage device, which has CUP, Memory, Disks, network cards, an Operating System Oracle Linux and Most important past Exdata Storage Server Software. There are mainly three services which run on cell server for processing, CellSRV (Cell Service), MS (Management Server) and RS (Restart Server).
Cell Service (CellSRV): This is the primary component of Exdata Cell which provides all Exadata Storage services. This process communicate with Database server for providing database blocks.

Management Server (MS): MS service provide an interface to DBA for communicating or Managing Cell Server. CellCLI is the Command Line tool which Exadata DBA used for performing Exadata Administration services.

Restart Server (RS): This service is to make sure the functioning of Exadata Server. RS monitors CellSRV and MS for liveliness and restart them whenever required.

Four Main Features of Exadata Storage Server.


1. Smart Flash Cache Intelligent Caching: Storage servers usually have two kind of storage Hard disk and Flash Cache. Flash Cache are fast storage device used to keep most frequently accessed data for faster access, whenever there is a requirement of a block it is first looked into Flash Cache and if available returned to the server without going to Hard disk for reading the block. This is a common feature in Storage servers. 

Now with Exadata Smart Flash Cache Inetlligence, Flash Disks are optimized to work according to
Oracle Database requirements. Exadata Software Directs Flash Cache to keep following objects into it.

    A. Frequently access data and index blocks
    B. Control Files read and write.
    C. File headers read and write.

Following are not kept in Flash Cache.

    a. Backup Related I/O
    b. Data Pump I/O
    c. Full Table Scan.

Database Administrator can also influence caching of Database Objects by pinning them into Flash Cache by setting CELL_FLASH_CACHE parameter. Here is a better way to know Exadata Smart Flash Cache.

2. Hybrid Columnar Compression (HCC): Compression is used for reducing storage consumption for large databases. In this technique a logical unit called Compression unit is used to store Hybrid columnar Compressed Rows. At time of data loading Column values are detached from rows, grouped and then compressed. After compression this is fit into compression unit. 
Database Smart scan processing is also supported at cell level i.e. Data blocks need not to move from cell server to database server for processing. The amount of saving storage space using HCC is around 10 to 15 times. Suppose you have 100 Tera Bytes of data, by using HCC DBA can store this Data in to 10 TB of Storage space.

3. Smart Scan Processing: In Exadata storage server has got intelligence to filter data at storage level, rather than transferring it to database server.

Exadata Smart Scan works filtering for following kind of queries:

1. Predicate Filter: In a query with where clause only blocks with satisfy where clause condition will only go to database server not the entire table.
2. Column Filtering: Suppose in a select query like "select name, age from employee" is execute on DB server by DBA, then only columns name and age data will send to Database Server not all columns of tables.
3. Join Processing: All join processing are done at Storage level itself, so only filtered data is sent to DB server.

4. I/O Resource Management: In traditional Database environment, If you have more than one database running on a Shared storage server. Large queries from one database can use more resource and cause performance issue for other databases. Another case a batch job has started in one DB by a DBA which case performance trouble into OLTP Database.

To avoid all these challenges Exadata has introduced Exadata Storage Server I/O Resource Management (IORM). Till now we have Database Resource Manager (DBRM) to manage database resource within the database but now with help of IORM DBA can manager resource across databases.


Let's take an example: You have two database Production and testing running on same Cell Server. Now Database Administrator can configure Resource plan which gives priority to Production Database over testing DB. Here, Whenever Testing Database load will affect Production Database IORM will manage rerource request such that it doesn't impact production Database performance. Thiis means Test Database requests has to wait until they can execute without disturbing production database performance.

You can also find few more features of Exadata Machine, but above are the main features of it, other features are either extension or part of these these features.

To know more about Exadata visit http://www.oracle.com/technetwork/database/exadata/exadata-technical-whitepaper-134575.pdf.
You can aslo see a 3D demo of Exadata Machnie https://blogs.oracle.com/databaseinsider/entry/oracle_exadata_database_machin
Tutorials for Exadata.

Please share you views about this article.