When the client connects to the oracle database through the network in the form of "connect user name/password @ connection string", the listener needs assistance. After the connection is established, even if the listener fails, the established connection will not be affected.
There are two main ways for users to connect to the oracle database server: private server connection and shared server connection.
Each server process has its own PGA. This PGA is created when the server process is started and the access permission to PGA is limited to the server process, the PGA can only be read and written by the Oracle code that represents the server process.
Multiple client users share server processes and UGA is transferred to SGA (if a shared pool or large pool is configured), PGA will only have stack space left.
Tools used to configure and manage Oracle Net include dbconsole, netca, netmgr, and command line tool (vi)
Oracle Net supports multiple connection Resolution Methods:
When using a simple connection, you can provide all the information required for the Oracle Net connection as part of the connection string. The simple connection string is in the following format:
Username/password @ hostname [: port] [/service_name]
The listener port and service name are optional. If no listener port is provided, Oracle Net assumes that the default port is 1521. If no service name is provided, Oracle Net assumes that the database service name provided in the connection string is the same as the host name.
SQL> conn hr/hr@192.168.0.90: 1521/orcl.example.com
When local naming is used, you can provide an alias for the Oracle Net service. Oracle Net checks the alias based on the list of locally known services. If a matching name is found, the alias is converted to the host, protocol, port, and service name.
One advantage of local naming is that database users only need to remember the short aliases required for simple connections, rather than long connection strings.
If the Organization's Oracle Net service configuration does not change frequently, it is appropriate to use a local name.
SQL> conn hr/hr @ orcl
The Oracle network-related files are located in the $ TNS_ADMIN directory, including sqlnet. ora, listener. ora, and tnsnames. ora.
Sqlnet. ora: Located on the database server, used to define the connection resolution method (the default connection method is TNSNAMES, EZCONNECT)
Listener. ora: The listener Configuration file located on the database server.
Tnsname. ora: Located on the client, contains the network server name, and mapped to the connection string
By default, the sqlnet. ora and listener. ora files may not exist, but the listener can still be started by default. In this case, Oracle automatically starts a LISTENER named "LISTENER" on the address whose resolution address is the host name of the computer and port 1521.
$ cat sqlnet.oraNAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)ADR_BASE = /u01/app/oracle$ cat listener.oraLISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora11g.example.com)(PORT = 1521)) ) )ADR_BASE_LISTENER = /u01/app/oracleENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent$ cat tnsnames.oraORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = orcl.example.com) ) )$ lsnrctl serviceLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-SEP-2013 22:11:58Copyright (c) 1991, 2009, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g.example.com)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s). Instance "+ASM", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVERService "orcl.example.com" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVERService "orclXDB.example.com" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Handler(s): "D000" established:0 refused:0 current:0 max:972 state:ready DISPATCHER <machine: ora11g.example.com, pid: 5008> (ADDRESS=(PROTOCOL=tcp)(HOST=ora11g.example.com)(PORT=56668))The command completed successfully
The methods for registering an instance to a database are static registration and dynamic registration.
Registration is to register the database as a service to the listener. The client does not need to know the Database Name and Instance name. It only needs to know the service name provided by the database to external users and can apply to connect to the database.
When the database server is started, the database server registers the corresponding service to the listener whenever a database is started. By default, two messages are registered to the listener: instance name and service name corresponding to the database server)
Static registration is to read the configuration of the listener. ora file when the instance starts, and register the instance and service to the listener. Whenever a database is started, two messages are registered to the listener by default: The instance and service corresponding to the database server.
During static registration, GLOBAL_DBNAME in listener. ora provides the service name externally, and SID_NAME in listener. ora provides the registered Instance name.
The instance name registered to the listener is obtained from the instance_name parameter in the parameter file. If this parameter is not set, it will take the value of db_name In the parameter file.
The service name registered to the listener is obtained from the service_names parameter in the parameter file. If no value is set for this parameter, the database registers the values of db_name and db_domain In the parameter file.
The pmon process is required for dynamic registration, so the listener must be started before the database starts. Otherwise, dynamic registration fails. When the database is running, restarting the listener will also cause dynamic registration failure.
SQL> show parameter _ listenerNAME TYPE VALUE -------------------------------------- local_listener string // The default VALUE is null, find the default listener LISTENERremote_listener string // The listener SQL> show parameter service_namesNAME TYPE VALUE ----------- -------------------------------- service_names string orcl.example.com $ cat listener in RAC. ora # listener. ora Network Configuration File:/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener. ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = ora11g.example.com) (PORT = 1521) ADR_BASE_LISTENER =/u01/app/LISTENER = ON
Add multiple listeners:
$ Vi $ TNS_ADMIN/listener. ora // Add the LISTENER1 Listener Configuration Information LISTENER1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1522 ))) $ vi $ TNS_ADMIN/tnsnames. ora // Add the connection string APPLE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1522) connected to the listener "LISTENER1 ))) SQL> alter system set local_listener = 'listener1'; alter system set local_listener = 'listener1' * ERROR at line 1: ORA-02097: parameter cannot be modified because specified value is invalidORA-00119: invalid specification for system parameter LOCAL_LISTENERORA-00132: syntax error or unresolved network name 'listener1' SQL> alter system set local_listener = 'apple '; // modify the default listener (the connection string corresponding to the listener must be used) System altered. $ lsnrctl start listener1 // start the LISTENER "LISTENER1" --------------- omitted output --------------- STATUS of the LISTENER Alias listener1Version TNSLSNR for Linux: Version 11.2.0.1.0-ProductionStart Date 11-SEP-2013 14: 18: 13 Uptime 0 days 0 hr. 0 min. 1 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener. oraListener Log File/u01/app/oracle/diag/tnslsnr/ora11g/listener1/alert/log. xmlListening Endpoints Summary... (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = 192.168.0.90) (PORT = 1522 ))) the listener supports no servicesThe command completed successfully $ lsnrctl status listener1 // view The status of The "LISTENER1" listener (Dynamic Registration usually has a delay of several seconds) --------------- omitted output --------------- Listening Endpoints Summary... (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = 192.168.0.90) (PORT = 1522) Services Summary... service "orcl.example.com" has 1 instance (s ). instance "orcl", status READY, has 1 handler (s) for this service... service "orclXDB.example.com" has 1 instance (s ). instance "orcl", status READY, has 1 handler (s) for this service... the command completed successfully $ lsnrctl status // view The status of The LISTENER (The LISTENER can be omitted) --------------- omitted output ------------- Listening Endpoints Summary... (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = ora11g.example.com) (PORT = 1521) Services Summary... service "+ ASM" has 1 instance (s ). instance "+ ASM", status READY, has 1 handler (s) for this service... the command completed successfully $ sqlplus/nolog SQL> conn hr/hr @ apple // connect to Connected through The "LISTENER" LISTENER.
$ Vi $ TNS_ADMIN/listener. oraLISTENER2 = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1523 )))) SID_LIST_LISTENER2 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl.example.com) (ORACLE_HOME =/u01/app/oracle/product/11.2.0/dbhome_1/) (SID_NAME = orcl ))) $ lsnrctl start listener2 --------------- omitted output --------------- Listening Endpoints Summary... (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = 192.168.0.90) (PORT = 1523) Services Summary... service "orcl.example.com" has 1 instance (s ). instance "orcl", status UNKNOWN, has 1 handler (s) for this service... the command completed successfully
Static registration can also be used to remotely enable database instances. Dynamic registration cannot be performed because the database instance is not started. Therefore, you cannot use the Dynamic Registration listener to connect to the database before enabling the database.
$ Sqlplus/nologSQL * Plus: Release 11.2.0.1.0 Production on Wed Sep 11 16:30:14 2013 Copyright (c) 1982,200 9, Oracle. all rights reserved. SQL> conn/as sysdbaConnected. SQL> shutdown immediateDatabase closed. database dismounted. ORACLE instance shut down. SQL> conn sys/oracle_4U @ apple as sysdba // unable to connect to a dynamically registered listener ERROR: ORA-12514: TNS: listener does not currently know of service requested in connectdescriptorSQL> conn sys/oracle_4U @ apear as sysdba // You can remotely enable database Connected to an idle instance. SQL> startupORACLE instance started. total System Global Area 459304960 bytesFixed Size 2214336 bytesVariable Size 289408576 bytesDatabase Buffers 159383552 bytesRedo Buffers 8298496 bytesDatabase mounted. database opened.
Configure client Failover and Server Load balancer Failover and LoadBalance during connection
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/214IM449-0.png "title =" FC BL.png "/>
You can configure through dbconsole or directly modify the tnsnames. ora file.
$ grep -A 11 ORCL tnsnames.oraORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1522)) (LOAD_BALANCE = yes) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.example.com) ) )
Only the second item "randomly trying each address until one address is successful" can achieve failover and load balancing at the same time.
Item 1: only the role of failover
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1521 ))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1523 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.example.com)
)
)
Item 3: only the role of Server Load balancer
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1521 ))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1523 ))
(LOAD_BALANCE = yes)
(FAILOVER = false)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.example.com)
)
)
Item 4: Role of only source route
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1521 ))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1523 ))
(SOURCE_ROUTE = yes)
(FAILOVER = false)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.example.com)
)
)
Item 5: use only the first address
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1521 ))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.90) (PORT = 1523 ))
(FAILOVER = false)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.example.com)
)
)
Add a listener to OHASD:
Note: When you use srvctl to add a listener, you must first disable the listener to be added. Otherwise, an error is reported.
$ . oraenvORACLE_SID = [orcl] ? +ASMThe Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle$ lsnrctl stop listener1$ lsnrctl stop listener2$ srvctl add listener -h Adds a listener configuration to be managed by Oracle Restart.Usage: srvctl add listener [-l <lsnr_name>] [-s] [-p "[TCP:]<port>[, ...][/IPC:<key>][/NMP:<pipe_name>][/TCPS:<s_port>] [/SDP:<port>]"] [-o <oracle_home>] -l <lsnr_name> Listener name (default name is LISTENER) -o <oracle_home> ORACLE_HOME path (default value is CRS_HOME) -s Skip the checking of ports -p "[TCP:]<port>[, ...][/IPC:<key>][/NMP:<pipe_name>][/TCPS:<s_port>] [/SDP:<port>]" Comma separated tcp ports or listener endpoints -h Print usage$ srvctl add listener -l listener1 -p 1522 -o /u01/app/oracle/product/11.2.0/dbhome_1/$ srvctl add listener -l listener2 -p 1523 -o /u01/app/oracle/product/11.2.0/dbhome_1/$ srvctl start listener -l listener1$ srvctl start listener -l listener2$ crs_stat -tName Type Target State Host ------------------------------------------------------------ora.DATA.dg ora....up.type ONLINE ONLINE ora11g ora.FRA.dg ora....up.type ONLINE ONLINE ora11g ora....ER.lsnr ora....er.type ONLINE ONLINE ora11g ora....R1.lsnr ora....er.type ONLINE ONLINE ora11g ora....R2.lsnr ora....er.type ONLINE ONLINE ora11g ora.asm ora.asm.type ONLINE ONLINE ora11g ora.cssd ora.cssd.type ONLINE ONLINE ora11g ora.diskmon ora....on.type ONLINE ONLINE ora11g ora.orcl.db ora....se.type ONLINE ONLINE ora11g
This article from the "ghost fireworks smile" blog, please be sure to keep this source http://vnimos.blog.51cto.com/2014866/1294812