{"id":9087,"date":"2016-10-11T13:38:13","date_gmt":"2016-10-11T11:38:13","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/"},"modified":"2016-10-11T13:38:13","modified_gmt":"2016-10-11T11:38:13","slug":"otn-appreciation-day-tnsping","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/","title":{"rendered":"OTN Appreciation Day &#8211; tnsping"},"content":{"rendered":"<h2>By William Sescu<\/h2>\n<p>Tim Hall had the idea that as many people as possible would write a small blog post about their favorite Oracle feature and we all post them on the same day. I do have a lot\u00a0of favorite Oracle tools, and the one I choose today is: tnsping<\/p>\n<p>tnsping tells you, if your connect string can be resolved and if the listener where the connect string is\u00a0pointing to, is available, and in the end, it displays an estimate of the round trip time (in milliseconds)\u00a0it takes to reach the Oracle Net service.<\/p>\n<p>All in all, tnsping is very easy to use and that&#8217;s why I love it, and not so overloaded like e.g. crsctl. \u00a0In fact, tnsping knows only 2 parameters. &lt;address&gt; and optionally &lt;count&gt;, like shown in the following example.<\/p>\n<p>Usage: tnsping &lt;address&gt; [&lt;count&gt;]<\/p>\n<p>Getting the option list of tnsping, a few lines are enough. I don&#8217;t need to scroll down several pages, like e.g. for emctl. \u00a0emctl is another one besides crsctl were you can spend a lifetime only reading the manual. \u00a0No, I picked tnsping this time because I like the option list.<\/p>\n<p>Here we go &#8230; now I run one tnsping without and one with count.<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">oracle@oel001:\/home\/oracle\/ [OCM121] tnsping RMAN\nTNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 11-OCT-2016 14:28:14\nCopyright (c) 1997, 2014, Oracle.  All rights reserved.\nUsed parameter files:\n\/u00\/app\/oracle\/network\/admin\/sqlnet.ora\nUsed TNSNAMES adapter to resolve the alias\nAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oel001)(PORT = 1521))) \n(CONNECT_DATA = (SERVICE_NAME = OCM121)))\nOK (0 msec)\n\noracle@oel001:\/home\/oracle\/ [OCM121] tnsping RMAN 5\nTNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 11-OCT-2016 14:28:20\nCopyright (c) 1997, 2014, Oracle.  All rights reserved.\nUsed parameter files:\n\/u00\/app\/oracle\/network\/admin\/sqlnet.ora\nUsed TNSNAMES adapter to resolve the alias\nAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oel001)(PORT = 1521))) \n(CONNECT_DATA = (SERVICE_NAME = OCM121)))\nOK (0 msec)\nOK (10 msec)\nOK (0 msec)\nOK (0 msec)\nOK (0 msec)<\/pre>\n<p>But &#8230; wait a second &#8230; my RMAN connect string points to host oel001, but it should point to oel002. Let&#8217;s take\u00a0a look in $ORACLE_HOME\/network\/admin\/tnsnames.ora<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">oracle@oel001:\/u00\/app\/oracle\/ [OCM121] cat \/u00\/app\/oracle\/product\/12.1.0.2\/network\/admin\/tnsnames.ora\nRMAN =\n  (DESCRIPTION =\n    (ADDRESS_LIST =\n      (ADDRESS = (PROTOCOL = TCP)(HOST = oel002)(PORT = 1521))\n    )\n    (CONNECT_DATA =\n      (SERVICE_NAME = OCM121)\n    )\n  )<\/pre>\n<p>It looks correct. So what is going on here. There are several explanations to this issue.<\/p>\n<p style=\"padding-left: 30px\">1.) You might have set the TNS_ADMIN environment variable, which points to a total different directory<br \/>\n2.) Or your sqlnet.ora might point to a LDAP server first, which resolves the name<br \/>\n3.) Or a total different tnsnames.ora file is taken into account, but which one?<br \/>\n4.) Or something totally different, e.g. corrupt nscd, symlinks &#8230;<\/p>\n<p>For quite a long time, Oracle is not searching first in the $ORACLE_HOME\/network\/admin\/tnsnames.ora<br \/>\nto get the name resolved. The tnsnames.ora search order is the following:<\/p>\n<p style=\"padding-left: 30px\">1.) $HOME\/.tnsnames.ora \u00a0 \u00a0# yes, it looks up the a hidden file in your home directory first<br \/>\n2.) \/etc\/tnsnames.ora \u00a0 \u00a0# then, a global tnsnames.ora in the \/etc directory<br \/>\n3.) $ORACLE_HOME\/network\/admin\/tnsnames.ora \u00a0 \u00a0# and last but not least, it looks it up in the $ORACLE_HOME\/network\/admin<\/p>\n<p>To prove it, simply run a strace on your tnsping command and take a look at the trace file.<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">$ strace -o \/tmp\/tnsping.trc -f tnsping RMAN\n$ cat \/tmp\/tnsping.trc | grep tnsnames\n\n21919 access(\"\/home\/oracle\/.tnsnames.ora\", F_OK) = 0\n21919 access(\"\/etc\/tnsnames.ora\", F_OK) = -1 ENOENT (No such file or directory)\n21919 access(\"\/u00\/app\/oracle\/product\/12.1.0.2\/network\/admin\/tnsnames.ora\", F_OK) = -1 ENOENT (No such file or directory)\n21919 stat(\"\/home\/oracle\/.tnsnames.ora\", {st_mode=S_IFREG|0644, st_size=173, ...}) = 0\n21919 open(\"\/home\/oracle\/.tnsnames.ora\", O_RDONLY) = 3<\/pre>\n<p>Here we go &#8230; in my case, the &#8220;\/home\/oracle\/.tnsnames.ora&#8221; was taken into account. Let&#8217;s take a look.<br \/>\nIndeed, I have found an entry here.<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">oracle@oel001:\/home\/oracle\/ [OCM121] cat \/home\/oracle\/.tnsnames.ora\nRMAN =\n  (DESCRIPTION =\n    (ADDRESS_LIST =\n      (ADDRESS = (PROTOCOL = TCP)(HOST = oel001)(PORT = 1521))\n    )\n    (CONNECT_DATA =\n      (SERVICE_NAME = OCM121)\n    )\n  )<\/pre>\n<p>Have fun with tnsping.<\/p>\n<p>Cheers,<br \/>\nWilliam<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By William Sescu Tim Hall had the idea that as many people as possible would write a small blog post about their favorite Oracle feature and we all post them on the same day. I do have a lot\u00a0of favorite Oracle tools, and the one I choose today is: tnsping tnsping tells you, if your [&hellip;]<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[96],"type_dbi":[],"class_list":["post-9087","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-oracle"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>OTN Appreciation Day - tnsping - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OTN Appreciation Day - tnsping\" \/>\n<meta property=\"og:description\" content=\"By William Sescu Tim Hall had the idea that as many people as possible would write a small blog post about their favorite Oracle feature and we all post them on the same day. I do have a lot\u00a0of favorite Oracle tools, and the one I choose today is: tnsping tnsping tells you, if your [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-11T11:38:13+00:00\" \/>\n<meta name=\"author\" content=\"Oracle Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oracle Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/\"},\"author\":{\"name\":\"Oracle Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"headline\":\"OTN Appreciation Day &#8211; tnsping\",\"datePublished\":\"2016-10-11T11:38:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/\"},\"wordCount\":454,\"commentCount\":0,\"keywords\":[\"Oracle\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/\",\"name\":\"OTN Appreciation Day - tnsping - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2016-10-11T11:38:13+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OTN Appreciation Day &#8211; tnsping\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\",\"name\":\"Oracle Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"caption\":\"Oracle Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"OTN Appreciation Day - tnsping - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/","og_locale":"en_US","og_type":"article","og_title":"OTN Appreciation Day - tnsping","og_description":"By William Sescu Tim Hall had the idea that as many people as possible would write a small blog post about their favorite Oracle feature and we all post them on the same day. I do have a lot\u00a0of favorite Oracle tools, and the one I choose today is: tnsping tnsping tells you, if your [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/","og_site_name":"dbi Blog","article_published_time":"2016-10-11T11:38:13+00:00","author":"Oracle Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Oracle Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/"},"author":{"name":"Oracle Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"headline":"OTN Appreciation Day &#8211; tnsping","datePublished":"2016-10-11T11:38:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/"},"wordCount":454,"commentCount":0,"keywords":["Oracle"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/","url":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/","name":"OTN Appreciation Day - tnsping - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2016-10-11T11:38:13+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/otn-appreciation-day-tnsping\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"OTN Appreciation Day &#8211; tnsping"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee","name":"Oracle Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","caption":"Oracle Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/9087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=9087"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/9087\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=9087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=9087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=9087"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=9087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}