一、理解网络配置 Understanding Network Configuration
For a client application and a database to communicate, the client application must be able to identify the database it wants to connect to, and the database must provide some sort of identification or address. You can use a service name to connect to a database. A service name is a logical representation of a database, which is the way a database is presented to clients. A single database can be presented as multiple services.
represent:表现、描述、象征
Using service names can provide location transparency such that the client application does not need to know the server's location. When the database is moved to another location, you need to reconfigure only Oracle Net. No changes are necessary to client applications.
transparency :透明、透明度
1、配置监听器 Oracle Net Listener Configuration
Listener is a process that listens for client connection requests. It receives incoming client connection requests and manages the traffic of these requests to the database server.
The default listener configuration file is called listener.ora
, and it is located in the Oracle_home
/network/admin
directory
>> 查看监听器配置
在 HOME PAGE中查看:
On the Database Home page, click the Listener link under General.
The Listener page appears, displaying the following information about the listener:
-
Current status
-
Availability over the last 24 hours
-
Alias
-
Version
-
Oracle home
-
Net address
-
Configuration file (
listener.ora
) location -
Start time
-
Host
用命令行查看:
-
Open a command window.
-
(Linux and UNIX systems only) Set the required environment variables by running the script
oraenv
(for the Bourne, Korn, or Bash shells) orcoraenv
(for the C shell).These scripts are typically located in the
/usr/local/bin
directory. They may prompt you for the desired value of theORACLE_SID
environment variable. If so, supply the system ID (SID) that you chose when you installed Oracle Database. The default SID that the installer typically suggests isorcl
. 可以用export ORACLE_SID=orcl来指定。 -
(Linux and UNIX systems only) Either ensure that the
Oracle_home
/bin
directory is in yourPATH
environment variable, or change the directory toOracle_home
/bin
. -
Enter the following command:
lsnrctl status
>> 启停止 Listener
在 home page中:
On the Database Home page, click the Listener link under General.The Listener page appears.
Click start or stop
以命令行方式:
lsnrctl stop
lsnrctl start
2、链接描述 Connect Descriptors
The client uses a connect descriptor to specify the database to which it wants to connect. This connect descriptor contains a protocol and a database service name. A database can have multiple service names defined, so a specific service name must be specified for the connect descriptor. In a preconfigured database, there is only one service name, which defaults to the global database name.
3、链接请求 Connection Requests
Users initiate a connection request by providing a connect string. A connect string includes a user name and password, and a connect identifier
就是平时用的 conn rms/rms@jldev 这种形式的串
Oracle Net provides support for the following naming methods:
The easy connect naming method enables clients to connect to an Oracle database by using only a TCP/IP connect string consisting of a host name and service name. The easy connect naming method requires no configuration.这种形式不需要配置
使用 easy connect Naming链接的步骤:
第一步:命令行输入 sqlplus
第二步:在提示输入用户名时,按如下格式输入
user@"[//]host[:port]/service_name"
比如:nick@"db.us.example.com/orcl.us.example.com" 第三步:输入 密码
The local naming method stores connect descriptors, identified by their net service names, in a configuration file on the client named tnsnames.ora
. This file is located in the Oracle_home
/network/admin
directory. 这种形式比较常用
Directory naming resolves a database service, net service name, or net service alias to a connect descriptor stored in an LDAP-compliant directory server. 没用过啊。。。
5、网络配置的工具 Tools for Network Configuration
During a typical database installation, Net Configuration Assistant (NETCA) automatically configures a listener called
LISTENER
that has a TCP/IP listening protocol address for the database. If you do a custom installation, then NETCA prompts you to configure a listener name and protocol address of your choice.Use NETCA for initial network configuration after database installation. Thereafter, you can use Oracle Enterprise Manager and Oracle Net Manager to configure and administer your networks
Oracle Net Manager provides the same features as Oracle Enterprise Manager with the addition of configuring profiles.
详见《Oracle Database Net Services Administrator's Guide》
二、查看监听器的配置 Viewing Listener Configuration
三、启动停止监听器 Starting and Stopping the Listener
四、从客户端链接数据库 Connecting to an Oracle Database from a Client Computer
五、Networking: Oracle By Example Series
Oracle的 例子教程:
http://www.oracle.com/technology/obe/11gr1_2day_dba/network/network.htm