1、服务器端
D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN
listener.ora
tnsnames.ora
1.1 基本配置
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SUPERVIS-EC05EE)(PORT = 1521))
)
监听器管理工具
lsnrctl: start stop reload status
注册
静态注册
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = abc)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(SID_NAME = mysid)
)
)
lsnrctl status
服务 "abc" 包含 1 个例程。
例程 "mysid", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
动态注册
PMON,看v$instance中的主机名,1521
1.2 配置非默认端口1522
修改listener.ora配置
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SUPERVIS-EC05EE)(PORT = 1522))
)
修改命名解析文件,增加监听器的命名
tnsnames.ora
lis1522 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SUPERVIS-EC05EE)(PORT = 1522))
)
SQL> show parameter local
修改系统参数
NAME TYPE VALUE
------------------------------------ ----------- -------------
local_listener string
log_archive_local_first boolean TRUE
SQL> alter system set local_listener=lis1522
手动注册
alter system register;
客户端
tnsnames.ora
sqlnet.ora
连接方式
1)host naming
sqlplus system/1@SUPERVIS-EC05EE
默认监听端口1521,主机名恰好和服务名一致
2)easy connect
sqlplus system/1@SUPERVIS-EC05EE:1521/abc
3)local naming
tnsnames.ora
A =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = SUPERVIS-EC05EE)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = abc)
)
)
sqlplus system/1@a
4) directory naming
5) external naming
练习1:配置监听器、客户端连接
1)使用netmanager配置监听器
2)使用netmanager静态注册数据库
3)启动监听器,lsnrctl,start,status
4)使用netmanager配置服务命名
5)使用plsqldeveloper连接数据库
练习2:配置监听1522端口
1)修改listener.ora
2)配置监听命名,修改tnsnames.ora
3)修改系统参数local_listener
4)观察监听器状态
5)修改客户端服务命名中端口
6)测试
练习3:配置两个监听器
修改tnsnames.ora
lis1522 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = SUPERVIS-EC05EE)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = SUPERVIS-EC05EE)(PORT = 1522))
)
)