Thursday 30 July 2015

srvctl commands

To start and stop database in all nodes with single command
=======================================================================================
[oracle@rtmrac1 ~]$ ps -ef|grep smon
oracle     2845      1  0 08:44 ?        00:00:00 asm_smon_+ASM1
root       2907      1  2 08:44 ?        00:00:12 /u01/app/12.1.0/grid/bin/osysmond.bin
oracle    10556      1  0 08:48 ?        00:00:00 ora_smon_orcl1
[oracle@rtmrac1 ~]$ . oraenv
ORACLE_SID = [orcl1] ? +ASM1
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@rtmrac1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rtmrac1
Instance orcl2 is running on node rtmrac2
[oracle@rtmrac1 ~]$ srvctl stop database -d orcl
[oracle@rtmrac1 ~]$ srvctl status database -d orcl
Instance orcl1 is not running on node rtmrac1
Instance orcl2 is not running on node rtmrac2
[oracle@rtmrac1 ~]$ srvctl start database -d orcl
[oracle@rtmrac1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rtmrac1
Instance orcl2 is running on node rtmrac2

=============================================================
To stop/start database instance in one node:
=======================================================================
[oracle@rtmrac1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rtmrac1
Instance orcl2 is running on node rtmrac2
[oracle@rtmrac1 ~]$ srvctl stop instance -i orcl2 -d orcl
[oracle@rtmrac2 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rtmrac1
Instance orcl2 is not running on node rtmrac2

[oracle@rtmrac1 ~]$ srvctl start instance -i orcl2 -d orcl
[oracle@rtmrac1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rtmrac1
Instance orcl2 is running on node rtmrac2

stop/start ASM instance in one instance.

srvctl stop asm -n <node_name>

--to stop with force

srvctl stop asm -n <node_name> -f

--starting ASM instance

srvctl start asm -n <node name>

=================================================================================
To stop ASM in one node: Example
=================================================================================
[oracle@rtmrac2 ~]$ ps -ef|grep pmon
oracle     2367      1  0 08:44 ?        00:00:00 asm_pmon_+ASM2
oracle    22998      1  0 09:14 ?        00:00:00 ora_pmon_orcl2
oracle    24664  24610  0 09:16 pts/1    00:00:00 grep --color=auto pmon
[oracle@rtmrac2 ~]$ . oraenv
ORACLE_SID = [oracle] ? +ASM2
The Oracle base has been set to /u01/app/oracle
[oracle@rtmrac2 ~]$ srvctl stop instance -i orcl2 -d orcl
[oracle@rtmrac2 ~]$ ps -ef|grep pmon
oracle     2367      1  0 08:44 ?        00:00:00 asm_pmon_+ASM2
oracle    25367  24610  0 09:19 pts/1    00:00:00 grep --color=auto pmon
[oracle@rtmrac2 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rtmrac1
Instance orcl2 is not running on node rtmrac2
[oracle@rtmrac2 ~]$ srvctl status asm
ASM is running on rtmrac2,rtmrac1
[oracle@rtmrac2 ~]$ srvctl stop asm -n rtmrac2
PRCR-1014 : Failed to stop resource ora.asm
PRCR-1065 : Failed to stop resource ora.asm
CRS-2529: Unable to act on 'ora.asm' because that would require stopping or relocating 'ora.DATA.dg', but the force option was not specified
[oracle@rtmrac2 ~]$ srvctl stop asm -n rtmrac2 -f
[oracle@rtmrac2 ~]$ srvctl status asm
ASM is running on rtmrac1
[oracle@rtmrac2 ~]$ ps -ef|grep pmon
oracle    26471  24610  0 09:21 pts/1    00:00:00 grep --color=auto pmon
[oracle@rtmrac2 ~]$ srvctl start asm -n rtmrac2
[oracle@rtmrac2 ~]$ srvctl status asm
ASM is running on rtmrac2,rtmrac1
[oracle@rtmrac2 ~]$ ps -ef|grep pmon
oracle    27242      1  0 09:24 ?        00:00:00 asm_pmon_+ASM2
oracle    27400  24610  0 09:24 pts/1    00:00:00 grep --color=auto pmon
[oracle@rtmrac2 ~]$ srvctl start instance -i orcl2 -d orcl
[oracle@rtmrac2 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node rtmrac1
Instance orcl2 is running on node rtmrac2

----if you get error as bellow while starting ASM

[oracle@SDBORN21 ~]$ srvctl start asm -n SDBORN21

PRCR-1070 : Failed to check if resource ora.asm is registered
Cannot communicate with crsd


----follow as bellow

crsctl stat res -t -init

----check  ora.asm and ora.crsd are OFFLINE

crsctl start res ora.asm -init
crsctl start res ora.crsd -init

----if above commands succeeded then ASM must be up

ps -ef|grep pmon

----start database instance

srvctl start instance -i <instance_name>  -d <database_name>

------------------------------------------------------------
If you want to add database to HA(grid instrastructure):
------------------------------------------------------------
ex:
srvctl add database -d orcl -o /opt/oracle/product/12.2.0.1/dbhome_1 -p +DATA//PARAMETERFILE/spfile.644.1041511849
------------------------------------------------------------
modify the database startup option (mount/open).
-----------------------------------------------------------
if you set mount, if server is restarted database will open in mount mode.

srvctl modify database -db ORCL -startoption MOUNT





Tuesday 28 July 2015



info <extract-name>, showch

info ECACA1, showch
To make the replicat to go new file:
====================================
ALTER replicat RMSDPC22, EXTSEQNO 3886 extrba 0

to rollover to new file for ext:
=============================
alter extract ECACA3, ETROLLOVER

to switch the extract to next sequence and to thread 1
===========================================================
alter <extract-name>, extseqno 10, extrba 0

Tracing for process:
========================
send < rep name>, trace ./dirrpt/reptrace.trc
To generate new report file:
=============================
send RMSDPC11, report

to set find long running transation
===================================
WARNLONGTRANS 2HRS
WARNLONGTRANS 2hours
WARNLONGTRANS 1DAY
WARNLONGTRANS 600sec
WARNLONGTRANS 40s
bounded recovery:
===================
BR BROFF

========================
TRANLOGOPTIONS parameter with the PURGEORPHANEDTRANSACTIONS option to
enable the purging of orphaned transactions that occur when a node fails and Extract cannot capture the rollback
===================
DBOPTIONS DEFERREFCONST

ASM queries

#### To know free space  in disk group ##

SET LINESIZE  145
SET PAGESIZE  9999
SET VERIFY    off
COLUMN group_name             FORMAT a20           HEAD 'Disk Group|Name'
COLUMN sector_size            FORMAT 99,999        HEAD 'Sector|Size'
COLUMN block_size             FORMAT 99,999        HEAD 'Block|Size'
COLUMN allocation_unit_size   FORMAT 999,999,999   HEAD 'Allocation|Unit Size'
COLUMN state                  FORMAT a11           HEAD 'State'
COLUMN type                   FORMAT a6            HEAD 'Type'
COLUMN total_mb               FORMAT 999,999,999   HEAD 'Total Size (MB)'
COLUMN used_mb                FORMAT 999,999,999   HEAD 'Used Size (MB)'
COLUMN pct_used               FORMAT 999.99        HEAD 'Pct. Used'
SELECT
    name                                     group_name
  , sector_size                              sector_size
  , block_size                               block_size
  , allocation_unit_size                     allocation_unit_size
  , state                                    state
  , type                                     type
  , total_mb                                 total_mb
  , (total_mb - free_mb)                     used_mb
  , ROUND((1- (free_mb / total_mb))*100, 2)  pct_used
FROM
    v$asm_diskgroup
ORDER BY
    name;


To know the disk info:
========================

SELECT SUBSTR(d.name,1,16) AS asmdisk, d.mount_status, d.state,
     dg.name AS diskgroup FROM V$ASM_DISKGROUP dg, V$ASM_DISK d
     WHERE dg.group_number = d.group_number;


--- To check with single disk

SELECT dg.name,SUBSTR(d.name,1,16) AS asmdisk, d.mount_status,d.HEADER_STATUS,d.total_mb,d.free_mb
      AS diskgroup FROM V$ASM_DISKGROUP dg, V$ASM_DISK d
     WHERE dg.group_number = d.group_number and dg.name='<diskname>';

To find ASM file system:
==========================

SELECT fs_name, available_time, block_size, state, corrupt FROM V$ASM_FILESYSTEM;

To find Candidate/Formar disks:
============================

select name,path,lable,HEADER_STATUS from v$asm_disk where HEADER_STATUS not like 'MEMBER';

Adding disk to diskgroup:
=========================


ALTER DISKGROUP SKS0DB_DG ADD DISK 'ORCL:SKS0_DATA30' rebalance power 8;


For more queries Qeries LInk