Thursday, June 25, 2015

Files`that need to use in Oracle Database administration

Useful Files In Linux

 Path    
 Description
 /etc/passwd
 User Settings
 /etc/group
  Group settings for users.  
 /etc/hosts
 Host name lookup information
 /etc/sysctl.conf                   
 Kernel parameters for Linux.                
 /var/log/messages
 Check System and error logs and messages
 /etc/oratab
  Oracle Registered instance (DBCA) 
 /etc/fstab
Files to check for File System entries
 /home/oracle/.bash_profile
Oracle user profile setting file in Linux.
 /proc/meminfo      
To determine To determine the RAM size
/etc/redhat- release
get the OS release information
 /etc/security/limits.conf
 Specify process and open files related limits 
 /etc/selinux/config
Enable or disable security feature.

Deinstall and cleanup Oracle 11g RAC instance

Deinstall and Clean-up  11g RAC installaton:


1) Shutdown all the DB and cluster services on all the RAC node
From root:
crsctl stop cluster -all
and
crsctl stop crs  on both node



2) From Oracle User:

Run the below:

soatsdb1.com[GSOATS1]$ cd /opt/oracle/grid/11.2.0/deinstall

soatsdb1.com[GSOATS1]$ ls
bootstrap.pl  deinstall  deinstall.pl  deinstall.xml  jlib  readme.txt  response  sshUserSetup.sh

soatsdb1.com[GSOATS1]$ ./deinstall
Checking for required files and bootstrapping ...
Please wait ...
Location of logs /opt/oracle/oraInventory/logs/

############ ORACLE DEINSTALL & DECONFIG TOOL START ############


######################### CHECK OPERATION START #########################
## [START] Install check configuration ##


Checking for existence of the Oracle home location /opt/oracle/grid/11.2.0
Oracle Home type selected for deinstall is: Oracle Grid Infrastructure for a Cluster
Oracle Base selected for deinstall is: /opt/oracle/product
Checking for existence of central inventory location /opt/oracle/oraInventory
Checking for existence of the Oracle Grid Infrastructure home /opt/oracle/grid/11.2.0
The following nodes are part of this cluster: soatsdb1,soatsdb2
Checking for sufficient temp space availability on node(s) : 'soatsdb1,soatsdb2'

## [END] Install check configuration ##

Traces log file: /opt/oracle/oraInventory/logs//crsdc.log
Enter an address or the name of the virtual IP used on node "soatsdb1"[null]
 >
soatsdb1-v.com
The following information can be collected by running "/sbin/ifconfig -a" on node "soatsdb1"
Enter the IP netmask of Virtual IP "10.30.207.150" on node "soatsdb1"[255.255.255.0]
 >

Enter the network interface name on which the virtual IP address "10.30.207.150" is active
 >

Enter an address or the name of the virtual IP used on node "soatsdb2"[10.30.207.150]
 >

The following information can be collected by running "/sbin/ifconfig -a" on node "soatsdb2"
Enter the IP netmask of Virtual IP "soatsdb2-vip" on node "soatsdb2"[255.255.255.0]
 >

Enter the network interface name on which the virtual IP address "soatsdb2-vip" is active
 >

Enter an address or the name of the virtual IP[]
 >


Network Configuration check config START

Network de-configuration trace file location: /opt/oracle/oraInventory/logs/netdc_check2012-02-02_11-59-38-PM.log

Network Configuration check config END

Asm Check Configuration START

ASM de-configuration trace file location: /opt/oracle/oraInventory/logs/asmcadc_check2012-02-02_11-59-40-PM.log

ASM configuration was not detected in this Oracle home. Was ASM configured in this Oracle home (y|n) [n]: n
ASM was not detected in the Oracle Home

######################### CHECK OPERATION END #########################


####################### CHECK OPERATION SUMMARY #######################
Oracle Grid Infrastructure Home is: /opt/oracle/grid/11.2.0
The cluster node(s) on which the Oracle home deinstallation will be performed are:soatsdb1,soatsdb2
Oracle Home selected for deinstall is: /opt/oracle/grid/11.2.0
Inventory Location where the Oracle home registered is: /opt/oracle/oraInventory
ASM was not detected in the Oracle Home
Do you want to continue (y - yes, n - no)? [n]: y
A log of this session will be written to: '/opt/oracle/oraInventory/logs/deinstall_deconfig2012-02-02_11-56-20-PM.out'
Any error messages from this session will be written to: '/opt/oracle/oraInventory/logs/deinstall_deconfig2012-02-02_11-56-20-PM.err'

######################## CLEAN OPERATION START ########################
ASM de-configuration trace file location: /opt/oracle/oraInventory/logs/asmcadc_clean2012-02-02_11-59-55-PM.log
ASM Clean Configuration END

Network Configuration clean config START

Network de-configuration trace file location: /opt/oracle/oraInventory/logs/netdc_clean2012-02-02_11-59-55-PM.log

De-configuring Naming Methods configuration file on all nodes...
Naming Methods configuration file de-configured successfully.

De-configuring Local Net Service Names configuration file on all nodes...
Local Net Service Names configuration file de-configured successfully.

De-configuring Directory Usage configuration file on all nodes...
Directory Usage configuration file de-configured successfully.

De-configuring backup files on all nodes...
Backup files de-configured successfully.

The network configuration has been cleaned up successfully.

Network Configuration clean config END


---------------------------------------->

The deconfig command below can be executed in parallel on all the remote nodes. Execute the command on  the local node after the execution completes on all the remote nodes.

Run the following command as the root user or the administrator on node "soatsdb2".

/tmp/deinstall2012-02-02_11-56-11PM/perl/bin/perl -I/tmp/deinstall2012-02-02_11-56-11PM/perl/lib -I/tmp/deinstall2012-02-02_11-56-11PM/crs/install /tmp/deinstall2012-02-02_11-56-11PM/crs/install/rootcrs.pl -force  -deconfig -paramfile "/tmp/deinstall2012-02-02_11-56-11PM/response/deinstall_Ora11g_gridinfrahome1.rsp"

Run the following command as the root user or the administrator on node "soatsdb1".

/tmp/deinstall2012-02-02_11-56-11PM/perl/bin/perl -I/tmp/deinstall2012-02-02_11-56-11PM/perl/lib -I/tmp/deinstall2012-02-02_11-56-11PM/crs/install /tmp/deinstall2012-02-02_11-56-11PM/crs/install/rootcrs.pl -force  -deconfig -paramfile "/tmp/deinstall2012-02-02_11-56-11PM/response/deinstall_Ora11g_gridinfrahome1.rsp" -lastnode

Press Enter after you finish running the above commands

<----------------------------------------


---------------------------------------->

The deconfig command below can be executed in parallel on all the remote nodes. Execute the command on  the local node after the execution completes on all the remote nodes.

Press Enter after you finish running the above commands

<----------------------------------------

Setting the force flag to false
Setting the force flag to cleanup the Oracle Base
Oracle Universal Installer clean START

Detach Oracle home '/opt/oracle/grid/11.2.0' from the central inventory on the local node : Done

Delete directory '/opt/oracle/grid/11.2.0' on the local node : Done

The Oracle Base directory '/opt/oracle/product' will not be removed on local node. The directory is in use by Oracle Home '/opt/oracle/product/11.2.0'.

Detach Oracle home '/opt/oracle/grid/11.2.0' from the central inventory on the remote nodes 'soatsdb2' : Done

Delete directory '/opt/oracle/grid/11.2.0' on the remote nodes 'soatsdb2' : Done

The Oracle Base directory '/opt/oracle/product' will not be removed on node 'soatsdb2'. The directory is in use by Oracle Home '/opt/oracle/product/11.2.0'.

Oracle Universal Installer cleanup was successful.

Oracle Universal Installer clean END


## [START] Oracle install clean ##

Clean install operation removing temporary directory '/tmp/deinstall2012-02-02_11-56-11PM' on node 'soatsdb1'
Clean install operation removing temporary directory '/tmp/deinstall2012-02-02_11-56-11PM' on node 'soatsdb2'

## [END] Oracle install clean ##


######################### CLEAN OPERATION END #########################


####################### CLEAN OPERATION SUMMARY #######################
Oracle Clusterware is stopped and successfully de-configured on node "soatsdb2"
Oracle Clusterware is stopped and successfully de-configured on node "soatsdb1"
Oracle Clusterware is stopped and de-configured successfully.
Successfully detached Oracle home '/opt/oracle/grid/11.2.0' from the central inventory on the local node.
Successfully deleted directory '/opt/oracle/grid/11.2.0' on the local node.
Successfully detached Oracle home '/opt/oracle/grid/11.2.0' from the central inventory on the remote nodes 'soatsdb2'.
Successfully deleted directory '/opt/oracle/grid/11.2.0' on the remote nodes 'soatsdb2'.
Oracle Universal Installer cleanup was successful.

Oracle deinstall tool successfully cleaned up temporary directories.
#######################################################################


############# ORACLE DEINSTALL & DECONFIG TOOL END #############

soatsdb1.com[GSOATS1]$


3) run the given command on

Node 2:

[root@soatsdb2 ~]# /tmp/deinstall2012-02-02_11-56-11PM/perl/bin/perl -I/tmp/deinstall2012-02-02_11-56-11PM/perl/lib -I/tmp/deinstall2012-02-02_11-56-11PM/crs/install /tmp/deinstall2012-02-02_11-56-11PM/crs/install/rootcrs.pl -force  -deconfig -paramfile "/tmp/deinstall2012-02-02_11-56-11PM/response/deinstall_Ora11g_gridinfrahome1.rsp"
Using configuration parameter file: /tmp/deinstall2012-02-02_11-56-11PM/response/deinstall_Ora11g_gridinfrahome1.rsp
PRCR-1119 : Failed to look up CRS resources of ora.cluster_vip_net1.type type
PRCR-1068 : Failed to query resources
Cannot communicate with crsd
PRCR-1070 : Failed to check if resource ora.gsd is registered
Cannot communicate with crsd
PRCR-1070 : Failed to check if resource ora.ons is registered
Cannot communicate with crsd

CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4000: Command Stop failed, or completed with errors.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'soatsdb2'
CRS-2673: Attempting to stop 'ora.mdnsd' on 'soatsdb2'
CRS-2673: Attempting to stop 'ora.crf' on 'soatsdb2'
CRS-2677: Stop of 'ora.mdnsd' on 'soatsdb2' succeeded
CRS-2677: Stop of 'ora.crf' on 'soatsdb2' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'soatsdb2'
CRS-2677: Stop of 'ora.gipcd' on 'soatsdb2' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'soatsdb2'
CRS-2677: Stop of 'ora.gpnpd' on 'soatsdb2' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'soatsdb2' has completed
CRS-4133: Oracle High Availability Services has been stopped.
Successfully deconfigured Oracle clusterware stack on this node
[root@soatsdb2 ~]#


4) Run the given command on

Node 1:


[root@soatsdb1 deinstall]# /tmp/deinstall2012-02-02_11-56-11PM/perl/bin/perl -I/tmp/deinstall2012-02-02_11-56-11PM/perl/lib -I/tmp/deinstall2012-02-02_11-56-11PM/crs/install /tmp/deinstall2012-02-02_11-56-11PM/crs/install/rootcrs.pl -force  -deconfig -paramfile "/tmp/deinstall2012-02-02_11-56-11PM/response/deinstall_Ora11g_gridinfrahome1.rsp" -lastnode
Using configuration parameter file: /tmp/deinstall2012-02-02_11-56-11PM/response/deinstall_Ora11g_gridinfrahome1.rsp

CRS-5702: Resource 'ora.cssd' is already running on 'soatsdb1'
CRS-4000: Command Start failed, or completed with errors.
CSS startup failed with return code 1
PRCR-1068 : Failed to query resources
Cannot communicate with crsd
PRCR-1068 : Failed to query resources
Cannot communicate with crsd
PRCR-1068 : Failed to query resources
Cannot communicate with crsd
PRCR-1068 : Failed to query resources
Cannot communicate with crsd
PRCR-1119 : Failed to look up CRS resources of ora.cluster_vip_net1.type type
PRCR-1068 : Failed to query resources
Cannot communicate with crsd
PRCR-1070 : Failed to check if resource ora.gsd is registered
Cannot communicate with crsd
PRCR-1070 : Failed to check if resource ora.ons is registered
Cannot communicate with crsd

CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4000: Command Stop failed, or completed with errors.
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4000: Command Delete failed, or completed with errors.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'soatsdb1'
CRS-2673: Attempting to stop 'ora.crsd' on 'soatsdb1'
CRS-2677: Stop of 'ora.crsd' on 'soatsdb1' succeeded
CRS-2673: Attempting to stop 'ora.ctssd' on 'soatsdb1'
CRS-2673: Attempting to stop 'ora.mdnsd' on 'soatsdb1'
CRS-2677: Stop of 'ora.mdnsd' on 'soatsdb1' succeeded
CRS-2677: Stop of 'ora.ctssd' on 'soatsdb1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'soatsdb1'
CRS-2677: Stop of 'ora.cssd' on 'soatsdb1' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'soatsdb1'
CRS-2677: Stop of 'ora.gipcd' on 'soatsdb1' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'soatsdb1'
CRS-2677: Stop of 'ora.gpnpd' on 'soatsdb1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'soatsdb1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
Successfully deconfigured Oracle clusterware stack on this node
[root@soatsdb1 deinstall]#


5) run below command on all the node.

[root@soatsdb1 stage]# rm /etc/oracle/*
rm: cannot lstat `/etc/oracle/*': No such file or directory
[root@soatsdb1 stage]#
[root@soatsdb1 stage]# rm -f /etc/init.d/init.cssd
[root@soatsdb1 stage]# rm -f /etc/init.d/init.crs
[root@soatsdb1 stage]# rm -f /etc/init.d/init.crsd
[root@soatsdb1 stage]# rm -f /etc/init.d/init.evmd
[root@soatsdb1 stage]# rm -f /etc/rc2.d/K96init.crs
[root@soatsdb1 stage]# rm -f /etc/rc2.d/S96init.crs
[root@soatsdb1 stage]# rm -f /etc/rc3.d/K96init.crs
[root@soatsdb1 stage]# rm -f /etc/rc3.d/S96init.crs
[root@soatsdb1 stage]# rm -f /etc/rc5.d/K96init.crs
[root@soatsdb1 stage]# rm -f /etc/rc5.d/S96init.crs
[root@soatsdb1 stage]# rm -Rf /etc/oracle/scls_scr
[root@soatsdb1 stage]# rm -f /etc/inittab.crs
[root@soatsdb1 stage]# ps -ef | grep crs
root      7139 34131  0 10:54 pts/5    00:00:00 grep crs
[root@soatsdb1 stage]# ps -ef | grep evm
root      7143 34131  0 10:54 pts/5    00:00:00 grep evm
[root@soatsdb1 stage]# ps -ef | grep css
root      7146 34131  0 10:54 pts/5    00:00:00 grep css
[root@soatsdb1 stage]# rm -f /var/tmp/.oracle
[root@soatsdb1 stage]# rm -f /tmp/.oracle
[root@soatsdb1 stage]#


6) Any files should not be there if deinstall has completed without any failure.

7) This will also delete all the contents which is on grid home.

8) We only need to remove ORALCE_HOME with rm command.

Data guard related issues and its fixes

If error is   Warning: ORA-16789: standby redo logs not configured

DGMGRL> DGMGRL> show configuration

Configuration - abcprd

  Protection Mode: MaxPerformance
  Databases:
    fc_abcprd - Primary database
      Warning: ORA-16789: standby redo logs not configured

    dr_abcprd - Physical standby database
      Error: ORA-16525: the Data Guard broker is not yet available

Fast-Start Failover: DISABLED

Configuration Status:
ERROR

DGMGRL>

Add Standby redo log group on to  Primary db as well as DR site:

SQL> ALTER DATABASE ADD STANDBY LOGFILE '/oradata/ABCPRD/stdby_redo04.log' size 50M;
SQL>  ALTER DATABASE ADD STANDBY LOGFILE '/oradata/ABCPRD/stdby_redo05.log' size 50M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/oradata/ABCPRD/stdby_redo06.log' size 50M;

And on  DR Site: 

SQL> alter database recover managed standby database cancel;

SQL>  ALTER DATABASE ADD STANDBY LOGFILE '/oradata/ABCPRD/stdby_redo04.log' size 50M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/oradata/ABCPRD/stdby_redo05.log' size 50M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE '/oradata/ABCPRD/stdby_redo06.log' size 50M;

After the above steps completion start DR in managed recovery:

SQL> alter database recover managed standby database disconnect from session;

On primary now run the dgmgrl :

DGMGRL>  show configuration;

Configuration - abcprd

  Protection Mode: MaxPerformance
  Databases:
    fc_abcprd - Primary database
    dr_abcprd - Physical standby database (disabled)

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

If error is below after above steps then on Primary site

Warning: ORA-16826: apply service state is inconsistent with the DelayMins property

DGMGRL> remove database DR_ABCPRD;
Removed database "dr_abcprd" from the configuration
DGMGRL> add database DR_ABCPRD as connect identifier is  DR_ABCPRD maintained as physical;
Database "dr_abcprd" added

Then Run :

Show configuration

It should not show any error message after that.  But if you are still facing any issue then please leave a message to me, will try to help you. 


Regards,
Amaresh

Wednesday, June 24, 2015

Script to list missing and INVALID Objects in the database

REM Script to list missing and INVALID Objects in the database
REM
REM      MISSING.SQL                                                  
REM
REM      This script recompiles all objects that have become invalidated    
REM
REM      It should be run as SYS or SYSTEM
REM

set pagesize 0
set linesize 120
set feedback off
set trimspool on
set termout on

spool missing.txt

select A.Owner Oown,
       A.Object_Name Oname,
       A.Object_Type Otype,
       'Miss Pkg Body' Prob
  from DBA_OBJECTS A
 where A.Object_Type = 'PACKAGE'
   and A.Owner not in ('SYS','SYSTEM')
   and not exists
        (select 'x'
           from DBA_OBJECTS B
          where B.Object_Name = A.Object_Name
            and B.Owner = A.Owner
            and B.Object_Type = 'PACKAGE BODY')
union
select Owner Oown,
       Object_Name Oname,
       Object_Type Otype,
       'Invalid Obj' Prob
  from DBA_OBJECTS
 where Owner not in ('SYS','SYSTEM')
   and Status != 'VALID'
 order by 1,4,3,2
/
spool off

Convert snapshot standby database to Physical standby database: Dataguard 11gR2

Step 1 SQL> shutdown immediate; Step 2 SQL> startup nomount Step 3 SQL> alter database mount; Step 4 SQL>  ALTER DATABASE CONV...