search
HomeDatabaseMysql TutorialOracle中tnsnames.ora的作用

tnsnames.ora 在listener的作用,数据库只是在启动的过程中会读到tnsnames.ora中的内容去解析LOCAL_LISTENER,之后tnsnames的变化

1、tnsnames.ora 在listener的作用
数据库只是在启动的过程中会读到tnsnames.ora中的内容去解析LOCAL_LISTENER,之后tnsnames的变化和侦听无关


---设置了LOCAL_LISTENER,1522端口
SQL> show parameter list


NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string LISTENER_1
remote_listener string


---listener.ora里面的内容
[Oracle@node1 admin]$ more listener.ora
# listener.ora Network Configuration File: /oracle/app/oracle/db/network/admin/listener.ora
# Generated by Oracle configuration tools.


LISTENER_1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.10)(PORT = 1522))
)


ADR_BASE_LISTENER_1 = /oracle/app/oracle


---tnsnames.ora里面的内容
LISTENER_1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.10)(PORT = 1522))
)
)
目前数据库状态正常

 


现在删除tnsnames。ora,启动数据库
SQL> ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENER_1
数据库报错,说明数据库在启动的时候是通过tnsnames.ora去解析LOCAL_LISTENER的


step2:修改tnsnames。ora的内容给他一个错误的IP地址
[oracle@node1 admin]$ vi tnsnames.ora


LISTENER_1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.17)(PORT = 1522))
)
)
1.1.1.17为错误的IP
SQL> startup
ORACLE instance started.


Total System Global Area 1054593024 bytes
Fixed Size 1349616 bytes
Variable Size 507512848 bytes
Database Buffers 541065216 bytes
Redo Buffers 4665344 bytes
Database mounted.
Database opened.
SQL>
数据库能正常启动

 


SQL> !ps -ef | grep tns
oracle 3219 1 0 21:26 ? 00:00:00 /oracle/app/oracle/db/bin/tnslsnr LISTENER_1 -inherit
oracle 4125 3881 0 21:40 pts/1 00:00:00 /bin/bash -c ps -ef | grep tns
oracle 4127 4125 0 21:40 pts/1 00:00:00 /bin/bash -c ps -ef | grep tns


SQL> !lsnrctl status LISTENER_1


LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 30-SEP-2013 21:40:25


Copyright (c) 1991, 2011, Oracle. All rights reserved.


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.10)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER_1
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 30-SEP-2013 21:26:50
Uptime 0 days 0 hr. 13 min. 34 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/app/oracle/db/network/admin/listener.ora
Listener Log File /oracle/app/oracle/diag/tnslsnr/node1/listener_1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.1.1.10)(PORT=1522)))
The listener supports no services
The command completed successfully


SQL>

 


没有服务注册到listener


step3:修改tnsnames.ora的内容为正确的IP


重新启动listener
[oracle@node1 admin]$ lsnrctl stop LISTENER_1
[oracle@node1 admin]$ lsnrctl start LISTENER_1


SQL> alter system register;


System altered.


SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@node1 admin]$ lsnrctl status LISTENER_1


LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 30-SEP-2013 21:43:03


Copyright (c) 1991, 2011, Oracle. All rights reserved.


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.10)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER_1
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 30-SEP-2013 21:42:30
Uptime 0 days 0 hr. 0 min. 32 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/app/oracle/db/network/admin/listener.ora
Listener Log File /oracle/app/oracle/diag/tnslsnr/node1/listener_1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.1.1.10)(PORT=1522)))
The listener supports no services
The command completed successfully


还是不行
[oracle@node2 admin]$ sqlplus vic@vic2


SQL*Plus: Release 11.2.0.3.0 Production on Mon Sep 30 21:43:32 2013


Copyright (c) 1982, 2011, Oracle. All rights reserved.


Enter password:
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


客服端也无法连接,说明重启listner对不会读取tnsnames。ora的内容。

接下来请看第2页精彩内容

 

相关阅读:

Oracle数据库中listener.ora sqlnet.ora tnsnames.ora的区别

Oracle RAC 下非缺省端口监听配置(listener.ora tnsnames.ora) 

Oracle RAC 监听配置 (listener.ora tnsnames.ora)

Oracle: listener.ora 、sqlnet.ora 、tnsnames.ora的配置及例子

Oracle本地命名服务tnsnames.ora配置

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software