Local service name (Tnsname)
The connection between the Oracle client and the server is a connection request sent by the client. The server listener checks the client connection request legally. If the connection request is valid, the connection is performed. Otherwise, the connection is rejected.
The local service name is a type of network configuration for the Oracle client, as well as the Oracle Names Server. The common client configuration in Oracle is the local service name. This article describes the configuration based on the local service name.
Oracle network connection configuration method
To configure the Oracle server and client, you can use the built-in graphical Oracle Network Manager (Oracle Net Manager) (we strongly recommend that you configure the Oracle server or client with this graphical tool ). In Windows, click Start/Program/Oracle-OraHome92/Configuration and Migration Tools/Net ManagerStart the Oracle network manager tool. In Linux/Unix, use the netmgr command to start the graphical Oracle Network Manager, such as $ netmgr.
1. Oracle LISTENER configuration (LISTENER)
Select the listener item in the tree directory, click "+" on the upper left side to add the listener, and click the listener directory, by default, the added LISTENER name is LISTENER (this name can also be named by any valid character ). Select the name, select "listener location" from the drop-down menu on the right of the window, and click the Add address button. Select "TCP/IP" from the Protocol drop-down option in the Network Address Bar, and enter the host name or IP address in the host text box (if the host is used as the server or as the client, either of the two items is valid. If the host acts as the server and needs to be connected over the network, we recommend that you enter an IP address), enter a number in the port text box, the default value is 1521, you can also customize any valid digital port.
Select "Database Service" from the drop-down list on the right of the window and click "add Database. In the displayed database column, enter the global database name, for example, myoracle. Note that the global database name is different from the database SID here. The global database name actually controls the uniqueness of the global database name in the same network segment through the domain name, such as the domain name controller in Windows, for example, enter myoracle.192.168.1.5. You can enter the SID for the Oracle main directory, for example, myoracle.
Save the preceding configuration. By default, you can find the Listener Configuration file in the Oracle Installation Directory (for exampleD: \ oracle \ ora92 \ network \ admin \ listener. oraIn Linux/Unix$ ORACLE_HOME/network/admin/listerer. ora). So far, the Listener Configuration for the Oracle server has been completed.
2. Local Service name configuration (Tnsnames)
The local service name is based on the network configuration of the Oracle client. Therefore, if the client needs to connect to the database server for operations, you need to configure the client, the attached object can be any PC to connect to the database server for operation, or the database server itself. As described earlier, you can use the Net Manager graphical management tool provided by Oracle to configure the Oracle client.
If the related services on the database server are started, click the test button to test the connection. By default, Oracle uses scott/tiger users to test connections. Since scott is an example user of Oracle, this user may not be configured for formal business databases or professional Test Databases, therefore, you must change it to a valid user logon before the test is successful. If the connection test fails, click "finish" to complete the configuration.
Go back to the main window of Oracle Network Manager (Oracle Net Manager) and save the configuration. By default, you can find the local service name configuration file in the Oracle Installation Directory (for exampleD: \ oracle \ ora92 \ network \ admin \ tnsnames. oraIn Linux/Unix$ ORACLE_HOME/network/admin/tnsnames. ora).
The service name in the tree directory can be changed to a service name composed of any valid characters by renaming the menu in the editing menu. Note that the service name cannot contain spaces before it; otherwise, the database server may not be connected.
3. Connect to the Database Server
(1) Start the server listener and Database Service:
In Linux/Unix, start the listener:$ Lsnrctl start
· Disable listeners:$ Lsnrctl stop
· View the listening status:$ Lsnrctl status
SQL> conn sys @ myoracle as sysdba --Here, myoracle is the local service name of the client configured earlier.
Or
SQL> conn/as sysdba
SQL> startup
In Windows, start the listener:C: \ lsnrctl start
Start the Oracle instance service:C: \ oradim-startup-sid myoracle
Disable the Oracle instance service:C: \ oradim-shutdown-sid myoracle
The above services must be started at the same time before the client can connect to the database. Because the Listener name configured by default is Listener, the above command can start the Listener normally. If the Listener name is another name, such as aListener, you need to start the Listener in the following ways:
Linux/Unix: $ lsnrctl start aListener
Windows: C: \ lsnrctl start aListener