Wednesday, December 2, 2015

Gather Stats to rescue yourself after Migrating to 11.2.0.4

This  was a scenario which was  faced by our team at the customer site

Oracle Database migration was planned  with OS Up gradation.

Old Database was 10g and runnig on AIX 6.1
New Database is 11g running on AIX 7.1

After migrating to 11.2.0.4  there were performance degradation.

work around carried out :

optimizer_features_enabled to 10.2.0.1

Alter system set optimizer_features_enabled=10.2.0.1 scope=both;

After altering to this Some queries which were taken too long time were run in quick time.

Lets say if query take  10S in 10.2.0,4 
That query take 40S in 11.2.0.4 
after setting optimizer_features_enabled to 10.2.0.1 it takes only 15S.

This rescue me for 2 days the performance issue raised  again.

After that again statistics were gathered and created all indexes online.

exec dbms_stats.gather_system_stats();
exec dbms_stats.gather_dictionary_stats
exec dbms_stats.gather_fixed_objects_stats();
exec dbms_stats.gather stats();

Rebuild all the Indexes  

 select OWNER,count(OBJECT_TYPE) from dba_objects where  OBJECT_TYPE='INDEX' group by owner


select 'ALTER INDEX ' || owner||'.'||index_name || ' rebuild online nologging;' from dba_indexes
where owner ='&OWNER';

This will give the  Alter Statements for Rebuild online INDEX.


Now the performance looks good ..!! :)

You can check when statistics were gathered last.

SELECT owner, table_name, last_analyzed FROM all_tables ORDER BY last_analyzed DESC NULLS
LAST; --Tables.
SELECT owner, index_name, last_analyzed FROM all_indexes ORDER BY last_analyzed DESC NULLS
LAST; -- Indexes.




Friday, October 30, 2015

Moving Tables to new TableSpace.

Task: There was a requirement to move some tables to SSD disk which is on ASM

So the tasks carried out was

Created ASM  DISK Group  INDEX ASM.

Created  a tablespace  called DATA_SSD using EM

Then moved required tables to newly created tablespace.


Alter table table_name move tablespace new_tablespace;

Alter table EMPLOYEE move tablespace DATA_SSD;

After Creating this   It's required  to Rebuild Indexes

Alter index index_name rebuild tablespace new_tablespace;

Alter index EMPNO_IDX rebuild tablespace DATA_SSD;

Tuesday, October 20, 2015

DB Auto Start Auto Shutdown on AIX 7.1 Server

I installed oracle database 11.2.0.4 on  AIX 7.1 server .Then it was required to start the db server, listener and dbconsole when  server is starting  and stop all services when shutting down the server.

I carried out following steps

1)Edit /etc/oratab entry

vi /etc/orataba

LECOBILL:/u02/app/oracle/product/11.2.0/dbhome_1 :Y


2) create a file called /etc/dboracle


vi /etc/dboracle

#! /bin/sh -x
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.
ORACLE_HOME=/u02/app/oracle/product/11.2.0/dbhome_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle
ORACLE_SID=LECOBILL
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME ORACLE_SID PATH
case $1 in
'start')
# Listener and instance are started by 'dbstart'
su - $ORACLE $ORACLE_HOME/bin/dbstart $ORACLE_HOME >> /var/log/oracle 2>&1 &
;;
'stop')
su - $ORACLE $ORACLE_HOME/bin/emctl stop dbconsole >> /var/log/oracle
# Listener and instance are shut down by 'dbstart'
su - $ORACLE $ORACLE_HOME/bin/dbshut $ORACLE_HOME >> /var/log/oracle 2>&1 &
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit


3).change  the group and permission for /etc/dboracle file

# chgrp dba /etc/dboracle
# chmod 750 /etc/dboracle

4).Then create symbolic links to /etc/dboracle  with appropriate  run levels
    Here I am in multi user environment.

# ln -s /etc/dboracle /etc/rc.d/rc2.d/S99dbora
# ln -s /etc/dboracle /etc/rc.d/rc2.d/K01dbora

5).Reboot the Machine to check
# shutdown -Fr

Wednesday, July 15, 2015

ORA-01092: ORACLE instance terminated

I installed Oracle 10g R2 (10.2.0.1) base on SUSE 11SP3 and created the database.
Then i wanted to patch the database to 10.2.0.5
I show down the Listener and Instance and Applied the patch (10.2.0.5).
Then i started the Instance.It suddenly terminate the instace. By Giving
ORA-01092: ORACLE instance terminated.Disconnection forced
Error:
SQL> startup
ORACLE instance started.

Total System Global Area  599785472 bytes
Fixed Size                  2098112 bytes
Variable Size             213912640 bytes
Database Buffers          377487360 bytes
Redo Buffers                6287360 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced.

I carried out following steps and those saved my day...!

cd $ORACLE_HOME/rdbms/admin
sqlplus "/as sysdba"
SQL>startup upgrade;
SQL>@catupgrd.sql
SQL>shutdown immediate;
SQL>startup;
SQL>@utlrp.sql



cheers :)




Monday, July 13, 2015

error while loading shared libraries: libcap.so.1: cannot open shared object file:

When I was installing single instance  ASM (grid infrastructure) Software .I came across with following error while running root.sh .

[root@dg2 ~]# /u01/app/11.2.0/grid/root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /u01/app/11.2.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]:
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
2015-07-06 22:47:51: Checking for super user privileges
2015-07-06 22:47:51: User has super user privileges
2015-07-06 22:47:51: Parsing the host name
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
/u01/app/11.2.0/grid/bin/clscfg.bin: error while loading shared libraries: libcap.so.1: cannot open shared object file: No such file or directory
Failed to create keys in the OLR, rc = 32512, 32512
OLR configuration failed

 
For that what i did was.It is required to install  relevant rpm which  provides above libcap.so.

 * compat-libcap1-1.10-1.x86_64
 * compat-libcap1-1.10-1.i386
 * libcap-*

yum install compat-libcap1-1.10-1.i386
yum install  compat-libcap1-1.10-1.x86_64 
yum install  libcap-* 

After this you may want to run root.sh again. Befor this you may want to deconfigure the instance configuration.


$GRID_HOME\crs\install\rootcrs.pl -deconfig  -force -verbose 
$GRID_HOME\crs\install\roothas.pl -deconfig  -force -verbose

 [root@dg2 install]# ./roothas.pl -deconfig -force -verbose
2015-07-06 23:09:17: Checking for super user privileges
2015-07-06 23:09:17: User has super user privileges
2015-07-06 23:09:17: Parsing the host name
Using configuration parameter file: ./crsconfig_params
CRS-4047: No Oracle Clusterware components configured.
CRS-4000: Command Stop failed, or completed with errors.
CRS-4047: No Oracle Clusterware components configured.
CRS-4000: Command Delete failed, or completed with errors.
CRS-4047: No Oracle Clusterware components configured.
CRS-4000: Command Stop failed, or completed with errors.
You must kill ohasd processes or reboot the system to properly
cleanup the processes started by Oracle clusterware
/u01/app/11.2.0/grid/bin/acfsdriverstate: line 51: /lib/acfstoolsdriver.sh: No such file or directory
/u01/app/11.2.0/grid/bin/acfsdriverstate: line 51: exec: /lib/acfstoolsdriver.sh: cannot execute: No such file or directory
Either /etc/oracle/olr.loc does not exist or is not readable
Make sure the file exists and it has read and execute access
/bin/dd: opening `': No such file or directory
Successfully deconfigured Oracle Restart stack
[root@dg2 install]#




Now you can run  GRID_HOME\crs\install

Wednesday, June 10, 2015

Active Data Guard Configuration

When Active Data guard is configured.You can use stand by site in Read only mode.By enabling Reporting on Stand by node It may reduce the weight on Primary site.Keep in remember You may required additional license to  configure this and .Bothe side as to be licensed according to same metrics.

On Primary Database

select status,instance_name,database_role from v$instance,v$database;

select max(sequence#) from v$archived_log;












 On Stand by database

select status,instance_name,database_role from v$database,v$instance;

select max(sequence#) from v$archived_log where applied='YES';











select process,status,sequence# from v$managed_standby;



































 alter database recover managed standby database cancel;

 alter database open;

select status,instance_name,database_role,open_mode from v$database,v$instance;

alter database recover managed standby database disconnect from session;


select process,status,sequence# from v$managed_standby;

















Now your database is configured with Active Data guard.

MRP process is Continue running  while stand by database is on read only mode.
Redo logs will be applied real time.



Wednesday, June 3, 2015

Data Guard Extended...Broker Method Configuartion.!!!

Make Sure Your Data guard configuration works fine..Logs shipping and Log applying is happening continuously.

My Primary Database is  DB11G
My Standby Database is  DB11G_STBY



Enable Broker Process
On Primary and Stand By server You need to enable broker process.

SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
 
 
 
Edit Listener.ora
Then you will edit listner.ora file on Both Primary and Stand by servers

 Make Sure that the GLOBAL_DBNAME is set to db_unique_name_DGMGRL.















Create Broker Configuration.

DGMGRL>Connect sys/oracle
DGMGRL>CREATE CONFIGURATION 'GenesisDR' AS PRIMARY DATABASE IS 'DB11G' CONNECT IDENTIFIER IS 'DB11G' ;












Add the Standby database to the configuration

 DGMGRL>ADD DATABASE  'DB11G_STBY'  AS CONNECT IDENTIFIER IS 'DB11G_STBY';





















Enable Configuration

DGMGRL>Enable Configuration

















View Primary and Stand by Server Properties.

DGMGRL>show database DB11G
DGMGRL>show database DB11G_STBY
even though its in the database configuration it says "object "db11g" not found ".


















So what I did was as follows;

single quotations were required.

DGMGRL>show database 'DB11G'
DGMGRL>show database 'DB11G_STBY'



















































Performing a switchover;
DGMGRL>switchover to 'DB11G_STBY'


























That is  it. :) now you can perform switch overs using broker utility. :)

Granting Views access to a Schema User.


When granting view access to a schema user on 11g database.I tried giving select on to a particular views.But it raised me an error.So  I used  "select_catalog_role" privilege.That works fine for me.

grant select_catalog_role to lahiru;



 :)




ORA-16139 media recovery required.


When Switching Stand by Database to Primary Database.This error message raised.

I carried out following on Stand by server.Then it was switched to primary with out any error.

SQL>Recover Managed Standby Database Finish;
SQL> Alter database Commit to switchover to Primary;












Monday, June 1, 2015

Export Script In Oracle DB "System" User

This is working Properly.


#!/bin/sh
STARTTIME=`date`
export ORACLE_SID=ORCL243
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
DATEFORMAT=`date +%Y%m%d`
export PATH=$PATH:$ORACLE_HOME/bin
DATEFORMAT=`date +%Y%m%d`
STARTTIME=`date`
exp userid=system/oracle@ORCL243 file=/u01/app/backup/`echo $ORACLE_SID`_`echo $DATEFORMAT`.dmp log=/u01/app/backup/`echo $ORACLE_SID`_`echo $DATEFORMAT`.log full=y compress=n statistics=none
ENDTIME=`date`

Monday, May 11, 2015

Deleting Archivlogs on Oracle Database Shell Script

Please add the following shell script(cleanup.sh) to the crontab of oracle user :)
this will run on every monday @3.30 p.m ,File name is cleanup.sh.Out put will be written to /tmp/clanup.lst
Add this on crontab -e
#crontab -e
30 15 * * 1 /home/oracle/cleanup.sh > /tmp/cleanup.lst
#vi /home/oracle/cleanup.ksh
 Add following this to the file

#!/bin/sh
export ORACLE_SID=ORCL
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
rman target sys/oracle@ORCL243 << HERE
delete noprompt archivelog all completed before 'sysdate-10';
HERE

Please Do remember to add  file permission to cleanup.sh 
chown -R oracle:oinstall /home/oracle/cleanup.sh
chmod -R 777 /home/oracle/cleanup.sh

Thursday, April 23, 2015

Change the Database SID


I am using Oracle Enterprise Linux 6.5 and Database version is 11.2.0.4
Initially My Database SID is ORCL  and I want it to change to ORCL2

Step 1 - You need to Back up the database using RMAN backup set or exp full back up

Step 2 -Mount it after clean shut down.
sql>shutdown immediate
sql>startup mount

Step 3 -Create pfile from the spfile;
sql>create pfile from spfile;

Step 4 -Use DBNEWID utility to change the DBNAME.Use SYSDBA privileges username and password and dbname parameter is the new DBname.
os>nid target=sys/oracle dbname=SAM2































Step 5 - shutdown the database
sql>shutdown immediate

Step 6 -Modify the DB_NAME parameter in the initialization parameter file
use either  one of methods

Method A
Directly edit initORCL.ora file  in $ORACLE_HOME\dbs location.
initORCL.ora
DB_NAME=ORCL2
startup mount pfile=' initORCL.ora'

Method B
The startup will result in an error but proceed anyway.
startup mount
alter system set db_name=ORCL2 scope=spfile;
shutdown immediate


Step 7 - Create a new password file:
os>orapwd file=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/pwdORCL2.ora password=password entries=10

Step 8- Rename the spfile init file to match the new name.

Step 9-Change the environment for the new DB NAME
export ORACLE_SID=ORCL2;

Step 10 - Alter the listener.ora and tnsnames.ora setting to match the new database name and restart the listener:

lsnrctl reload

ORCL2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCL2)
    )
  )

 Step 11 -
Open the database with RESETLOGS:

startup mount
alter database open resetlogs;

Step 12 - Backup the database.

Tuesday, April 21, 2015

Install Dbvisit without configuring mail.

Please  set the  parameters as follows  in  the dbv_ORCL.env file (dbv_ORACLE_SID.env) which is located in


C:\Program Files (x86)\Dbvisit\Standby\conf



#--------------------------------------------------------------------------
SEND_MAIL_FLAG = N
SEND_MAIL_FLAG_DR = N

#--------------------------------------------------------------------------


#==============================================================================
# ==> Mail settings.
#==============================================================================
[40 Mail Settings]
SUCCESSMAIL = N
SUCCESSMAIL_DR = N
ADMINS = N
MAILCFG_FROM = N
MAILCFG_FROM_DR = N
MAILCFG_SMTP_SERVER = N
MAILCFG_SMTP_SERVER_DR = N

Wednesday, April 1, 2015

Export with No Data.Only Table structure.

When exporting you have to mention ROWS=N in the  exp command


[oracle@testdb backup]$ exp test/test FILE=ods.dmp LOG=ods.log ROWS=N

Export: Release 11.2.0.4.0 - Production on Wed Apr 1 09:25:47 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8MSWIN1252 character set (possible charset conversion)
Note: table data (rows) will not be exported
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user TEST
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user TEST
About to export TEST's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export TEST's tables via Conventional Path ...
. . exporting table                             T1
. . exporting table                             T2
. . exporting table                             T3
. . exporting table                             T4
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.



------------------------------------------------------------------------------------------------------------------------
Import above backup  (DMP)with another user test2

[oracle@testdb backup]$ imp userid=test2/test2 FILE=ods.dmp LOG=impods.log GRANTS=N IGNORE=Y CONSTRAINTS=Y STATISTICS=NONE FROMUSER=test TOUSER=test2

Import: Release 11.2.0.4.0 - Production on Wed Apr 1 09:29:49 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


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

Export file created by EXPORT:V11.02.00 via conventional path

Warning: the objects were exported by TEST, not by you

import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses WE8MSWIN1252 character set (possible charset conversion)
Import terminated successfully without warnings.


















Tuesday, March 31, 2015

Oracle Enterprise Manager Cloud Control 12c Release 4 Installation on OEL 6.5

PS:When Installing 12EMGrid Controller .THis will implicitly install WebLogic Server 10.3.6

First of  all you will have to deconfig the Enterprise Manager Console (EM) of the EM Repository Database

[oracle@emgrid admin]$ emca -deconfig dbcontrol db -repos drop

STARTED EMCA at Mar 16, 2015 7:51:40 AM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle.  All rights reserved.

Enter the following information:
Database SID: ORCL
Listener port number: 1521
Password for SYS user: 
Password for SYSMAN user: 
Enterprise Manager configuration completed successfully
FINISHED EMCA at Mar 16, 2015 7:54:33 AM

Then Install following RPMs on OEL6.5

yum install make -y
yum install binutils -y
yum install gcc -y
yum install libaio -y
yum install glibc-common -y
yum install libstdc++ -y
yum install libXtst -y
yum install sysstat -y
yum install glibc-devel -y
yum install glibc -y
yum install libaio -y
yum install glibc-devel.i686 -y

Then you will have to configure database for  preticular values

SQL> ALTER SYSTEM SET processes=300 SCOPE=SPFILE;
System altered.
SQL> ALTER SYSTEM SET session_cached_cursors=200 SCOPE=SPFILE;
System altered.
SQL> ALTER SYSTEM SET sga_target=2G SCOPE=SPFILE;
System altered.
SQL> ALTER SYSTEM SET shared_pool_size=600M SCOPE=SPFILE;
System altered.
SQL> ALTER SYSTEM SET pga_aggregate_target=1G SCOPE=SPFILE;
System altered.
SQL> ALTER SYSTEM SET job_queue_processes=20 SCOPE=SPFILE;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>


Edit Following value for /etc/security/limits.conf  set the minimum value 4096

oracle   soft   nofile    4096 // default it was  1024

Then create  Following Folders

mkdir -p /u01/app/oracle/Middleware12C2
mkdir -p /u01/app/oracle/Agent12C2

Now Start running the Installer

cd /tmp/FULLGrid12c
./runInstaller.sh

This will start the installation window.

Unchecked the check box and click Next

















Choose skip ,Click Next

















Pre-chek is going on




 














  Create a new  Simple Enterprise Manager

















Choose the Middle ware Location and Agent Base Location.
Enter Host Name as a emgrid


















Enter Administrator Password  this is for weblogic Server administrations,Node Manager ,MDS administration,SYSMAN user account and OMS registration.
Enter database details for Repository.


















When you click Next  this will ask for a pop up  window.Click YES


















Click on Install.

















Installing ;)



















Enter following values to  .bash_profile
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
export OMS_HOME=/u01/app/oracle/Middleware12C2/oms
export AGENT_HOME=/u01/app/oracle/Agent12C2/core/12.1.0.4.0

# Start everything
$ORACLE_HOME/bin/dbstart $ORACLE_HOME
$OMS_HOME/bin/emctl start oms
$AGENT_HOME/bin/emctl start agent

# Stop everything
$OMS_HOME/bin/emctl stop oms -all
$AGENT_HOME/bin/emctl stop agent
$ORACLE_HOME/bin/dbshut $ORACLE_HOME
 

Friday, March 20, 2015

Enabling YUM Repository update on OEL6.5

Edit the /public-yum-ol6.repo file  resides in   /etc/yum.repos.d

vi /etc/yum.repos.d/public-yum-ol6.repo

enable the following locations

You Need to enable the following block's enabled value to 1 
[public_ol6_latest]
[public_ol6_UEK_latest]
















If you company has proxy settings,You may have to set the proxy settings like follows.

export http_proxy=ip:port/
ex:
export http_proxy=192.9.220.235:3128/

Then type  yum  list. You May list down all the rpms available.




Monday, March 2, 2015

Useful RMAN Commands(Deleting Archivelogs)


List archivelogs

RMAN> list archivelog all;
RMAN>list copy of archivelog  until time 'sysdate-7';
RMAN>list copy of archivelog  until sequence 1000;

Archivelog Deletion method

RMAN> delete archivelog all;
RMAN> delete archivelog  until time 'sysdate-7';
RMAN> delete archivelog until sequence 1000;
RMAN>delete archivelog from time 'sysdate-10';
RMAN> delete noprompt archivelog until time 'sysdate-10'; // this will not ask to confirm the   deletion.

Delete Obsolete Back ups

RMAN>delete obsolete;

RMAN>delete noprompt obsolete;//will not ask for conformation

Thursday, February 12, 2015

Configuring Managing Tape Drivers



Check weather correctly mounted the tape driver to OS

cat /proc/scsi/scsi


 vendor details are listed if properly configured.You can see that with


 Check the status of the tape 

mt –f  /dev/st0 status  or  mt –f  /dev/st1  status 

ps : If mt command does not work  you want to install  mt-st-0.9b-2.2.2.x86_64.rpm  rpm.

other possible  commands for  tape

 mt -f   /dev/st0  rewind
 mt -f   /dev/st0 erase
mt  -f   /dev/st0 rewind
mt  -f   /dev/st0 lock  //while copying to the disk if somebody ejects it 
mt  -f   /dev/st0 unlock

Copying Files to tape drive

tar –cvzf  /dev/st0  /u01/app/rman

mt –f  /dev/st0 unlock

mt –f /dev/st0 eject