tns
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| tns [2019/03/21 21:13] – stuart | tns [2022/03/30 10:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| * [[http:// | * [[http:// | ||
| * [[http:// | * [[http:// | ||
| + | * [[https:// | ||
| ==== Some basic reminders ==== | ==== Some basic reminders ==== | ||
| Original at [[https:// | Original at [[https:// | ||
| Line 12: | Line 13: | ||
| * The listener itself doesn’t give a flying fig about what is in tnsnames.ora. That file (tnsnames.ora) is used ONLY by client processes. In the case of dynamic registration, | * The listener itself doesn’t give a flying fig about what is in tnsnames.ora. That file (tnsnames.ora) is used ONLY by client processes. In the case of dynamic registration, | ||
| * The listener is quite capable of starting with no listener.ora file at all. In this case it will start with all default values, including the default name of LISTENER and default port of 1521. For most people, most of the time, this is sufficient. | * The listener is quite capable of starting with no listener.ora file at all. In this case it will start with all default values, including the default name of LISTENER and default port of 1521. For most people, most of the time, this is sufficient. | ||
| - | * If the local_listener parameter is not set (null) the database will send the registration request to port 1521. Notice that 1521 is also the default port of of the listener. | + | * If the local_listener parameter is not set (null) the database will send the registration request to port 1521. |
| - | * If you choose to set local_listener, | + | * If you choose to set local_listener, |
| - | * The SID_LIST section of listener.ora has nothing to do with dynamic registration. Quite the opposite. The SID_LIST section is how you implement static registration. | + | * The SID_LIST section of listener.ora has nothing to do with dynamic registration. Quite the opposite. The SID_LIST section is used to implement static registration. |
| + | |||
| + | ==== Count the number of entries in the tnsnames.ora file ==== | ||
| + | < | ||
| + | grep -E -v '^ ' tnsnames.ora|grep -v ' | ||
| + | </ | ||
| + | ==== How to parse the listener.log file ==== | ||
| + | * [[https:// | ||
| + | |||
| + | * Other Useful stuff by Norman Dunbar (DBA at Toad) | ||
| + | [[http:// | ||
| ==== Connections fail 10% of the time. How to fix? ==== | ==== Connections fail 10% of the time. How to fix? ==== | ||
| Line 22: | Line 33: | ||
| Setting a value greater than 0 ensures that connections are not left open indefinitely, | Setting a value greater than 0 ensures that connections are not left open indefinitely, | ||
| < | < | ||
| - | - sqlnet.ora Network Configuration File: / | ||
| - | - Generated by Oracle configuration tools. | ||
| - | |||
| NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME) | NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME) | ||
| - | |||
| ADR_BASE = / | ADR_BASE = / | ||
| - | |||
| DIAG_ADR_ENABLED=OFF | DIAG_ADR_ENABLED=OFF | ||
| - | |||
| sqlnet.expire_time=10 | sqlnet.expire_time=10 | ||
| DEFAULT_SDU_SIZE=11280 | DEFAULT_SDU_SIZE=11280 | ||
| </ | </ | ||
| - | === tnsnames.ora === | + | === Clean up the tnsnames.ora |
| + | The contents of this file can get pretty nasty and outdated. Keeping it clean and up-to-date is a very good idea but what should be in there? | ||
| + | |||
| + | - a reference to the service names used by any applications connecting to the databases (generally the database names) | ||
| + | - a reference to any useful external services (database link hosts, synonym links, ...) | ||
| + | |||
| + | 95% of the file can be cleaned up with this. It addresses the first point above by spitting out only the stanzas in use by instances on this host. | ||
| + | <code perl> | ||
| + | # | ||
| + | # ============================================================================== | ||
| + | # Name : clean_tnsnames.ora.pl | ||
| + | # Description | ||
| + | # | ||
| + | # Parameters | ||
| + | # | ||
| + | # Notes : Must be run from the $TNS_ADMIN directory | ||
| + | # hostname should be supplied in case clustername is different | ||
| + | # | ||
| + | # Example | ||
| + | # | ||
| + | # Modification History | ||
| + | # ==================== | ||
| + | # When Who | ||
| + | # ========= ================= ================================================== | ||
| + | # 24-MAY-20 Stuart Barkley | ||
| + | # ============================================================================== | ||
| + | |||
| + | use strict; | ||
| + | use warnings; | ||
| + | |||
| + | die " | ||
| + | my ($host) = @ARGV; | ||
| + | |||
| + | # -------------------------------------------------- | ||
| + | # build an array of instances running on this server | ||
| + | # -------------------------------------------------- | ||
| + | my @running_sids = qx[ps -eo args|grep pmon|sed -e ' | ||
| + | chomp @running_sids; | ||
| + | #print " | ||
| + | |||
| + | |||
| + | # ---------------------------------------------------------- | ||
| + | # build an array of tnsnames stanzas that match current host | ||
| + | # ---------------------------------------------------------- | ||
| + | local $/ = ''; | ||
| + | my @stanzas; | ||
| + | open (DATA, "< | ||
| + | while (< | ||
| + | chomp; | ||
| + | if (m/$host/i) {push @stanzas, $_}; | ||
| + | } | ||
| + | close (DATA); | ||
| + | #print " | ||
| + | $/ = " | ||
| + | |||
| + | |||
| + | # --------------------------------------------------------- | ||
| + | # print only the tns stanzas matching the running instances | ||
| + | # --------------------------------------------------------- | ||
| + | my (@matches, @sorted, @unique); | ||
| + | foreach my $running_sid (@running_sids) { | ||
| + | push @matches, grep { / | ||
| + | @sorted = sort @matches; | ||
| + | @unique = do { my %seen; grep { !$seen{$_}++ } @sorted }; | ||
| + | } | ||
| + | print join (" | ||
| + | |||
| + | |||
| + | # next bit needs more thinking about | ||
| + | |||
| + | # ---------------------------------------------------- | ||
| + | #print "add these stanzas needed for database links\n"; | ||
| + | # ---------------------------------------------------- | ||
| + | #my @db_link_hosts = qx[printf " | ||
| + | #chomp @db_link_hosts; | ||
| + | #foreach my $db_link_host (@db_link_hosts) { | ||
| + | # open CMD,' | ||
| + | # while (defined(my $line=< | ||
| + | # print " | ||
| + | # } | ||
| + | # close CMD; | ||
| + | # print (" | ||
| + | #} | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== Check to see how many connections there are in the tnsnames.ora file ==== | ||
| + | <code perl> | ||
| + | perl -ne 'print " | ||
| + | </ | ||
| + | === Layout of a typical tnsnames.ora stanza | ||
| The clause for LISTENER_FEUK11UD is a reference for the local_listener parameter. | The clause for LISTENER_FEUK11UD is a reference for the local_listener parameter. | ||
| < | < | ||
| - | - tnsnames.ora Network Configuration File: / | + | LISTENER_FEUK11UD = |
| - | | + | |
| - | LISTENER_FEUK11UD | ||
| - | (ADDRESS = (PROTOCOL = TCP)(HOST = HFE2PrePrdOra)(PORT = 1521)) | ||
| - | + | FEUK11UD | |
| - | FEUK11UD | + | (DESCRIPTION = |
| - | (DESCRIPTION | + | (ADDRESS = (PROTOCOL = TCP)(HOST = hn481)(PORT = 1521)) |
| - | (ADDRESS = (PROTOCOL = TCP)(HOST = HFE2PrePrdOra)(PORT = 1521)) | + | (CONNECT_DATA = |
| - | (CONNECT_DATA | + | |
| (SERVER = DEDICATED) | (SERVER = DEDICATED) | ||
| (SERVICE_NAME = FEUK11UD) | (SERVICE_NAME = FEUK11UD) | ||
| Line 55: | Line 147: | ||
| Setting the local_listener in the database to the connection string instead of the connect identifier can help the debugging process... | Setting the local_listener in the database to the connection string instead of the connect identifier can help the debugging process... | ||
| < | < | ||
| - | alter system set local_listener=" | + | alter system set local_listener=" |
| </ | </ | ||
| Line 62: | Line 154: | ||
| Setting CONNECT_TIMEOUT_LISTENER | Setting CONNECT_TIMEOUT_LISTENER | ||
| < | < | ||
| - | - listener.ora Network Configuration File: / | ||
| - | - Generated by Oracle configuration tools. | ||
| - | |||
| STARTUP_WAIT_TIME_LISTENER_FEUK11UD = 0 | STARTUP_WAIT_TIME_LISTENER_FEUK11UD = 0 | ||
| CONNECT_TIMEOUT_LISTENER_FEUK11UD = 30 | CONNECT_TIMEOUT_LISTENER_FEUK11UD = 30 | ||
| - | LISTENER_FEUK11UD | + | LISTENER_FEUK11UD = |
| - | (DESCRIPTION_LIST | + | (DESCRIPTION_LIST = |
| - | (DESCRIPTION | + | (DESCRIPTION = |
| (ADDRESS = (PROTOCOL = TCP)(HOST = HFE2PrePrdOra)(PORT = 1521)) | (ADDRESS = (PROTOCOL = TCP)(HOST = HFE2PrePrdOra)(PORT = 1521)) | ||
| (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) | (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) | ||
| Line 104: | Line 193: | ||
| (DESCRIPTION_LIST = | (DESCRIPTION_LIST = | ||
| (DESCRIPTION = | (DESCRIPTION = | ||
| - | (ADDRESS = (PROTOCOL = TCP)(HOST = hn481.crelan.be)(PORT = 3531)) | + | (ADDRESS = (PROTOCOL = TCP)(HOST = hn481)(PORT = 3531)) |
| - | (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC3531)) | + | |
| ) | ) | ||
| ) | ) | ||
| Line 114: | Line 202: | ||
| | | ||
| | | ||
| - | | + | |
| ) | ) | ||
| ) | ) | ||
| Line 127: | Line 215: | ||
| Copyright (c) 1991, 2018, Oracle. | Copyright (c) 1991, 2018, Oracle. | ||
| - | Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hn481.crelan.be)(PORT=3531))) | + | Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hn481.cln.be)(PORT=3531))) |
| Services Summary... | Services Summary... | ||
| Service " | Service " | ||
| Line 142: | Line 230: | ||
| (DESCRIPTION_LIST = | (DESCRIPTION_LIST = | ||
| (DESCRIPTION = | (DESCRIPTION = | ||
| - | (ADDRESS = (PROTOCOL = TCP)(HOST = hn481.crelan.be)(PORT = 3531)) | + | (ADDRESS = (PROTOCOL = TCP)(HOST = hn481.cln.be)(PORT = 3531)) |
| (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC3531)) | (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC3531)) | ||
| ) | ) | ||
| Line 152: | Line 240: | ||
| | | ||
| | | ||
| - | | + | |
| ) | ) | ||
| ) | ) | ||
| Line 165: | Line 253: | ||
| Copyright (c) 1991, 2018, Oracle. | Copyright (c) 1991, 2018, Oracle. | ||
| - | Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hn481.crelan.be)(PORT=3531))) | + | Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hn481.cln.be)(PORT=3531))) |
| Services Summary... | Services Summary... | ||
| Service " | Service " | ||
tns.1553202816.txt.gz · Last modified: 2019/03/21 21:13 by stuart
