Tuesday, June 20, 2017

Linux "tr" Command Examples





Translate upper case to lower
tr A-Z a-z < inputfile > outputfile
cat inputfile|tr A-Z a-z

Translate braces into parenthesis
tr '{}' '()' < inputfile > outputfile

Translate white-space to tabs
 echo "This is for testing" | tr [:space:] '\t'

Squeeze repetition of characters using -s
echo "This   is   for testing" | tr [:space:] '\t'

We can use -s option to squeeze the repetition of characters.
echo "This   is   for testing" | tr -s [:space:] '\t'

convert multiple continuous spaces with a single space
echo "This  is  for testing" | tr -s [:space:] ' '

Delete specified characters using -d option
echo "the geek stuff" | tr -d 't'

To remove all the digits from the string, use
echo "my username is 432234" | tr -d [:digit:]

Complement the sets using -c option
echo "my username is 432234" | tr -cd [:digit:]

Remove all non-printable character from a file
tr -cd [:print:] < file.txt

Join all the lines in a file into a single line
 tr -s '\n' ' ' < file.txt

How to Start/Stop CRS

As root - set enviornment ( . oraenv and at prompt enter grid and press enter)
# cd /ora01/grid/11.2.0.4/grid/bin
# . ./oraenv
Type in grid

To stop Grid
# crsctl stop crs (will do one node at a time)
# ./crs_stop -all   (this will shutdown grid on both nodes, use only if directed by DBA)

To start grid
# ./crsctl start crs

To disable grid autostart
# crsctl disable crs  # to disable

To enable grid autostart(whenever we need to enable and start, the sequence is first enable then start)
# crsctl enable crs   # to enable

To check the grid status
# crsctl config crs

###FOR STANDALONE ORACLE SERVERS###

crsctl disable has
crsctl config has
crsctl enable has
crs_stat -t -v

to stop
crsctl stop has -f

to start
crsctl start has

Wednesday, May 24, 2017

Resource busy; not able to modify the table

step 1 // identify object id
 select OBJECT_ID from dba_objects where OBJECT_NAME='EMP

step 2 // identify who is locking
select
   c.owner,
   c.object_name,
   c.object_type,
   b.sid,
   b.serial#,
   b.status,
   b.osuser,
   b.machine
from
   gv$locked_object a ,
   gv$session b,
   dba_objects c
where
   b.sid = a.session_id
and
   a.object_id = c.object_id
   and c.object_id=1101;
 
 
solution
steps 3  //  modify ddl table lock time for 10 seconds
alter session set ddl_lock_timeout = 10;

step 4 // modify table
alter table // full modify table command

Deleting tons of files in Linux (Argument list too long)

option 1
find /oramisc01/oracle/demo/adump -name "*aud"  -type f -mtime +1 -exec rm {} \;

option 2
find  /oramisc01/oracle/demo/adump  -name "aud*" -type f  -delete

option 3
find  /oramisc01/oracle/demo/adump  -name "aud*" -type f -mtime +1 |xargs rm -rf

option 4
mkdir empty_dir
rsync -a -delete empty_dir/ yourdirectory/


option 5
perl -e 'for(<*aud>){((stat)[9]<(unlink))}'




Friday, May 19, 2017

data guard - Check redo transport lag and apply lag in standby database

-- Check redo transport lag and apply lag in standby database


# standby
  
  archive log list
  
  col name for a13
  col value for a20
  col unit for a30
  set lines 122
  select name, value, unit, time_computed from v$dataguard_stats where name in ('transport lag','apply lag');