Wednesday, April 16, 2014

Move MySQL tmp dir from Disk to RAM for better performance

        Move MySQL tmp dir from Disk to RAM for better performance
Cause:- If these temporary disk tables are causing serious I/O performance problems one could consider to use a RAM-disk instead of normal physical disks instead.

Goal :- Improve performance and decrease query time.

Solution:- Move MySQL's temporary files from disk to a RAM is very significant, if our server has lots of slow queries.

On Linux we have 2 possibilities to create a RAM-disk: ramfs and tmpfs.

#~~#Recommend to use tmpfs.
A RAM-disk can be created as follows:
shell> mkdir -p /db/ramdisk
shell> chown mysql:mysql /db/ramdisk
shell> mount -t tmpfs -o size=1024M tmpfs /db/ramdisk
To make this persistent we have to add it to the fstab:
#
# /etc/fstab
#
tmpfs           /db/ramdisk     tmpfs   rw,mode=1777,size=1024M    0       0

To changes and get it reflected this need to configure in my.cnf accordingly and restart the database...

Saturday, April 12, 2014

Applying CPU Patch in a Physical Standby Database Configuration

                                      Oracle patch deployment activity plan
                Applying CPU Patch in a Physical Standby Database Configuration
Activity Plan:-Activity step from 1 to 6 before downtime and Activity onward step7 will be in Downtime
1. Disable log shipping from the Primary
i)Stop recovery at standby:-
a.cmd:-alter database recover managed standby database cancel;
b.verfiry at os level ps -ef |grep mrp
c.verify at db level using alert log file
ii)Defer archive shiping from production
cmd:-alter system set log_archive_dest_state_2=DEFER;

2. Shutdown Standby
a.Stop Listener
cmd:- lsnrctl stop servicename
Note:-To check servicename please find it using cmd:-lsnrctl status
b.Shutdown Database
cmd:-shut immediate

3. Take Backup of Oracle binaries on standby
cmds:-
cd $ORACLE_HOME
cd ../
tar -cvf $ORACLE_HOME/Backupstdby_db_1.09042014 db_1
cd /home/oracle/
tar -cvf $ORACLE_HOME/Backupstdby_oraInventory.09042014 oraInventory

4. Install the CPU patch on Standby server
a.check inventory & version status before proceeding for update
cmd for version:-opatch version
cmd for inventory status:-opatch lsinventory
b.Apply patch(Note:make sure we have exported $ORACLE_HOME/OPatch in PATH ENV VAR)
To apply CPU Patch we require OPatch utility available of that database version or later in order to apply that patch.
Go to path where we have placed both patches CPU Patch: p5689937_10201_Linux-x86-64.zip & Opatch ultility :- & p6880880_102000_Linux-x86-64.zip.(i.e /home/oracle/oracle_patch/)
Note:(pnumber_xxxxx_OS-Bit.zip :number defines patch number & xxxxx defines db version number for which it is valid , OS defines OS Flavour and Bit represent architecture bit of OS)
cd /home/oracle/oracle_patch/
cp -pvr p6880880_102000_Linux-x86-64.zip $ORACLE_HOME/
(Note:above patch will deploy opatch utility)
cd $ORACLE_HOME
mv OPatch OPatch_old
unzip p6880880_102000_Linux-x86-64.zip
cd /home/oracle/oracle_patch/
unzip p5689937_10201_Linux-x86-64.zip
cd 5689937
opatch apply
c.check inventory & version status after updation of patch
cmd for version:-opatch version
cmd for inventory status:-opatch lsinventory

5. Startup Standby in recovery mode (do NOT run any SQL the standby)
a.Start Database
cmds:-
sqlplus / as sysdba
Startup mount
b.Start Listener
cmd:- lsnrctl start servicename
Note:-servicename here belongs to what we have already captured in step 2

6. Re-enable log shipping on standby
i)Resume Recovery
a.cmd:-alter database recover managed standby database using current logfile disconnect;
b.verfiry at os level ps -ef |grep mrp
c.verify at db level using alert log file
ii)Enable archive shiping from production
cmd:-alter system set log_archive_dest_state_2=ENABLE;
iii)Switch logfile on production
alter system switch logfile;
iv)Check both are in sync or not with daily_queries.
select DEST_ID,sequence#,archived,applied,deleted,status from v$archived_log order by 2;

7. Shutdown Primary
a.Stop Listener
cmd:- lsnrctl stop servicename
Note:-To check servicename please find it using cmd:-lsnrctl status
b.Also shutdown oem service if any
cmd:-emctl stop dbconsole
c.Shutdown Database
cmd:-shut immediate

8. Take Backup of Oracle binaries on Primary
cmds:-
cd $ORACLE_HOME
cd ../
tar -cvf $ORACLE_HOME/Backupprim_db_1.09042014 db_1
cd /home/oracle/
tar -cvf $ORACLE_HOME/Backupprim_oraInventory.09042014 oraInventory

9. Install the CPU patch on Primary
a.check inventory & version status before proceeding for update
cmd for version:-opatch version
cmd for inventory status:-opatch lsinventory
b.Apply patch(Note:make sure we have exported $ORACLE_HOME/OPatch in PATH ENV VAR)
To apply CPU Patch we require OPatch utility available of that database version or later in order to apply that patch.
Go to path where we have placed both patches CPU Patch: p5689937_10201_Linux-x86-64.zip & Opatch ultility :- & p6880880_102000_Linux-x86-64.zip.(i.e /home/oracle/oracle_patch/)
Note:(pnumber_xxxxx_OS-Bit.zip :number defines patch number & xxxxx defines db version number for which it is valid , OS defines OS Flavour and Bit represent architecture bit of OS)cd /home/oracle/oracle_patch/
cp -pvr p6880880_102000_Linux-x86-64.zip $ORACLE_HOME/
cd $ORACLE_HOME
mv OPatch OPatch_old
unzip p6880880_102000_Linux-x86-64.zip
cd /home/oracle/oracle_patch/
unzip p5689937_10201_Linux-x86-64.zip
cd 5689937
opatch apply
c.check inventory & version status after updation of patch
cmd for version:-opatch version
cmd for inventory status:-opatch lsinventory

10. Start primary
a.Start Database
cmds:-
sqlplus / as sysdba
Startup
b.Start Listener
cmd:- lsnrctl start servicename
Note:-servicename here belongs to what we have already captured in step 7

11. Run the SQL script for the patch on Primary
a.cmd:-
cd $ORACLE_HOME/cpu/CPUJan2007
sqlplus / as sysdba
@catcpu.sql

b.Use the below SQL command to see all the PSUs/CPUs applied to your database.
cmd:-select * from dba_registry_history ;

12. Re-enable log shipping
i)Resume Recovery
a.cmd:-alter database recover managed standby database using current logfile disconnect;
b.verfiry at os level ps -ef |grep mrp
c.verify at db level using alert log file
ii)Enable archive shiping from production
cmd:-alter system set log_archive_dest_state_2=ENABLE;
iii)Switch logfile on production
cmd:-alter system switch logfile;
iv)Check both are in sync or not with daily_queries.
select DEST_ID,sequence#,archived,applied,deleted,status from v$archived_log order by 2;

13. Monitor the redo apply from Primary to Standby --- this will also upgrade the Standby data dictionary

--Rollback Plan:-
1. Disable log shipping from the Primary
2. Shutdown Standby
3. Take Backup of Oracle binaries on standby
4. Rollback the CPU patch on Standby server
5. Startup Standby in recovery mode (do NOT run any SQL the standby)
6. Re-enable log shipping on standby
7. Shutdown Primary
8. Take Backup of Oracle binaries on Primary
9. Rollback the CPU patch on Primary
10. Start primary
11. Run the SQL Rollback script for the patch on Primary
12. Re-enable log shipping
13. Monitor the redo apply from Primary to Standby --- this will also rollback the Standby data dictionary