Wednesday 30 November 2016

RAC \ crsctl \srvctl commands

1 . Clusterware Resource Status\start\stop commands Check  
============================================================  
crsctl status resource -t  
crsctl status res -t  
crsctl check crs  
crsctl start\stop crs    
(or)  
#/etc/init.d/init.crs start\stop
crsctl start/stop cluster -all    csr services on all nodes of clusterware (run as root)                


2. to check\start\stop ohasd configuration\status and enable autostart (run as root)  
============================================================  
crsctl config has  
crsctl check has                                
crsctl enable has                              
crsctl disable has
crsctl start has                                
crsctl stop has        
   
 
3. Check , start\stop individual component of RAC
========================================================================
crsctl check cssd  
crsctl check crsd  
crsctl check evmd  
crsctl check oprocd  
crsctl check ctss  
#/etc/init.d/init.cssd stop\start
#/etc/rc.d/init.d/init.evmd stop\start
#/etc/rc.d/init.d/init.cssd stop\start
#/etc/rc.d/init.d/init.crsd stop\start

4. to check the votedisk informations
========================================================================
crsctl -- to get help  
crsctl query crs activeversion    
crsctl query crs softwareversion [node_name]  
#crsctl check css votedisk
#crsctl query css votedisk -- lists the voting disks used by CSS
#crsctl add css votedisk PATH
#crsctl add css votedisk PATH -force -- if Clusterware is not running
#crsctl delete css votedisk PATH
#crsctl delete css votedisk PATH -force -- if Clusterware is not running
 
 
5. Status of a single instance  
========================================================================    
srvctl status instance -d orcl -i orcl2  
   
6. Check STATUS/configuration of  service    
====================================================================  
srvctl status service -d orcl -s orcltest  
srvctl config service -d orcl  
   
7. Check STATUS/configuration of resources (database/listner/nodeapplications/asm instance)  
============================================================  
srvctl status database -d ORCL  
srvctl config database -d orcl  
srvctl status listener -l  LISTENER_NAME    
srvctl status nodeapps -n node1  
$ srvctl status asm -n node1  
srvctl config asm -n node1  
#crsctl start\stop resources -- starts Clusterware resources
./crsctl start resource ora.DATA.dg
crsctl status resource
crsctl status resource -t
crsctl stat resource -t
   
8. Display the configuration for node applications - (VIP, GSD, ONS, Listener)  
==========================================================  
srvctl config nodeapps -n node1 -a -g -s -l  
   
   
9. LISTENER STATUS Check\START\STOP\config local and scan listener    
============================================================  
ps -ef | grep tns -- to find listener name    
srvctl status listener -l  LISTENER_NAME    
srvctl start listener -l LISTENER_NAME          
srvctl stop listener -l LISTENER_NAME  
srvctl config scan_listener  
   
   
10. Start / Stop All Instances with SRVCTL  
==============================================  
srvctl start database -d orcl  
srvctl stop database -d orcl  
   
11. List all configured databases  
================================  
srvctl config database  
   
12. check status and  start/stop nodesapps  
======================================================  
srvctl status nodeapps -n rac1  
 ./crs_stat -p ora.myrac1.LISTENER_MYRAC1.lsnr  
 srvctl stop nodeapps -n rac1  
srvctl start nodeapps -n rac1 

Sunday 21 September 2014

Enterprise Manager Grid Control Architecture

Although Enterprise Manager Grid Control is viewed as a single entity, technically, it
is built with the following software components

   1)      Oracle Management Agent (Management Agent)

Management Agent is an integral software component that is deployed on each
monitored host. It is responsible for monitoring all the targets running on those
hosts, communicating that information to the middle-tier Oracle Management
Service, and managing and maintaining the hosts and its targets.

Configuration file for Management Agent is $OH/ <hostname>_<sid>/ sysman/ config/ emd.properties. Configuration file for Management Agent is $OH/ <hostname>_<sid>/ sysman/ config/ emd.properties. Agent uploads managed data (from server its monitoring) to Management Service via HTTP Server (URL of management Service HTTP Server is defined by REPOSITORY_URL parameter in emd.properties)
     Management Agent software also includes inbuilt HTTP Listener (different from standalone HTTP Server) to accept messages(data) from Management Service and this URL is defined by parameter EMD_URL in emd.properties.

Management Agent Log & Trace files are in $AGENT_HOME (or $OH/ <hostname>_<sid>) / sysman/ emagent.log, emagent.trc, emagentfetchlet.log, emagentfetchlet.trc , emagent.nohup

   2)      Oracle Management Service (OMS)

OMS is a J2EE Web application that orchestrates with Management Agents to
discover targets, monitor and manage them, and store the collected information in
a repository for future reference and analysis. OMS also renders the user interface
for the Enterprise Manager Grid Control console. OMS is deployed to the Oracle
Middleware home, which is the parent directory that has the Oracle WebLogic
Server home, the Web tier instance files, and, optionally, one or more Oracle
homes.

 Configuration file for Management Service is $OH/<hostname>_<sid>/ sysman/ config/ emoms.properties.
               Repository connection details are defined by parameter emdRepSID, emdRepServer, emdRepConnectDescriptor and emdRepUser in emoms.properties
  Management Service also monitors Management Agent (to check its up and running), submit enterprise manager jobs and other functions using EMD_URL (Management Agent runs inbuilt HTTP listener) defined in emoms.properties

Management Service Log & Tracefiles are in $AS_HOME (or $OH/ <hostname>_<sid>)  / sysman/ emoms.log, emoms.trc

    3)      Oracle Management Repository (Management Repository)

Management Repository is the storage location where all the information collected
by the Management Agent gets stored. It consists of objects such as database jobs,
packages, procedures, views, and tablespaces.

Management Service connects to Management Repository using JDBC

    4)      Enterprise Manager Grid Control Console

Enterprise Manager Grid Control Console is the user interface you see after you
install Enterprise Manager Grid Control. With the help of the console, you can
monitor and administer your entire computing environment from one location on
the network. All the services within your enterprise, including hosts, databases,
listeners, application servers, and so on, are easily managed from one central


5. HTTP Server: recieve requests from webcache, pulls data from Repository via Management Serviceand return response back to Webcache. HTTP Server also receive data from Management Agents, forward it to Management Service to store them in Management Repository.

6. Webcache : acts as web accelerator; forward request from Users (console) to HTTP Server and response back from HTTP server to Users (Console)






.
Communication between Management Agent & Service

Management Agent connect to Management Service via HTTP Server of Grid Control Middleware where as Management Service connect directly (using HTTP protocol) to Management Agent (Agent software include inbuilt http server)


Reference:  Oracle Enterprise Manager Grid Control Basic Installation Guide 

Tuesday 16 September 2014

Restore standby database using incremental backup

   1)      Find the current scn of Standby database

select  current_scn from v$database;

CURRENT_SCN
-----------
    750098

    2)      Take incremental backup  on primary database  start from the scn  shown in step 1

BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750098 DATABASE
     FORMAT '/tmp/incr_standby/backup_%U';

   3)      Create control file backup  for standby

ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/oracle/standby_control.ctl';

   4)      Copy the incremental backup and control file backup from primary to secondary database

   5)      Check the status of standby and controlfile location

select open_mode , database_role ,name from v$database;

OPEN_MODE  DATABASE_ROLE    NAME
---------- ---------------- ---------
MOUNTED    PHYSICAL STANDBY ORCL

Select name , value from  v$parameter where name=’control_file’;

NAME            VALUE
--------------- --------------------------------------------------
control_files   /u01/app/oracle/oradata/orcl/control01.ctl, /u01/a
pp/oracle/flash_recovery_area/orcl/control02.ctl


    6)      Cancel recovery on standby  stop  standby database

 Alter database recover managed standby database cancel;
Database altered.

SQL>  shu immediate ;
    
     7)      Recover control file


rman target /

Restore  controlfile from ‘/tmp/incr_standby/stby.ctl';
startup mount


    8)      Catalog the backup  on standby database


catalog start with  '/tmp/incr_standby/';


    9)      Restore database

RMAN>  recover database noredo;


     10)   Start recover y on standby database

alter database recover managed standby database disconnect from session ;




Thursday 4 September 2014

Gateway connectivity (hetrogeneous ) from oracle to non-oracle databases .



Here we are connecting oracle to netizza same way we can connect  oracle and mysql

Step1: Ensure Unix ODBC Driver Manager is version 2.2.11 or higher.

[oracle@myhost-x1 ~]$
odbcinst --version
unixODBC 2.2.14

to check how to install unixODBC  on linux you can check here 


Step2: Define or append below environment variables in user’s .bash_profile : highlighted in  yellow

[oracle@myhost-x1 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


################ START: Entries at the time of ODBC installation ###############################

# User specific environment and startup programs

export TMP=/d2/db1/oracle/temp
export TEMPDIR=/d2/db1/oracle/temp
export ORACLE_BASE=/d2/db1/oracle/apps
export ORACLE_HOME=$ORACLE_BASE/product/db_1/11.2.0
export ORACLE_SID=DB1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib32:$ORACLE_HOME/lib:/usr/local/nz/lib:/usr/lib64
export LD_LIBRARY_PATH_32=$ORACLE_HOME/lib32
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:/bin:/usr/lib64/:$ORACLE_HOME/OPatch:/usr/local/nz/bin

export NZ_ODBC_INI_PATH=/etc
export ODBCSYSINI=/etc
export ODBCINI=/etc/odbc.ini

export PATH

################  END: Entries at the time of ODBC installation ###############################



Step3:
  • Go to the path $ NZ_ODBC_INI_PATH set above in .bash_profile (i.e cd $ NZ_ODBC_INI_PATH).
  • Login through root .( sudo su -) and Create odbc.ini using vi editor vi /etc/odbc.ini for server to be connected, in which DSN is defined like below. Please point to the right library file for ODBC.

[oracle@myhost-x1 ~]$ cat /etc/odbc.ini

[ODBC Data Sources]
NZSQL = NetezzaSQL

[NZSQL]
Driver                = /usr/local/nz/lib64/libnzodbc.so
Description           = NetezzaSQL ODBC
Servername            = 10.10.30.101
Port                  = 5480
Database              = xyz
Username              = abc
Password              = mypassword
ReadOnly              = false
ShowSystemTables      = false
LegacySQLTables       = false
LoginTimeout          = 0
QueryTimeout          = 0
DateFormat            = 1
NumericAsChar         = false
SQLBitOneZero         = false
StripCRLF             = false
securityLevel         = preferredUnSecured
caCertFile            =

[ODBC]
IANAAppCodePage=4
InstallDir=/opt/odbc32v51
Trace=0
TraceDll=/opt/odbc32v51/lib/odbctrac.so
TraceFile=odbctrace.out
UseCursorLib=0
[oracle@myhost-x1 ~]$

Test note 1: Now open another PuTTY session and check you can connect to non- oracle database using ODBC driver

[oracle@myhost-x1 ~]$
 isql -v NZSQL
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>


Till this point the ODBC setup is complete, you can go ahead at oracle end.

Test note 2:

[oracle@myhost-n1 gateway]$ echo $ORACLE_HOME
/d1/db1/oracle/apps/product/11.1.0/gateway
[oracle@myhost-n1 gateway]$ pwd
/d1/db1/oracle/apps/product/11.1.0/gateway
[oracle@myhost-n1 gateway]$ ./bin/dg4odbc

Oracle Corporation --- THURSDAY  APR 15 2010 06:37:17.144

Heterogeneous Agent Release 11.1.0.7.0 - 64bit Production  Built with
   Oracle Database Gateway for ODBC

Step 4: Prepare the 11g gateway heterogeneous instance. In our case we have kept instance name to DG4ODBC.

[oracle@myhost-n1 admin]$ pwd
/d1/db1/oracle/apps/product/11.1.0/gateway/hs/admin

[oracle@myhost-n1 admin]$ cat initDG4ODBC.ora

# This is a sample agent init file that contains the HS parameters that are
# needed for the Database Gateway for ODBC


HS_LANGUAGE=american_america.we8iso8859P1

#HS_FDS_TRACE_LEVEL = debug
HS_FDS_CONNECT_INFO = NZSQL
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so

#
# ODBC specific environment variables
#
set ODBCINI = /home/oracle/nz/odbc.ini

#HS_FDS_CHARACTER_SEMANTICS=TRUE

#
# Environment variables required for the non-Oracle system
#
#set <envvar>=<value>
HS_FDS_SUPPORT_STATISTICS=FALSE

Step 5: Create  gateway listener as below. Take care in specifying ENVS attribute.

trace_level_LISTENER_DB1=0

SID_LIST_LISTENER_DB1 =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /d1/db1/oracle/apps/product/db_1/11.2.0)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = DB1)
      (ORACLE_HOME = /d1/db1/oracle/apps/product/db_1/11.2.0)
    )
   (SID_DESC =
      (SID_NAME = DG4ODBC)
      (ORACLE_HOME =/d1/db1/oracle/apps/product/11.1.0/gateway)
      (ENVS = LD_LIBRARY_PATH=/usr/lib64/:/home/oracle/nz/lib:/d1/db1/oracle/apps/product/11.1.0/gateway/lib)
      (PROGRAM = dg4odbc)
    )
  )

LISTENER_DB1 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = aaaa.com)(PORT = 1522))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
    )
  )

Start this listener and proceed for remaining steps to be performed at 10g server only.

export ORACLE_HOME=:/d1/db1/oracle/apps/product/11.1.0/gateway
$ORACLE_HOME/bin/lsnrctl start LISTENER_DB1

Step 6: Create TNS entry for the 11g gateway instance( DG4ODBC in our case)

Note:      (HS=OK) should be after connect_data is closed


DG4ODBC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = aaaa.com)(PORT = 1522))
    )
    (CONNECT_DATA =
      (SID = dg4odbc)
   )
      (HS=OK)
  )


Test note 3: now tnsping the gateway  listener from database  home to check request is reaching to gateway  listener from db  home. If ok then go ahead.

Step 7:  connect to  database user, from where connectivity to non-oracle database is desired and create db link as below:

Create database link NZ connect to abc  identified by “mypassword” using ‘DG4ODBC’;

Step 8: Check connectivity oracle to natizza

 select * from test@NZ                                                                                                     .                                                                                             

You should be able to see data fetched from non-oracle database

If have issue, diagnosis  logs can be seen from 11g home location: $ORACLE_HOME/hs/admin/log

You need to uncomment #HS_FDS_TRACE_LEVEL = debug  and HS_FDS_TRACE_LEVEL = 4;  restart 11g listener and query again.

General issues:

- Driver manager older version is some times. Installing newer versions help.
- Some problems need compilation of Driver manager source code with some options like taking flag for 64bit data etc.
- Some problems require fix at Non Oracle database software end.
- Some problems required change the ODBC driver software.
- Some problems are fixed by changing the HS parameter in the initInstance.ora file of gateway.

 Real issue example