Oracle Net Services - Complete Connectivity Guide
Oracle Net Services - Complete Connectivity Guide
Section titled âOracle Net Services - Complete Connectivity GuideâOracle Net Services is Oracleâs communication software that enables network sessions between client applications and Oracle databases. It provides location transparency, centralized configuration, and scalable connectivity solutions for Oracle environments.
đŻ Overview
Section titled âđŻ OverviewâWhat is Oracle Net Services?
Section titled âWhat is Oracle Net Services?âOracle Net Services provides:
- Transparent network connectivity between clients and databases
- Location transparency - clients donât need to know database location
- Load balancing and failover capabilities
- Connection pooling and multiplexing for scalability
- Security features including encryption and authentication
- Centralized configuration management
Oracle Net Architecture
Section titled âOracle Net ArchitectureâCore Components
Section titled âCore ComponentsâClient Application âOracle Net (Client) âNetwork (TCP/IP) âOracle Net (Server) âOracle Listener âOracle Database
đ§ Listener Configuration
Section titled âđ§ Listener ConfigurationâBasic Listener Setup
Section titled âBasic Listener SetupâListener.ora Configuration
Section titled âListener.ora Configurationâ# Sample listener.ora fileLISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1.company.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) )
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = MYDB) (ORACLE_HOME = /u01/oracle/product/19c) (PROGRAM = oracle) ) (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/19c) (PROGRAM = extproc) ) )
# Advanced settingsLOGGING_LISTENER = ONTRACE_LEVEL_LISTENER = OFFINBOUND_CONNECT_TIMEOUT_LISTENER = 60
Multiple Listeners
Section titled âMultiple Listenersâ# Multiple listeners on same serverLISTENER1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) )
LISTENER2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1522)) )
# Different service listenersPROD_LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = prodserver)(PORT = 1521)) )
TEST_LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = testserver)(PORT = 1522)) )
Listener Management
Section titled âListener ManagementâListener Control Commands
Section titled âListener Control Commandsâ# Start listenerlsnrctl start LISTENER
# Stop listenerlsnrctl stop LISTENER
# Check listener statuslsnrctl status LISTENER
# Reload listener configurationlsnrctl reload LISTENER
# Show listener serviceslsnrctl services LISTENER
# Show listener versionlsnrctl version
# Trace listener activitylsnrctl trace LISTENER admin
# Set listener passwordlsnrctl set password
Advanced Listener Operations
Section titled âAdvanced Listener Operationsâ# Dynamic service registration statuslsnrctl services LISTENER
# Show listener statisticslsnrctl status LISTENER -detail
# Enable/disable servicelsnrctl set service_registration onlsnrctl set service_registration off
# Show current parameterslsnrctl show LISTENER
# Save configurationlsnrctl save_config LISTENER
# Listener log managementlsnrctl set log_status onlsnrctl set log_file /u01/oracle/network/log/listener.log
đ TNS Configuration
Section titled âđ TNS ConfigurationâTNS Names Configuration
Section titled âTNS Names ConfigurationâTnsnames.ora Setup
Section titled âTnsnames.ora Setupâ# Basic connection descriptorMYDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1.company.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = mydb.company.com) ) )
# Connection with failoverMYDB_HA = (DESCRIPTION = (ADDRESS_LIST = (FAILOVER = ON) (LOAD_BALANCE = ON) (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = server2)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 3) (DELAY = 10) ) ) )
# RAC connectionRAC_DB = (DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = ON) (FAILOVER = ON) (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = rac3-vip)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = racdb.company.com) ) )
Advanced TNS Features
Section titled âAdvanced TNS Featuresâ# Connection with retry and timeoutROBUST_DB = (DESCRIPTION = (RETRY_COUNT = 3) (RETRY_DELAY = 10) (TRANSPORT_CONNECT_TIMEOUT = 60) (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) (SERVER = DEDICATED) ) )
# SSL/TLS encrypted connectionSECURE_DB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCPS)(HOST = secure-server)(PORT = 2484)) (CONNECT_DATA = (SERVICE_NAME = securedb.company.com) ) (SECURITY = (SSL_SERVER_CERT_DN = "CN=secure-server,O=Company,C=US") ) )
# Connection poolingPOOLED_DB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) (SERVER = POOLED) ) )
TNS Testing and Validation
Section titled âTNS Testing and ValidationâConnection Testing
Section titled âConnection Testingâ# Test TNS connectivitytnsping MYDB
# Test with counttnsping MYDB 5
# Detailed testingsqlplus system/password@MYDB
# Test specific servicetnsping MYDB.company.com
# Test from different hosttnsping MYDB 10 | grep -E "(OK|TNS-)"
Trace and Debugging
Section titled âTrace and Debuggingâ# Enable TNS tracing (sqlnet.ora)TRACE_LEVEL_CLIENT = 16TRACE_DIRECTORY_CLIENT = /u01/oracle/network/traceTRACE_FILE_CLIENT = clientTRACE_UNIQUE_CLIENT = ON
# Server-side tracingTRACE_LEVEL_SERVER = 16TRACE_DIRECTORY_SERVER = /u01/oracle/network/traceTRACE_FILE_SERVER = server
# Listener tracinglsnrctl set trc_level 16lsnrctl set trc_file /u01/oracle/network/trace/listener.trc
âď¸ Connection Management
Section titled ââď¸ Connection ManagementâConnection Types
Section titled âConnection TypesâDedicated Server Connections
Section titled âDedicated Server Connectionsâ# Dedicated connection in tnsnames.oraDEDICATED_DB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) (SERVER = DEDICATED) ) )
# Check dedicated processesSQL> SELECT program, count(*) FROM v$process WHERE program LIKE '%oracle@%' GROUP BY program;
Shared Server Connections
Section titled âShared Server Connectionsâ# Shared server configuration (init.ora)DISPATCHERS="(PROTOCOL=TCP)(DISPATCHERS=3)"SHARED_SERVERS=5MAX_SHARED_SERVERS=20SHARED_SERVER_SESSIONS=50
# Shared connection descriptorSHARED_DB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) (SERVER = SHARED) ) )
# Monitor shared serverSQL> SELECT * FROM v$dispatcher;SQL> SELECT * FROM v$shared_server;SQL> SELECT * FROM v$queue;
Connection Pooling
Section titled âConnection Poolingâ# Connection pooling parametersCONNECTION_POOLING = ONPOOL_SIZE = 10POOL_INCREMENT = 2POOL_DECREMENT = 1POOL_TIMEOUT = 300
# Monitor connection poolsSQL> SELECT pool_name, status, sessions, max_sessions FROM v$cpool_stats;
Session Management
Section titled âSession ManagementâSession Monitoring
Section titled âSession Monitoringâ-- Current sessionsSELECT username, program, machine, status, logon_timeFROM v$sessionWHERE type = 'USER'ORDER BY logon_time;
-- Connection detailsSELECT s.username, s.program, s.machine, p.program as process_name, s.server as connection_typeFROM v$session s, v$process pWHERE s.paddr = p.addr AND s.type = 'USER';
-- Network statisticsSELECT name, valueFROM v$sysstatWHERE name LIKE '%Net%' OR name LIKE '%SQL*Net%';
Session Limits and Resources
Section titled âSession Limits and Resourcesâ-- Check session limitsSELECT resource_name, current_utilization, max_utilization, limit_valueFROM v$resource_limitWHERE resource_name IN ('sessions', 'processes');
-- Session resource usageSELECT username, program, logical_reads_session, physical_reads_session, cpu_used_by_this_sessionFROM v$sesstat s, v$statname n, v$session sesWHERE s.statistic# = n.statistic# AND s.sid = ses.sid AND n.name IN ('session logical reads', 'session physical reads', 'CPU used by this session') AND ses.username IS NOT NULL;
đ Security Configuration
Section titled âđ Security ConfigurationâNetwork Security
Section titled âNetwork SecurityâEncryption Configuration
Section titled âEncryption Configurationâ# SQLNet.ora encryption settingsSQLNET.ENCRYPTION_CLIENT = REQUIREDSQLNET.ENCRYPTION_TYPES_CLIENT = (AES256, AES192, AES128, 3DES168)SQLNET.ENCRYPTION_SERVER = REQUIREDSQLNET.ENCRYPTION_TYPES_SERVER = (AES256, AES192, AES128, 3DES168)
# Checksumming for data integritySQLNET.CRYPTO_CHECKSUM_CLIENT = REQUIREDSQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT = (SHA256, SHA1, MD5)SQLNET.CRYPTO_CHECKSUM_SERVER = REQUIREDSQLNET.CRYPTO_CHECKSUM_TYPES_SERVER = (SHA256, SHA1, MD5)
SSL/TLS Configuration
Section titled âSSL/TLS Configurationâ# SSL wallet configurationWALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = /u01/oracle/network/admin/wallet) ) )
SSL_CLIENT_AUTHENTICATION = FALSESSL_CIPHER_SUITES = (SSL_RSA_WITH_AES_256_CBC_SHA)
# Listener SSL configurationLISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCPS)(HOST = server1)(PORT = 2484)) )
SSL_CLIENT_AUTHENTICATION = FALSEWALLET_LOCATION = /u01/oracle/network/admin/wallet
Access Control
Section titled âAccess Controlâ# Valid node checkingTCP.VALIDNODE_CHECKING = YESTCP.INVITED_NODES = (server1, server2, client1, client2)TCP.EXCLUDED_NODES = (hacker*, *.untrusted.com)
# Connection rate limitingCONNECTION_RATE_LISTENER = 10INBOUND_CONNECT_TIMEOUT_LISTENER = 10
# Logging and auditingLOGGING_LISTENER = ONLOG_STATUS_LISTENER = ONADMIN_RESTRICTIONS_LISTENER = ON
Authentication Methods
Section titled âAuthentication MethodsâDatabase Authentication
Section titled âDatabase Authenticationâ# Standard database authenticationMYDB_AUTH = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) ) )
# Connection: sqlplus username/password@MYDB_AUTH
External Authentication
Section titled âExternal Authenticationâ# OS AuthenticationSQLNET.AUTHENTICATION_SERVICES = (NTS) # WindowsSQLNET.AUTHENTICATION_SERVICES = (BEQ) # Unix/Linux
# Kerberos authenticationSQLNET.AUTHENTICATION_SERVICES = (KERBEROS5)SQLNET.KERBEROS5_CONF = /etc/krb5.confSQLNET.KERBEROS5_REALMS = /etc/krb5.realms
đ Performance Optimization
Section titled âđ Performance OptimizationâConnection Optimization
Section titled âConnection OptimizationâConnection Pooling Tuning
Section titled âConnection Pooling Tuningâ# Optimal pooling parametersCONNECTION_POOLING = ONPOOL_SIZE = 20POOL_INCREMENT = 5POOL_DECREMENT = 2POOL_TIMEOUT = 300POOL_MAX_LIFETIME = 3600
# Monitor pool efficiencySQL> SELECT pool_name, opened_connections, closed_connections, pool_hits, pool_misses FROM v$cpool_stats;
Network Performance
Section titled âNetwork Performanceâ# SDU (Session Data Unit) optimizationDEFAULT_SDU_SIZE = 8192MAX_SDU_SIZE = 32767
# Disable Nagle algorithm for low latencyTCP.NODELAY = YES
# Socket buffer sizesRECV_BUF_SIZE = 65536SEND_BUF_SIZE = 65536
# Connection multiplexingUSE_SHARED_SOCKET = TRUE
Load Balancing
Section titled âLoad BalancingâClient-Side Load Balancing
Section titled âClient-Side Load Balancingâ# Random load balancingBALANCED_DB = (DESCRIPTION = (LOAD_BALANCE = ON) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = server2)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = server3)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) ) )
Server-Side Load Balancing
Section titled âServer-Side Load Balancingâ-- Configure service with load balancingBEGIN DBMS_SERVICE.CREATE_SERVICE( service_name => 'BALANCED_SERVICE', network_name => 'balanced.company.com', goal => DBMS_SERVICE.GOAL_THROUGHPUT, clb_goal => DBMS_SERVICE.CLB_GOAL_SHORT );
DBMS_SERVICE.START_SERVICE( service_name => 'BALANCED_SERVICE' );END;/
-- Monitor service metricsSELECT service_name, goal, clb_goal, aq_ha_notificationsFROM dba_services;
Failover Configuration
Section titled âFailover ConfigurationâTransparent Application Failover (TAF)
Section titled âTransparent Application Failover (TAF)â# TAF configurationTAF_DB = (DESCRIPTION = (ADDRESS_LIST = (FAILOVER = ON) (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5) ) ) )
# Session failoverSESSION_TAF_DB = (DESCRIPTION = (ADDRESS_LIST = (FAILOVER = ON) (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) (FAILOVER_MODE = (TYPE = SESSION) (METHOD = BASIC) ) ) )
đ Monitoring and Troubleshooting
Section titled âđ Monitoring and TroubleshootingâNetwork Monitoring
Section titled âNetwork MonitoringâConnection Statistics
Section titled âConnection Statisticsâ-- Network statisticsSELECT name, valueFROM v$sysstatWHERE name LIKE '%Net%' OR name LIKE '%SQL*Net%'ORDER BY name;
-- Session network I/OSELECT s.username, s.program, n1.value as bytes_sent, n2.value as bytes_receivedFROM v$session s, v$sesstat n1, v$sesstat n2, v$statname sn1, v$statname sn2WHERE s.sid = n1.sid AND s.sid = n2.sid AND n1.statistic# = sn1.statistic# AND n2.statistic# = sn2.statistic# AND sn1.name = 'bytes sent via SQL*Net to client' AND sn2.name = 'bytes received via SQL*Net from client' AND s.username IS NOT NULL;
-- Listener statisticsSELECT * FROM v$listener_network;
Performance Metrics
Section titled âPerformance Metricsâ-- Response timesSELECT service_name, calls_per_sec, average_response_time, total_cpu_timeFROM v$service_stats;
-- Wait eventsSELECT event, total_waits, total_timeouts, time_waitedFROM v$system_eventWHERE event LIKE '%Net%' OR event LIKE '%SQL*Net%'ORDER BY time_waited DESC;
Troubleshooting Common Issues
Section titled âTroubleshooting Common IssuesâConnection Problems
Section titled âConnection Problemsâ# TNS resolution issuestnsping MYDBnslookup server1.company.comtelnet server1 1521
# Listener issueslsnrctl statuslsnrctl servicesps -ef | grep tnslsnr
# Firewall/network issuestelnet server1 1521netstat -an | grep 1521iptables -L | grep 1521
Error Diagnosis
Section titled âError Diagnosisâ# Common TNS errors and solutions
# TNS-12541: TNS:no listener# - Check if listener is running# - Verify hostname/port in tnsnames.oralsnrctl statuslsnrctl start
# TNS-12154: TNS:could not resolve the connect identifier# - Check tnsnames.ora syntax# - Verify ORACLE_HOME/network/admin pathtnsping MYDB
# ORA-12519: TNS:no appropriate service handler found# - Check processes/sessions limits# - Verify service registrationSQL> SHOW PARAMETER processes;SQL> ALTER SYSTEM SET processes=300 SCOPE=SPFILE;
# ORA-12514: TNS:listener does not currently know of service# - Check service registration# - Verify database is openlsnrctl servicesSQL> SELECT name, open_mode FROM v$database;
Performance Issues
Section titled âPerformance Issuesâ# Network latency testingtime tnsping MYDB
# Connection time analysistime sqlplus system/password@MYDB <<< "exit"
# Trace network issues# Set in sqlnet.ora:TRACE_LEVEL_CLIENT = 16TRACE_DIRECTORY_CLIENT = /tmp
# Analyze trace filesgrep -i error /tmp/client*.trcgrep -i "elapsed time" /tmp/client*.trc
đ ď¸ Advanced Configuration
Section titled âđ ď¸ Advanced ConfigurationâEnterprise Features
Section titled âEnterprise FeaturesâConnection Manager (CMAN)
Section titled âConnection Manager (CMAN)â# Connection Manager configurationCMAN = (CONFIGURATION = (ADDRESS = (PROTOCOL = TCP)(HOST = cman-server)(PORT = 1521)) (PARAMETER_LIST = (MAX_GATEWAY_PROCESSES = 8) (MIN_GATEWAY_PROCESSES = 2) ) )
# Client connection through CMANCMAN_DB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = cman-server)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = mydb.company.com) ) )
Directory Naming
Section titled âDirectory Namingâ# LDAP configuration (ldap.ora)DEFAULT_ADMIN_CONTEXT = "cn=OracleContext,dc=company,dc=com"DIRECTORY_SERVERS = (ldap-server1:389, ldap-server2:389)DIRECTORY_SERVER_TYPE = OID
# Using directory namingNAMES.DIRECTORY_PATH = (LDAP, TNSNAMES, HOSTNAME)NAMES.DEFAULT_DOMAIN = company.com
High Availability
Section titled âHigh AvailabilityâFast Connection Failover (FCF)
Section titled âFast Connection Failover (FCF)â# FCF with RACFCF_RAC = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = racdb.company.com) (FAST_CONNECTION_FAILOVER = ON) ) )
# Enable FCF notificationsSQL> ALTER SYSTEM SET aq_tm_processes=1;
Global Data Services (GDS)
Section titled âGlobal Data Services (GDS)â# GDS broker configurationGDSCTL> add broker gdsbroker1 -connect server1:1522GDSCTL> add broker gdsbroker2 -connect server2:1522
# Create GDS configurationGDSCTL> create gdsconfiguration -gdsname mygdsGDSCTL> add service -service sales_svc -gdspool sales_poolGDSCTL> start service -service sales_svc
Oracle Net Services provides the foundation for scalable, secure, and highly available Oracle database connectivity. Proper configuration and monitoring ensure optimal performance and reliability for enterprise applications.
đ Related Topics
Section titled âđ Related Topicsâ- Oracle Listener Management - Listener monitoring scripts
- RAC Configuration - Cluster database connectivity
- Data Guard Setup - Standby database connectivity
- Security Configuration - Database security practices