Location>code7788 >text

8. tnsnames file configuration

Popularity:918 ℃/2024-11-20 14:08:38

Configuration file for listening

2. Documentation
File: The client's

Configuring Listening Files

1. Use the netca command

Specify the image mapping machine
[oracle@db11g admin]$ export DISPLAY=192.168.56.1:0.0

The netca command
[oracle@db11g admin]$ netca

2、optionlocal net service name configuration,strike (on the keyboard)next

3, select add, click next

4, enter service name: cis (be sure and lsnrctl status command to view the Service "cis" has 1 instance(s), cis the same), click next

5. Select TCP and click next.

6, enter Host name: 192.168.56.70, click next

7, whether to test, you can test, you can not test, click next

8, enter net service name: cistest (this name can be arbitrary)

9. Click next

10, click next

11, click finish, complete

View the contents of the file:

[oracle@db11g ~]$ cd $ORACLE_HOME
[oracle@db11g db_1]$ cd network/admin
[oracle@db11g admin]$ ls
  samples    
[oracle@db11g admin]$ cat 
#  Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/
# Generated by Oracle configuration tools.

CISTEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = cis)
    )
  )

The file is a parse file that parses CISTEST into: 192.168.56.70 IP address, 1521 port number, cis service name

Two types of database connections

1,
[oracle@db11g admin]$ sqlplus system/[email protected]:1521/cis
2,
[oracle@db11g admin]$ sqlplus system/oracle@cistest -- cistest: Configured client listening name in the file

When connecting, without the @ symbol, there is no listening, and the user connects directly to the database instance; with the @ symbol, there is listening, and if the listening is not activated, the user will not be able to connect to the database instance.

The same configuration method is used for testing inside Windows:

tnsping cistest2

Note: tnsping, the first cistest2 is resolved, the second access to the IP address 192.168.56.70 and port 1521, the third tnsping does not determine whether there is a cis on the listener

So you also need to test if you can log in successfully:

To connect to linux oracle on Windows, you need an oracle client on Windows.

Oracle client: download the installation package inside the detailed installation instructions
1. Full version
With commands, management tools

Library files (some functions, dll, so, o, etc. that the program will use to connect to the database)

2. instant version
Command:sqlplus (with or without)

library file

instant version:
1, is a compressed package, after decompression, placed in a directory inside the
2、linux:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/oraclient/ora_instant
3. windows: set the environment variable PATH, plus c:\app/ora_instant

Three names (instance name, database name, service name)

instance name
View the instance name:

SQL> show parameter instance_name
NAME				                    TYPE	 VALUE
------------------------------------ ----------- ------------------------------
instance_name			               string	 orcl

A database can have multiple instances, one name for each instance: the
For example: Example 1: cis1; Example 2: cis2

Database Name
View the database name:

SQL> show parameter db_name
NAME				                     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
db_name 			                    string	 orcl

A database has only one name

Service Name
View service name:

SQL> show parameter service_name
NAME				                    TYPE	 VALUE
------------------------------------ ----------- ------------------------------
service_names			                string	 orcl

The name of the service can be modified and there can be multiple service names

Modify the service name:

SQL> alter system set service_name = 'cis,cist';; -- Register the service name after modification.
SQL> alter system register; -- register service_name after modification

Dynamic Registration of Listeners
Dynamic registration: default registration to listener listener.

SQL> show parameter local
NAME				                    TYPE	 VALUE
------------------------------------ ----------- ------------------------------
local_listener			             string
log_archive_local_first 	            boolean	 TRUE
parallel_force_local		            boolean	 FALSE

If you want pmonitor to register instancename and servername with listener1, you have to modify the local_listener parameter.

How to modify the local_listener parameter to register with listener1 (IP address: 10.10.10.70)?

SQL> alter system set LOCAL_LISTENER = '(ADDRESS = (PROTOCOL=TCP)(HOST=10.10.10.70)(PORT=1521))';
SQL> alter system register;


At this point, the listener is empty inside:

What if I regret it after making the change, how can I change it back?

SQL> alter system set LOCAL_LISTENER = ‘’;
SQL> alter system register;

The listener is back: