您的位置:首页 > 其它

tnsping 解析

2016-02-01 19:40 295 查看
什么是tnsping?

可以参考官方文档的具体介绍
http://docs.oracle.com/cd/E11882_01/network.112/e41945/connect.htm#NETAG378
TNSPING is a utility in the ORACLE HOME/bin directory used to test if a SQL*Net connect string can connect to a remote listener (check if the socket is reachable).

Note: This utility only tests if the listener is available. It cannot tell if the databases behind the listener is up or not.

Using the TNSPING Utility to Test Connectivity from the Client

The TNSPING utility determines whether the listener for a service on an Oracle Net network can be reached successfully.

If you can connect successfully from a client to a server (or a server to another server) using the TNSPING utility, then it displays an estimate of the round trip time (in milliseconds) it takes to reach the Oracle Net service.

If it fails, then it displays a message describing the error that occurred. This enables you to see the network error that is occurring without the overhead of a database connection.

tnsping 实际上就是一个小工具,用来决定是否一个Oracle Net 网络服务(service)可以被接受。

从某种意义上来说,tnsping 针对的 sqlnet连接,就好比为我们常用的ping 命令来检查IP,主机名网络连接情况。

总结:tnsping 用于诊断各种客户端连接问题的一个非常好的工具。

但是我们要清楚的知道,这个工具能做什么(检查客户端TNS配置),什么不能做(检查数据库实例是否启动,监听端口是否在1521上)!

tnsping的解析成功仅仅意味着本地的tnsnames.ora ,IP地址,TNS_ADMIN 变量等配置成功。

但是,完全跟目标数据库实例连接没有任何关系!

最后,sqlnet 跟数据库也完全是独立的两个问题。不要因为sqlnet连接方面出错,就肯定是数据库的问题。要从客户端自身先找原因。

Use the following command to test connectivity:

tnsping net_service_name count

In the preceding command, the following arguments are used:

net_service_name must exist in tnsnames.ora file or the name service in use, such as NIS.

count determines how many times the program attempts to reach the server. This argument is optional.

If the net service name specified is a database name, then TNSPING attempts to contact the corresponding listener. It does not actually determine whether the database is running. Use SQL*Plus to attempt a connection to the database.

Following are some examples of TNSPING.

Note:

Different platforms may have different interfaces, but the program accepts the same arguments. Invoke TNSPING for the display of the proper interface requirements.

Example 15-1 is an example of checking a listener for a database using a net service name of sales using the TNSPING command.

Example 15-1 Checking a Listener with TNSPING

TNSPING sales

This produces the following message:

TNS Ping Utility for Linux: Version 11.1.0.0.2 on 15-FEB-2009 14:46:28

Copyright (c) 1997, 2009 Oracle Corporation. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =

TCP)(HOST = sales-server)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =

sales.us.example.com)))

OK (10 msec)

To determine whether the listener for the sales database is available, and to specify that TNSPING try to connect eight times and then give up, use the following syntax:

tnsping sales 8

This command produces the following message:

TNS Ping Utility for Linux: Version 11.1.0.0.2 on 15-FEB-2009 14:48:28

Copyright (c) 1997, 2009 Oracle Corporation. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =

TCP)(HOST = sales-server)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =

sales.us.example.com)))

OK (10 msec)

OK (0 msec)

OK (10 msec)

OK (0 msec)

OK (10 msec)

OK (10 msec)

OK (10 msec)

OK (0 msec)

Example 15-2 is an example of TNSPING attempting to check using an invalid net service name.

Example 15-2 Checking an Invalid Net Service Name with TNSPING

tnsping badname

This attempt produces the following message:

TNS Ping Utility for Linux: Version 11.1.0.0.2 on 15-FEB-2009 14:50:28

Copyright (c) 1997, 2009 Oracle Corporation. All rights reserved.

Used parameter files:

TNS-03505: Failed to resolve name

Example 15-3 is an example of output when using TNSPING to check a name that is valid, but that resolves to an address where no listener is located (for example, the listener may not be started).

Example 15-3 Checking Valid Net Service Name but No Listener with TNSPING

TNS Ping Utility for Linux: Version 11.1.0.0.2 on 15-FEB-2009 14:52:28

Copyright (c) 1997, 2009 Oracle Corporation. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =

TCP)(HOST = sales-server)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =

sales.us.example.com)))

TNS-12541: TNS:no listener
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: