Вы находитесь на странице: 1из 6

Remote connection

sqlplus barts/l1sa@'dwdb1:1521/dwrep1'
dwdb1 is the server, 1521 is the port, and dwrep1 is the
database service name):
remote server is available or not
$ ping dwdb1
if ping works check remote server is reachable via the port
$ telnet IP <port>
$ telnet 192.168.254.215 1521
tnsping DWREP1 (use tnsping for geting port ip and port number) ****
If tnsping works, it means the remote listener is up and working. It doesn't nec
essarily mean that
the database is up, so you may need to log onto the database server to further i
nvestigate. If tnsping
doesn't work, then the listener or the database is down or hung. At this point,
I logon directly to the
server to perform additional checks such as a mount point filling up.
Disk full MOunt point
SQL> show parameter background_dump_dest
to find alert log
$ cd $ORACLE_BASE
Next, use the find command to attempt to locate the file:
$ find . -name "alert*.log"
$ ls -altr *.trc
vmstat
vmstat <interval in seconds> <number of intervals>
for a specific session
$ top u oracle d 5 n 25
delay and number of
iterations by using the -d and -n options
To determine the ID of the processes consuming the most
CPU resources
$ ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head
get top resouce consuming pid and logon to respective db to know wat type of pro
gram is asscoiated with it
select
'USERNAME : ' || s.username|| chr(10) ||
'OSUSER : ' || s.osuser || chr(10) ||
'PROGRAM : ' || s.program || chr(10) ||
'SPID : ' || p.spid || chr(10) ||
'SID : ' || s.sid || chr(10) ||
'SERIAL# : ' || s.serial# || chr(10) ||
'MACHINE : ' || s.machine || chr(10) ||
'TERMINAL : ' || s.terminal
from v$session s,
v$process p
where s.paddr = p.addr
and p.spid = '&PID_FROM_OS';
to get sql of highly consuming
select
'USERNAME : ' || s.username || chr(10) ||
'OSUSER : ' || s.osuser || chr(10) ||
'PROGRAM : ' || s.program || chr(10) ||
'SPID : ' || p.spid || chr(10) ||
'SID : ' || s.sid || chr(10) ||
'SERIAL# : ' || s.serial# || chr(10) ||
'MACHINE : ' || s.machine || chr(10) ||
'TERMINAL : ' || s.terminal || chr(10) ||
'SQL TEXT : ' || q.sql_text
from v$session s
,v$process p
,v$sql q
where s.paddr = p.addr
and p.spid = '&PID_FROM_OS'
and s.sql_id = q.sql_id;
in multiple database systems we can identify the top Oracle memory-using process
es
ps -e -o pmem,pid,user,tty,args | grep -i oracle | sort -n -k 1 -r | head
Finding Resource Intensive SQL Statements
Monitoring Real-Time SQL Execution Statistics
select * from (
select
a.sid session_id
,a.sql_id
,a.status
,a.cpu_time/1000000 cpu_sec
,a.buffer_gets
,a.disk_reads
,b.sql_text sql_text
from v$sql_monitor a
,v$sql b
where a.sql_id = b.sql_id
order by a.cpu_time desc)
where rownum <=20;
currently executing queries ordered by the number of disk reads:
select * from (
select
a.sid session_id
,a.sql_id
,a.status
,a.cpu_time/1000000 cpu_sec
,a.buffer_gets
,a.disk_reads
,substr(b.sql_text,1,15) sql_text
from v$sql_monitor a
,v$sql b
where a.sql_id = b.sql_id
and a.status='EXECUTING'
order by a.disk_reads desc)
where rownum <=20;
V$SQL_MONITOR
Using AWR
SQL> @?/rdbms/admin/awrrpt
AWR report for a specific SQL
@?/rdbms/admin/awrsqrpt.sql
Using ADDM
@?/rdbms/admin/addmrpt
Using ASH
The ASH report allows you to focus on short-lived SQL statements that have been
recently run and may
have only executed for a brief amount of time
@?/rdbms/admin/ashrpt
Detecting and Resolving Locking Issues
locking session SQL statement and the waiting SQL statement:
set lines 80
col blkg_user form a10
col blkg_machine form a10
col blkg_sid form 99999999
col wait_user form a10
col wait_machine form a10
col wait_sid form 9999999
col obj_own form a10
col obj_name form a10
col blkg_sql form a50
col wait_sql form a50
--
select
s1.username blkg_user
,s1.machine blkg_machine
,s1.sid blkg_sid
,s1.serial# blkg_serialnum
,s1.process blkg_OS_PID
,substr(b1.sql_text,1,50) blkg_sql
,chr(10)
,s2.username wait_user
,s2.machine wait_machine
,s2.sid wait_sid
,s2.serial# wait_serialnum
,s2.process wait_OS_PID
,substr(w1.sql_text,1,50) wait_sql
,lo.object_id blkd_obj_id
,do.owner obj_own
,do.object_name obj_name
from v$lock l1
,v$session s1
,v$lock l2
,v$session s2
,v$locked_object lo
,v$sqlarea b1
,v$sqlarea w1
,dba_objects do
where s1.sid = l1.sid
and s2.sid = l2.sid
and l1.id1 = l2.id1
and s1.sid = lo.session_id
and lo.object_id = do.object_id
and l1.block = 1
and s1.prev_sql_addr = b1.address
and s2.sql_address = w1.address
and l2.request > 0;
kill session
alter system kill session '1084,265';
$ ps -ef | grep 3153
Here is some sample output:
oracle 3153 1690 0 10:40:30 pts/1 0:00 sqlplus star2....
$ kill -9 3153
Troubleshooting Undo Tablespace Issues
select
to_char(begin_time,'MM-DD-YYYY HH24:MI') begin_time
,ssolderrcnt ORA_01555_cnt
,nospaceerrcnt no_space_cnt
,txncount max_num_txns
,maxquerylen max_query_len
,expiredblks blck_in_expired
from v$undostat
where begin_time > sysdate - 1
order by begin_time;
active sessions
SELECT SID, Serial#, UserName, Status, SchemaName, Logon_Time
FROM V$Session
WHERE
Status='ACTIVE' AND
UserName IS NOT NULL;
Identify the Session to be Killed
SET LINESIZE 100
COLUMN spid FORMAT A10
COLUMN username FORMAT A10
COLUMN program FORMAT A45
SELECT s.inst_id,
s.sid,
s.serial#,
p.spid,
s.username,
s.program
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE s.type != 'BACKGROUND';
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#';
SQL> ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;

Вам также может понравиться