ORALCE远程连接

ORACLE 远程连接

 


专用服务器模式:
1) 静态注册 理解三个文件:sqlnet.ora , tnsnames.ora ,listener.ora
Sqlnet.ora在本地: 决定oracle使用什么来解析连接的字符串
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Tnsnames.ora在本地: 如果sqlnet.ora中选定用tnsnames.ora来解析,那么才生效
ok128 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.244.128)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sb)
)
)
Listener.ora在服务端:配置监听器 和 静态注册ORACLE服务端
[oracle@localhost admin]$ pwd
/opt/oracle/10g/network/admin
[oracle@localhost admin]$ cat  listener.ora 
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
#以上是配置监听器,下面是静态注册
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=sb)
(SID_NAME=orcl)
(ORACLE_HOME=/opt/oracle/10g )
)
)
# 这里GLOBAL_DBNAME 与tnsnames.ora本地中SERVICE_NAME保持一致

2) 动态注册 :理解两个参数:service_names 和 local_listener .
SQL> alter system set service_names=sb;
SQL> show parameter service_names
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string SB
注释:service_names 参数根据其值,自动生成listener中的信息。故而不需要在listener.ora中配置任何信息,甚至删除listenser.ora也没关系。

注意:使用动态注册,启动监听后需要等1分钟,才能连接上。

如果监听器端口不是在默认端口1521,那么动态注册就找不到,或者监听器与服务端不再统一机器上,这个时候需要配置local_listener参数。
实例:如果动态注册并把端口监听在1421上。
服务端:[oracle@localhost admin]$ cat tnsnames.ora
LN14 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.244.128)(PORT = 1421))
)
SQL> alter system set local_listener = LN14;

System altered.

SQL> show parameter local_listener

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string LN14
注释:这样服务端就能监听到客服端的连接了。
这个时候配置的tnsnames.ora 是在服务端上,请注意。

共享服务器模式
参数:dispatchers , max_dispatchers 调度器设置
shared_servers ,max_shared_servers 共享服务器进程设置
下面是初始状态的参数的值:
SQL> show parameter dispatchers

NAME TYPE VALUE
--------------------------------- ----------- ------------------------------
dispatchers string (PROTOCOL=TCP) (SERVICE=orclXDB)
max_dispatchers integer
SQL> show parameter shared_servers //这是共享服务器唯一必须设置的参数
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers integer
shared_servers integer 1

设置dispatchers参数:
SQL> alter system set dispatchers="(protocol=tcp)(dispatcher=5)";
SQL> show parameter dispatchers
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string (protocol=tcp)(dispatcher=5)
max_dispatchers integer

设置shared_servers参数:
SQL> alter system set shared_servers=3;
SQL> show parameter shared_servers;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers integer
shared_servers integer 3
1)静态注册:
服务端listener.ora配置:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=sb)
(SID_NAME=orcl)
(ORACLE_HOME=/opt/oracle/10g )
)
)
客服端配置tnsnames.ora :
sh1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.244.128)(PORT = 1521))
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = orcl)
)
)
注释:这里的SERVICE_NAME = orcl 直接配置为实例名才能登录,而不是与服务端的listener.ora中的GLOBAL_DBNAME=sb相同。感觉似乎和GLOBAL_DBNAME没关系
3) 动态注册
SQL> alter system set service_names=sb;
SQL> show parameter service_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string SB
这个是默认端口的动态注册方式,非默认端口的如下:
服务端tnsnames.ora :
ln14 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.244.128)(PORT = 1421))
)
设置参数dispatchers:
SQL> alter system set dispatchers="(ADDR=(protocol=tcp)(host = 192.168.244.128)(port = 1421)) (listener=ln14) (dispatchers=5)" ;
SQL> alter system set shared_servers=3;
客服端需要只需要更改tnsnames.ora中的端口即可。

注释:这里的参数dispatchers这里如果不添加(listener=ln14),则需要去定义参数local_listenser。

 

你可能感兴趣的:(oracle,远程连接)