The transparent network substrate a proprietary oracle computer networkin technology,supports homogeneous peer-to-peer connectivity on top of other networking technologies such as tcp/ip and named pipes.
Tns operates mainly for connection to oracle databases.
Which is the responsible of connecctions establishment.
TNS ENTRY:-
[oracle@nijam]$netca
Step1:- To click the local net service name configuration and click next button.
Step2:-To click the add and click next button.
Step3:-To add service name and click next button.
Step4:-To click the tcp and click next button.
Step5:-To add host name and click next button.
Step6:-To click the no and click next button.
Step7:-To add net service name and click next button.
The oracle database listener is the server process that provides basic network connectivity for clients,application servers,and other databases to an oracle databases.
In addition to database ,the listener can also be configured to support binary executables.
The listener listens on a specific network port(default 1521) and forwards network connections to the database.
The listener configuration, stored in the listener.ora file.
[oracle@nijam]$netca
Step1:-To click the listener configuration and click next button.
Lsnctl>start —>a starts the listener with the name specified.will be used.
Lsnrctl>stop —>a stop the listener.
Lsnrctl>status —>information about the listener.
Lsnrctl>reload —>a forces a read of the configuration file in orderfor new settings to take effect without stopping and starting the listener.
Lsnrctl>exit —>a the lsnrctl utility.
check whether port is available or not.
[oracle@nijam]$netstat -tunlp|grep 1521.
TNS_ADMIN is an environment variable that points to the directory where the SQL*Net configuration files (like sqlnet.ora and tnsnames.ora) are located.
VLAN (virtual local area network) is very useful concept as you can easily separate device management from users by using appropriate network devices and configuration.
Preparations Install user mode programs to enable VLANs on your ethernet devices: $ sudo apt-get install vlan Load 8021q module (IEEE 802.1Q):
$ sudo modprobe 8021q To load 8021q module at the boot time add it to the /etc/modules file:
$ sudo echo 8021q >> /etc/modules $ cat /etc/modules # /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with “#” are ignored. # Parameters can be specified after the module name. oop 8021q Solution For Temporary Create VLAN 700 on the eth0 device: $ sudo vconfig add eth0 700
Add VLAN with VID == 700 to IF -:eth0:- Set IP address (10.100.10.77 netmask 255.255.255.0 in this example): $ sudo ifconfig eth0.700 10.100.10.77/24
Created interface is named as eth0.700: $ sudo ifconfig -a eth0 Link encap:Ethernet HWaddr 84:8f:69:b0:fa:0a UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:49
eth0.700 Link encap:Ethernet HWaddr 84:8f:69:b0:fa:0a inet addr:10.100.10.77 Bcast:10.100.10.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:11 errors:0 dropped:0 overruns:0 frame:0 TX packets:53 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:884 (884.0 B) TX bytes:3158 (3.0 KiB) Now you can access other hosts available in VLAN 700: $ ping -c 1 10.100.10.1 PING 10.100.10.1 (10.100.10.1) 56(84) bytes of data. 64 bytes from 10.100.10.1: icmp_req=1 ttl=64 time=1.28 ms
— 10.100.10.1 ping statistics — 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 1.282/1.282/1.282/0.000 ms To remove VLAN 700 from the eth0 interface execute command:
$ sudo vconfig rem eth0.700 Removed VLAN -:eth0.700:- Permanent solution To create VLAN at the boot time you need to get familiar with /etc/network/interfaces configuration file (man interfaces, man vlan-interfaces).
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).
# The loopback network interface auto lo iface lo inet loopback
To create VLAN 700 on the eth0 interface at the boot time just add similar configuration: # add vlan 700 on eth0 – static IP address auto eth0.700 iface eth0.700 inet static address 10.100.10.77 netmask 255.255.255.0
1) What’s the difference between soft link and hard link?
Ans: A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system, because they share same inode number and an inode table is unique to a file system, both must be on the same file system.
2) How you will read a file from shell script? Ans: while read line do echo $line done < file_name
3) 3. What’s the use of umask? ANS: Will decide the default permissions for files.
4) What is crontab and what are the arguments? Ans: The entries have the following elements: field allowed values —– ————– minute 0-59 hour 0-23 day of month 1-31 month 1-12 day of week 0-7 (both 0 and 7 are Sunday) user Valid OS user command Valid command or script
? ? ? ? ? command | | | | |_________day of the week (0-6, 0=Sunday) | | | |___________month (1-12) | | |_____________day of the month (1-31) | |_______________hour (0-23) |_________________minute (0-59)
5) How to find operating system (OS) version? Ans: uname –a
6) How to find out the run level of the user? Ans: uname –r
7) How to delete 7 days old trace files? Ans: find ./trace –name *.trc –mtime +7 –exec rm {} \;
8) What is top command? Ans: top is a operating system command, it will display top processes which are taking high cpu and memory.
9) 8. How to get 10th line of a file (by using grep)?
SQL> alter system set local_listener=’LISTENER_TEST’; alter system set local_listener=’LISTENER_TEST’ * ERROR at line 1: ORA-02097: parameter cannot be modified because specified value is invalid ORA-00119: invalid specification for system parameter LOCAL_LISTENER ORA-00132: syntax error or unresolved network name ‘LISTENER_TEST’ Solution :
SQL > alter system set LOCAL_LISTENER='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=oraclehost)(PORT=1521))))’ sid=’test’;
SQL*Plus: Release 11.2.0.1.0 Production on Thu Feb 21 11:14:47 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
How will you connect a DB in linux from windows? First check the connectivity in OS(windows) level using ping -t 10.3.2.10(linux server) Then install Oracle Client in Windows and configure tnsnames.ora. TNS can be configures using netca.
Server side, Make sure that listener is configured in listener.ora and it is running. Listener consists of a header and body like
LISTENER = … …
SID_LIST_LISTENER = … … …
then use C:\> tnsping sss to check the response from listener. It is not mandatory that Database should be UP and running.
What is default location of listener.ora and tnsnames.ora ? Can this be changed?
The default location is $ORACLE_HOME/network/admin. This can be changed by using TNS_ADMIN parameter.
What is TNS?
TNS stands for TRANSPARENT NETWORK SUBSTRATE
How will you find how many listeners are running in my server? $ps -ef|grep -i tns
Is it possible to have more than one listener for one database? Yes, You can have more than one listener for one database. It is configured as show below. LISTENER_SSS = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = sss-oracle)(PORT = 1521)) ) )
How will you find whether a port is available? $ netstat -tunlp |grep portnumber.
Is it possible to have one listener for more than one database?
Yes, You can have one listener for more than one database. It is configured as show below. LISTENER_SSS = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = sss-oracle)(PORT = 1521)) ) )
Error : Starting ORACLE instance (normal) Wed Feb 20 12:00:52 2013 Process m000 died, see its trace file Wed Feb 20 12:00:52 2013 ksvcreate: Process(m000) creation failed Wed Feb 20 12:01:53 2013 Process m000 died, see its trace file Wed Feb 20 12:01:53 2013 ksvcreate: Process(m000) creation failed Wed Feb 20 12:02:54 2013 Process m000 died, see its trace file Wed Feb 20 12:02:54 2013 ksvcreate: Process(m000) creation failed Wed Feb 20 12:03:56 2013 Process m000 died, see its trace file Wed Feb 20 12:03:56 2013 ksvcreate: Process(m000) creation failed Wed Feb 20 12:04:57 2013
Ans :
Check you have sufficient resources in OS level, if yes , increase or increase the processes parameter accordingly.
================================================= WARNING: inbound connection timed out (ORA-3136) Wed Feb 20 12:21:06 2013 WARNING: inbound connection timed out (ORA-3136) Wed Feb 20 12:21:07 2013 WARNING: inbound connection timed out (ORA-3136) Solution:
In sqlnet.ora set
SQLNET.INBOUND_CONNECT_TIMEOUT= 0 or more value > 120
One of the most and COMPLEX task is tuning the database. COMPLEX is not the correct word, if we understand the environment(ie. functionality) and we know how to tune a query, then everything is simple. Advanced tuning can be learned only through experience and with good environment setup.
Actually 70% of the database is self tuned. Our job is just to do the remaining.
Scenario 1 , Lets have the problematic query , how will you tune it? Eg. 1 select e.empno, 2 d.deptno 3 from 4 emp e, 5 dept d 6 where 7* e.deptno=d.deptno;
First you need to get the execution plan for the query. To get plan you can do the following.
Step 1: ——— First check all the tables in the query are RECENTLY analyzed using the below query. (here it is emp and dept)
SQL> select last_analyzed from dba_tables where table_name in (‘EMP’,’DEPT’);
Like,
SQL> select last_analyzed from user_tables;
LAST_ANAL ————–
4 rows selected.
SQL>
If the result is null or the date is not current then analyze the table.
PLAN_TABLE_OUTPUT ———————————————————————————————————————————- Predicate Information (identified by operation id): —————————————————
3 – access(“E”.”DEPTNO”=”D”.”DEPTNO”)
Note —– – dynamic sampling used for this statement
19 rows selected.
What is execution plan? It the access path for a query execution.
When a query is executed from the client, it does three things.
1. Parsing 2. Exection 3. fetching
1. PARSING Parsing has 6 stages, they are
1. systax checking – Just checks the syntax 2. Semantic checking – Checks the objects are available and accessible. 3. View Merging – rewrites the query so that it uses tables instead if views. 4. Statement transformation – Breaks the query to simple queries. 5. Optimization – Check the best access path with use of CBO or RBO. 6. Query Execution Plan Generation
After taking the best access path, it is stored with the query in the library cache. Queries are stored in the
library cache by using a hash value.
If a query is called again , it is hashed using hashing algorithm and checks in the library cache, if found it uses
the execution plan else it does the parsing(6 stages).
2. EXECUTION Query Execution Plan Execution
3. FETCHING
Reads the data. It may be physical reads, logical reads and consistent reads. How does oracle reads data? There are two ways. 1. sigle blocks read 2. multi-block read
Blocks are read using the following techniqs.
Full tables scan Index scan Rowid What is rowsource, predicate,tuples? Rowsource is a function that does some action and returns set of records.
predicate is where clause from a query.
tuples are rows from table.
What is driving table and probing table? Driving table is the one that will be scanned first and the key rows are retrieved. The result will be compared to the probing table to get the exact result.
for example.
SQL> select e.empno, d.deptno from emp e, dept d where e.deptno=d.deptno;
if the table emp is scanned first by using the predicate e.deptno and the result is used to look for data in dept table using d.deptno.
Here emp is driving table and dept is probing table.
What are joining methods?
There are three types of joining methods.
1. Sort merge 2. Nested loop 3. Hash join.
How will you interpret the execution plan?
Execution plan should be read from right most top.
What will you see in the execution plan?
We need to see the cost and bytes of accessing each table. Try to reduce the cost.
Like, Check any full table scans and force to use index etc.
How will you monitor the index creation?
select OPNAME,SOFAR,TOTALWORK,TIME_REMAINING from v$session_longops where sofartotalwork;
How will you view the DML queries that are currently executing?
SQL> select a.sql_text, s.sql_id, t.ubablk from v$transaction t, v$session s, v$sqlarea a where t.addr=s.taddr and a.sql_id=s.sql_id;
Note : Since the above query is referring V$TANSACTION , it take only DML statements.
What is RBO?
RBO is Rule based optimizer that uses 15 set of rules to create the execution plan.
RBO Path 1: Single Row by Rowid
RBO Path 2: Single Row by Cluster Join
RBO Path 3: Single Row by Hash Cluster Key with Unique or Primary Key
RBO Path 4: Single Row by Unique or Primary Key
RBO Path 5: Clustered Join
RBO Path 6: Hash Cluster Key
RBO Path 7: Indexed Cluster Key
RBO Path 8: Composite Index
RBO Path 9: Single-Column Indexes
RBO Path 10: Bounded Range Search on Indexed Columns
RBO Path 11: Unbounded Range Search on Indexed Columns
RBO Path 12: Sort Merge Join
RBO Path 13: MAX or MIN of Indexed Column
RBO Path 14: ORDER BY on Indexed Column
RBO Path 15: Full Table Scan
SQL> conn scott/tiger
SQL> set autotrace on SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled SP2-0611: Error enabling STATISTICS report
SQL> conn sys/sys as sysdba
@?/sqlplus/admin/plustrce.sql
SQL> SQL> drop role plustrace; drop role plustrace * ERROR at line 1: ORA-01919: role ‘PLUSTRACE’ does not exist
SQL> create role plustrace;
Role created.
SQL> SQL> grant select on v_$sesstat to plustrace; grant select on v_$sesstat to plustrace * ERROR at line 1: ORA-00942: table or view does not exist
SQL> grant select on v_$statname to plustrace; grant select on v_$statname to plustrace * ERROR at line 1: ORA-00942: table or view does not exist
SQL> grant select on v_$mystat to plustrace; grant select on v_$mystat to plustrace * ERROR at line 1: ORA-00942: table or view does not exist
SQL> grant plustrace to dba with admin option;
Grant succeeded.
SQL> SQL> set echo off SQL> grant plustrace to scott;
Grant succeeded.
reconnect scott.
SQL> conn scott/tiger Connected. SQL> set autotrace on SQL>
Scenario : My daily job has a update statement that normally runs every 10 mins. But today it takes more that 30 mins but still it hangs. How will i trouble shoot it.
Answer :
Terminal one :
SQL> SELECT sys_context(‘USERENV’, ‘SID’) FROM DUAL 2 /
Note : In first 3 columns you find values 0 0 0 and sid is 25, which means this session is hanging (waiting session) …, The session 39 is holding(lock holding) session.
SQL> select sid,serial# from v$session where sid=39;
SID SERIAL# ———- ———- 39 3
To kill the sesison from database :
SQL> alter system kill session ‘39,3’; Killing from OS level :
SQL> select PADDR from v$session where sid=39;
PADDR ——– 52522C34
SQL> select PID,SPID,ADDR from v$process where addr=’52522C34′;