Tuesday, December 19, 2017

Change Remote Window Password VPN via Mac

To Change Password on Window

Press fn-control-option-del

Extract range of lines from a text file in Unix

Input File    : orig-data-file
OutPut File : new-file

Line range 100 to 110



sed -n '100,110 p' orig-data-file > new-file
awk 'NR>=100&&NR<=110' orig-data-file > new-file
perl -ne 'print if 110..110' orin-data-file > new_file
-- get alert.log file for particular day
awk '/Jun 26/{c=6}c&&c --' alert_demo.log
grep -B1 -A1 'Jun 26' alert_demo.log




Wednesday, November 29, 2017

oratop

Pre- requisite

download oratop
set  oracle environment
helpful commands


oratop -i 5 / as sysdba
oratop -bdfi5 "/ as sysdba"
to remote database
oratop -f -i 5 sys/pass@db as sysdba


FOR HELP press h  and get the interactive key and enter in the main screen for example t is for table space






The UNION [ALL], INTERSECT, MINUS Operators

UNION Example The following statement combines the results of two queries with the UNION operator, which eliminates duplicate selected rows. This statement shows that you must match datatype (using the TO_CHAR function) when columns do not exist in one or the other table:
SELECT location_id, department_name "Department", 
   TO_CHAR(NULL) "Warehouse"  FROM departments
   UNION
   SELECT location_id, TO_CHAR(NULL) "Department", warehouse_name 
   FROM warehouses;
UNION ALL Example The UNION operator returns only distinct rows that appear in either result, while the UNION ALL operator returns all rows. The UNION ALL operator does not eliminate duplicate selected rows:
SELECT product_id FROM order_items
UNION
SELECT product_id FROM inventories;

SELECT location_id  FROM locations 
UNION ALL 
SELECT location_id  FROM departments;

location_id value that appears multiple times in either or both queries (such as '1700') is returned only once by the UNION operator, but multiple times by the UNION ALL operator.
INTERSECT Example The following statement combines the results with the INTERSECT operator, which returns only those rows returned by both queries:
SELECT product_id FROM inventories
INTERSECT
SELECT product_id FROM order_items;
MINUS Example The following statement combines results with the MINUS operator, which returns only unique rows returned by the first query but not by the second:
SELECT product_id FROM inventories
MINUS
SELECT product_id FROM order_items;

Monday, November 20, 2017

Extract DDL of scheduler job in oracle

set long 10000
select dbms_metadata.get_ddl('PROCOBJ','SCOTT_JOB','SCOTT') from dual;
Note : The job in sys cannot be extracted, so, copy it to another user and then extract
exec dbms_scheduler.copy_job('SYS.MY_JOB','SCOTT.MY_JOB');

Tuesday, August 29, 2017

Checking Swap Space Size and Usage



step 1
grep SwapTotal /proc/meminfo

step 2
vmstat 3 100
  The fields si and so show the amount of memory paged in from disk and paged out to disk, respectively

step 3
ls -al /var/log/sa | grep "Oct 12"
sar -W -f /var/log/sa/sa12
The fields pswpin and pswpout show the total number of pages brought in and out per second, respectively.

alternative example for yesterday
sar -f /var/log/sa/sa$(date +%d -d yesterday)

solutions
Adding more RAM.
Reducing the size of the SGA.
Increasing the size of the swap space

Wednesday, June 21, 2017

Oracle 12c agent won't start due to large amount of databases on the server


Oracle 12c agent won't start due to large amount of databases on the server

cd /ora01/oracle/product/agent12c/agent_inst/sysman/config

Change Xmx1024M    to Xmx2024M

< agentJavaDefines=-Xmx1024M -XX:MaxPermSize=96M
---
> agentJavaDefines=-Xmx2024M -XX:MaxPermSize=96M



Tuesday, June 20, 2017

Useful command to Check performance on linux server

network
   netstat -ptc

IO
  iostat

 ps commands in order to check for performance probelms:

1) Displaying top CPU_consuming processes:

 # ps aux|head -1; ps aux|sort -rn -k2|head -10
2) Displaying top 10 memory-consuming processes:

# ps aux|head -1; ps aux|sort -rn -k3|head
3) Displaying process in order of being penalized:

# ps -eakl|head -1; ps -eakl|sort -rn +5
4) Displaying process in order of priority:

# ps -eakl|sort -n +6|head
5) Displaying process in order of nice value

# ps -eakl|sort -n +7
6) Displaying the process in order of time

# ps vx|head -1;ps vx|grep -v PID|sort -rn +3|head -10
7) Displaying the process in order of real memory use

# ps vx|head -1; ps vx|grep -v PID|sort -rn +6|head -10
8) Displaying the process in order of I/O

# ps vx|head -1; ps vx|grep -v PID|sort -rn +4|head -10
9) Displaying WLM classes

# ps -a -o pid, user, class, pcpu, pmem, args
10) Determining process ID of wait processes:

# ps vg|head -1; ps vg|grep -w wait
11) Wait process bound to CPU

 # ps -mo THREAD -p
12) CPU usage with priority levels

 # topas -P


# for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; done

# ps auxww --sort=lstart | sort -r -k3,4 | head -20

# ps aux --sort -pcpu

# ps -ef --sort=start_time|head -20

# watch -n 1 "(ps aux | awk '\$8 ~ /D/  { print \$0 }')"

-- -----------------------------------------------------------------------

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');