Friday, 13 October 2017

How to start the service on DR if it does not Auto start After reboot the server


How to start the service on DR if it does not Auto start After reboot the server
  

Check the running services as 

srvctl status service -d ABC_WDC

Service ABC_APP is running on instance(s) ABC2,ABC3
Service ABC_BATCH is running on instance(s) ABC2,ABC3
Service ABC_BKP is running on instance(s) ABC2,ABC3
Service ABC_INTR is running on instance(s) ABC2,ABC3
Service ABC_USER is running on instance(s) ABC2,ABC3


Check for the backup service since issue is with the backup did not auto triggered after reboot 

> srvctl config  service -d ABC_WDC -s ABC_BKP
Service name: ABC_BKP
Service is enabled
Server pool: ABC_WDC_ABC_BKP
Cardinality: 3
Disconnect: false
Service role: PRIMARY  (This should not be primary this shuld be physical standby)
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: SESSION
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: ABC1,ABC2,ABC3
Available instances:
MWLDADM@twdrracancl01 - ABC1 - Linux - /home/oracle    <<< DR >>>
> srvctl modify  service -d ABC_WDC -s ABC_BKP -l PHYSICAL_STANDBY
MWLDADM@twdrracancl01 - ABC1 - Linux - /home/oracle    <<< DR >>>

Now change the role from primary to physical standby with below command -

> srvctl config  service -d ABC_WDC -s ABC_BKP

Service name: ABC_BKP
Service is enabled
Server pool: ABC_WDC_ABC_BKP
Cardinality: 3
Disconnect: false
Service role: PHYSICAL_STANDBY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: SESSION
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: ABC1,ABC2,ABC3
Available instances:
MWLDADM@twdrracancl01 - ABC1 - Linux - /home/oracle    <<< DR >>>
>

Start instance in a RAC database



Command - 


srvctl start instance -d db_unique_name -i instance_name

command to remove AUDIT



go to the AUDIT location -
cd /u01/app/12.1.0.2/grid/rdbms/audit

execute command as - 

find /u01/app/12.1.0.2/grid/rdbms/audit/ -type f -exec rm -f {} \; 

OEM Agent Deinstall

export AGENT_HOME=<Agent Home>


$AGENT_HOME/perl/bin/perl $AGENT_HOME/sysman/install/AgentDeinstall.pl -agentHome $AGENT_HOME

Friday, 6 October 2017

Get create user DDL with grants, privileges and roles

rem script: user_cr_ddl.sql
rem  Purpose: generate create user script with privs
rem
rem  Usage: user_cr_ddl 
rem
rem  Note:
rem   If ORA-31608 encountered, it means the user does not
rem   have grants in that category. Edit the spooled script
rem   as ncessary
rem
rem
SET LINESIZE 200
SET PAGESIZE 0 FEEDBACK off VERIFY off
-- SET TRIMSPOOL on
SET LONG 1000000
-- COLUMN ddl_string FORMAT A100 WORD_WRAP
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY',true);
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
COLUMN ddl FORMAT A4000
define username=&&1
spool &username._cr_ddl.sql
SELECT DBMS_METADATA.GET_DDL('USER', upper('&username') )  DDL FROM dual;
prompt -- Role
SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT', upper('&username'))  DDL from dual
where exists ( select 1 from dba_role_privs  where grantee=upper('&username') );
prompt -- Sys priv
SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT', upper('&username'))  DDL FROM  dual
where exists ( select 1 from dba_sys_privs  where grantee=upper('&username') );
prompt -- Object priv
SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT', upper('&username'))  DDL
FROM dual where exists ( select 1 from dba_tab_privs  where grantee=upper('&username') );
prompt -- tablespace quota
SELECT  DBMS_METADATA.GET_GRANTED_DDL('TABLESPACE_QUOTA',upper('&username')) DDL from dual
where exists ( select 1 from dba_ts_quotas  where username=upper('&username') );
spool off
exit

Query to find PID & SPID of LGWR

SQL> select pid, program from v$process where program like '%LGWR%';

       PID   PROGRAM
----------   ------------------------------------------------
        14    oracle@evXXXXX (LGWR)

SQL>SELECT p.spid, s.program FROM v$session s, v$process p WHERE s.paddr=p.addr  AND s.program LIKE '%LGWR%';


SPID                     PROGRAM
------------------------ ------------------------------------------------
26803                    oracle@evXXXXX (LGWR)

Add Data file

 ************************************************** Database status Tablespace Usage ASM Disk Group Usage(RAC) Backup Filesystem Usage Alert...