Oracle的连接方式:
想要连接到oralce服务器,需要的三个条件:
* 服务器的IP
* 监听端口
* 服务名称
1.easy connect(configurationless connection)
简单连接(非配置连接)
[oracle@db253 admin]$ sqlplus scott/[email protected]:1522/orcl11g.neves.com
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 19 13:56:46 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[email protected]:1522/orcl11g.neves.com>
2.使用本地服务名的方式连接
这个设置是客户端设置;
netca
netmgr
手动配置:
ORACLE_DOCUMENTS
---> Net Services Reference
---> 6 Local Naming Parameters (tnsnames.ora)
--->
Example
net_service_name=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales-svr)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=sales.us.example.com))
本地服务名的配置文件位置:
$ORACLE_HOME/network/admin/tnsnames.ora
oracle$vi $ORACLE_HOME/network/admin/tnsnames.ora
ORCL11G_253 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = db253.neves.com)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl11g.neves.com) -- 指的是服务名
)
)
如何验证配置的本地服务名是否是有效的?
[oracle@db253 admin]$ tnsping orcl11g_253
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 19-JUN-2013 14:06:49
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = db253.neves.com)(PORT = 1522))) (CONNECT_DATA = (SERVICE_NAME = orcl11g.neves.com)))
OK (0 msec)
如何使用本地服务名连接数据库?
[oracle@db253 admin]$ sqlplus scott/tiger@orcl11g_253
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 19 14:07:53 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@orcl11g_253>
3.使用本地服务名设置local_listener,remote_listener
LSNR253 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db253.neves.com)(PORT = 1522))
)
LSNR109 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.109)(PORT = 1521))
)
SYS@orcl11g> alter system set local_listener='LSNR253';
System altered.
SYS@orcl11g> alter system set remote_listener='LSNR109';
System altered.
4.共享服务器的设置
dispatcher
max_dispatcher
shared_servers
max_shared_servers
SYS@orcl11g> alter system set dispatchers='(protocol=tcp)(dispatchers=3)';
System altered.
SYS@orcl11g> alter system set max_dispatchers=10;
System altered.
SYS@orcl11g> alter system set shared_servers=10;
System altered.
SYS@orcl11g> alter system set max_shared_servers=20;
System altered.
通过设置本地服务名,来实现共享服务器模式连接:
oracle$vi $ORACLE_HOME/network/admin/tnsnames.ora
ORCLS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = o5u4.uplooking.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = shared)
(SERVICE_NAME = orcl11g.up.com)
)
)