Considerations for connecting Oracle clients to servers:
1. Through the SQL * Net protocol, sqlnet. ora and tnsnames. ora must be configured when the Oracle client connects to the server.
Their default directories are in the $ ORACLE_HOME/Network/Admin directory.
You can also set the environment variable tns_admin to point to the sqlnet. ora and tnsnames. ora directories you want to use.
For example:
Tns_admin =/home/Oracle/config/9.0.1; export tns_admin
The sqlnet. ora file decides how to find the database server alias
The default parameters include:
Names. default_domain = World
Names. directory_path = (tnsnames, onames, hostname)
If the default domain name of your Oracle client and server is different, you need to comment the first line #.
# Names. default_domain = World
Make it ineffective.
Names. directory_path specifies the order of server aliases (local tnsnames. ora file, naming server, host name method)
In sqlnet. ora of the server, you can set the time interval for checking whether the client is alive.
Sqlnet. expire_time = 10
The detailed description of the Database Server alias in the tnsnames. ora file is written as follows:
# General statement
Appdb =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 192.168.0.35) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = appdb)
)
)
# Explicitly specifying how to connect to the database using dedicated
Appd =
(Description =
(Address = (Protocol = TCP) (host = 192.168.0.35) (Port = 1521 ))
(CONNECT_DATA =
(SERVICE_NAME = appdb)
(Server = dedicated )))
# Load balancing multiple listener ports to connect to the database
Apps =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 192.168.0.35) (Port = 1521 ))
(Address = (Protocol = TCP) (host = 192.168.0.35) (Port = 1856 ))
)
(CONNECT_DATA =
(SERVICE_NAME = appdb)
)
)
# Note: if the database server uses MTS, it is best to explicitly specify the dedicated direct connection mode for the client when the client program needs to use database link,
# Otherwise, you will encounter many Oracle bugs related to the distributed environment.
# In general, direct connection to the database server will be better, unless your real-time database connection is close to 1000.
2./etc/hosts (UNIX)
Or windows/hosts (Win98) winnt/system32/Drivers/etc/hosts (Win2000)
The client needs to write the correspondence between the IP address of the database server and the host name.
127.0.0.1 localhost
192.168.0.35 oracledb
192.168.0.45 Tomcat
202.84.10.193 bj_db
Sometimes, after configuring step 1, The tnsping Database Server alias is displayed successfully,
However, sqlplus username/password @ servicename does not work, and JDBC thin link does not work either,
Do not forget to do this step on the client, probably because the DNS server does not set the ing between the Server IP address and the host name.
If there are both private IP addresses and public IP addresses on the Internet, private IP addresses are written first, and public IP addresses are written later.
It is recommended to keep a backup before editing. When adding a line, you should also copy and paste it to avoid the error of editing the hosts space-time grid or Tab character.
3. for Oracle multi-database environment in UNIX, the OS client needs to configure the following two Environment Variables
Oracle_sid = appdb; export oracle_sid
Two_task = appdb; export two_task
To specify the default target database.