connect连接oracle6,EZCONNECT方式连接服务端

这里介绍一种比较方便的连接服务端的方式:EZCONNECT 。

这种连接方式,只需要服务端配置监听文件就可以了,而不需要再客户端配置tnsnames文件的连接串。

---配置监听:[oracle@enmo admin]$ vi listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = enmo)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

)

)

---启动监听:

[oracle@enmo admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 03-NOV-2016 20:04:17

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

... ...

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                03-NOV-2016 20:04:17

Uptime                    0 days 0 hr. 0 min. 38 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/enmo/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Services Summary...

Service "PROD" has 1 instance(s).

Instance "PROD", status READY, has 1 handler(s) for this service...

Service "PRODXDB" has 1 instance(s).

Instance "PROD", status READY, has 1 handler(s) for this service...

The command completed successfully

--首先使用tnsnames方式作连接测试:

--使用连接串测试监听:

ORA11GR2 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.6)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = PROD)

)

)

--串通服务机测试:

[oracle@host01 admin]$ tnsping ora11gr2

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 03-NOV-2016 20:05:08

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:

/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.6)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD)))

OK (20 msec)

[oracle@host01 admin]$

--tnsping通后,连接服务机的数据库测试:

[oracle@host01 admin]$ sqlplus sys/oracle@ora11gr2 as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 3 20:05:36 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

SQL> show parameter service

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

service_names                        string      PROD

SQL>

#连接成功。

---尝试在另外一台机进行EZCONNECT:

[oracle@host01 ~]$ sqlplus sys/oracle@192.168.2.6:1521/PROD as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 3 20:30:25 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

SQL> show parameter service

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

service_names                        string      PROD

---在Windows的客户端连接:

C:\Users\Asus>sqlplus sys/oracle@192.168.2.6:1521/PROD as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 11月 3 22:00:41 2016

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

连接到:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter service

NAME                                 TYPE

------------------------------------ ----------------------

VALUE

------------------------------

service_names                        string

PROD

SQL>

#都连接成功。

注意,一般情况下,在配置或者连接命令书写无误的情况下,若依然连接不到,则需要去配置sqlnet.ora文件,

文件所在的位置跟listener.ora文件的路径一样在/u01/app/oracle/product/11.2.0/dbhome_1/network/admin。

[oracle@enmo admin]$ vi sqlnet.ora

# sqlnet.ora Network Configuration File: /oracle/app/oracle/product/10.2.0/dbhome_1/network/admin/sqlnet.ora

# Generated by Oracle configuration tools.

NAMES.DIRECTORY_PATH= (TNSNAMES,EZCONNECT)

#此文件明确远程客户端连接服务端的方式。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值