What is the listener?
*Listener .ora file contains server-side network configuration parameter
*The Physical location of that file is "$ORACLE_HOME/newtwork/admin/"
Default Listener.ora contains
<listener_name> =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = <db_hostname>)(PORT = <port_name>))
)
)
)
SID_LIST_<listener_name> =
(SID_LIST =
(SID_DESC =
(SID_NAME = <DB_sid>)
(ORACLE_HOME = <Oracle_home Location>)
)
)
in above we have to replace host into machine "IP Address" and SID_Name
is Instance name
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.171)(PORT = 1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = proddb)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
)
Once we did the configuration we should start the listener again
i)To start listener
oracle@oracle11g~]$ lsnrctl start
II)To stop listener
oracle@oracle11g~]$ lsnrctl stop
III)To view status
oracle@oracle11g~]$ lsnrctl status
eitherway ,we can use the lsnrctl utility at os level
oracle@oracle11g~]$ lsnrctl
Start listener from that utility
LSNRCTL> start
Stop listener
LSNRCTL> stop
Status of the listener
LSNRCTL> status
Check listener at os level
At OS level, you can check background process tns
# ps –ef|grep tns
What is tnsname.ora file?
* It contains the information about the server where our remotely connect
database is present,the port number information,the DB name,the protocol
used.
* If a user wants to have connection entry into tnsname.ora
* It's located in "$ORACLE_HOME/network/admin" and edit
tnsname.ora
Testdb =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.121)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = Testdb)
)
)
here "Testdb" is connection string name host "192.168.0.121" port "1521"
the service name is "Testdb"
* Generally, most of the people will use the db name as service name
To check our tnsname configuration:
note : ensure the listener is up and running in order to accept the
connection
tnsping Testdb
Note : Difference B/w Listener.ora and Tnsname.ora ?
Tnsname.ora = The file contains the information about the server where
your database is present
Listener.ora=The file contains the information about the listener which is
the users have to connect from a different server.
Performance tuning
now HR is waiting for scott once we get problem issue from development
side first we ensure who are all in on-line
SQL> select sid,serial#,username from V$session;
SID SERIAL# USERNAME
---------- ---------- ------------------------------
1 5 SYS
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
20 2
22 2
24 3
25 99
29 3
30 12
31 16
32 50
33 3 HR
34 15 SCOTT
S-2: to wait out both user what is the status
SQL> select sid,event,seconds_in_wait,wait_time,state from V$session where
sid in('33','34');
SID EVENT
SECONDS_IN_WAIT WAIT_TIME STATE
----------
----------------------------------------------------------------
--------------- ---------- -------------------
33 enq: TX - row lock contention
829 0 WAITING
34 SQL*Net message from client
914 0 WAITING
here the problem is "ENQ:TX- row lock contention" means that sid is
waiting for someone
S-3: let us find cpu usage in system level
SQL> select event,time_waited from V$system_event where event='enq: TX -
row lock contention';
EVENT
TIME_WAITED
----------------------------------------------------------------
-----------
enq: TX - row lock contention
154390
SQL> /
EVENT
TIME_WAITED
----------------------------------------------------------------
-----------
enq: TX - row lock contention
158326
S-4: find which session is waiting for session level
SQL> select sid,event,time_waited from V$session_event where event='enq: TX
- row lock contention' and sid in ('33','34');
SID EVENT
TIME_WAITED
----------
---------------------------------------------------------------- -----------
33 enq: TX - row lock contention
175386
S-5: find out how the user has been logged
SQL> select
event,service_name,total_waits,time_waited,average_wait,max_wait from
V$service_event where event='enq: TX - row lock contention';
EVENT
SERVICE_NAME TOTAL_WAITS TIME_WAITED AVERAGE_WAIT MAX_WAIT
---------------------------------------------------------------
---------------------------------------------------------------- -----------
----------- ------------ ----------
enq: TX - row lock contention
SYS$USERS 1 190688 190688 0
S-6: to find the blocked session user
SQL> select BLOCKING_SESSION_STATUS, BLOCKING_INSTANCE,
BLOCKING_SESSION ,username from V$session where sid in('33','34');
BLOCKING_SE BLOCKING_INSTANCE BLOCKING_SESSION USERNAME
----------- ----------------- ----------------
------------------------------
VALID 1 34 HR
NO HOLDER SCOTT
S-7: to find the object _id because using this id we can find which has been
trouble
SQL> select ROW_WAIT_OBJ# "Object_id" ,ROW_WAIT_FILE# "realtive
fileno", ROW_WAIT_BLOCK# "Block Number" from V$session where sid in('33');
Object_id realtive fileno Block Number
---------- --------------- ------------
73181 4 151
S-8: to find the table problem occur table and owner
SQL> select owner,object_type,object_name,data_object_id from
dba_objects where object_id='73181';
OWNER OBJECT_TYPE OBJECT_NAME
DATA_OBJECT_ID
------------------------------ -------------------
------------------------------------------------------------------------------
--------------------------------------------- ----- --------------
SCOTT TABLE EMP
73181
S-9: to find out user details
SQL> select machine,osuser,username ,sid,service_name,logon_time from
V$session where sid in ('33','34');
MACHINE
OSUSER USERNAME SID SERVICE_NAME
LOGON_TIM
----------------------------------------------------------------
------------------------------ ------------------------------ ----------
---------------------------------------------------------------- ---------
goldengatesource
oracle HR 33 SYS$USERS
12-MAR-16
goldengatesource oracle
SCOTT 34 SYS$USERS
S-10: to sql_id for sql query which has be issued
SQL> select sql_id from V$session where sid in ('33','34');
SQL_ID
-------------
1dc2pgg0uh57f
S-11: finally we found the issue query which has be given hr user now we
ensure whether user scott is going to commit or kill that session get the
conformation application team .
SQL> select sql_fulltext from V$sql where sql_id='1dc2pgg0uh57f';
SQL_FULLTEXT
------------------------------------------------------------------------------
--
update scott.emp set sal=sal-3 where empno=7900
What is the difference between sga_max_size & sga_target ? or what is the
difference between memory_target & memory_max_target?
* sga_max_size set the over all amount of memory the sga can consume
but it is not dynamic
* sga_max_size is allowed to resize sga memory but sga_target is set some
value there the ASMM ie enabled it can be adjusted up to sga_max_size
parameter not more than it MEMORY_TARGET &
MEMORY_MAX_TARGET
* If we set sga_max_size and pga_aggregate_target to 0 then
memory_target(optionally memory_max_target) to non-zero value,oracle
will manage both sga nd pga with their limit
* if we set memory_targer set 1024mb oracle will manage sga and pga
components within itself
* if memory_target is non-zero -SGA_TARGET, SGA_MAX_SIZE, and
PGA_AGGREGATE_TARGET are set to 0, 60% of memory mentioned in
MEMORY_TARGET is allocated to SGA and rest 40% is kept for PGA.
-SGA_TARGET and PGA_AGGREGATE_TARGET are set to non-zero values,
these values will be considered minimum values.
-SGA_TARGET is set to non-zero value and PGA_AGGREGATE_TARGET is not
initialised . Still these values will be autotuned and
PGA_AGGREGATE_TARGET will be initialized with the value of
(MEMORY_TARGET-SGA_TARGET).
-PGA_AGGREGATE_TARGET is set and SGA_TARGET is not initialised. Still
both parameters will be autotuned. SGA_TARGET will be initialized to a value
of (MEMORY_TARGET-PGA_AGGREGATE_TARGET).