本文共 3614 字,大约阅读时间需要 12 分钟。
监听器启动会读取listener.ora文件
[oracle@prod1 admin]$ more listener.ora LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.137.127)(PORT = 1521)) ) )SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=beijing) (SID_NAME=PROD) (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1) ) )
TNS文件
[oracle@prod1 admin]$ more tnsnames.ora bj= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp)(HOST=prod1)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=beijing) (SERVER=dedicated) ) )
登录远程数据库方式
#查看监听状态[oracle@prod1 admin]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-FEB-2015 18:49:04Copyright (c) 1991, 2009, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.137.127)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionStart Date 19-FEB-2015 11:45:07Uptime 0 days 7 hr. 3 min. 56 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log File /u01/app/oracle/diag/tnslsnr/prod1/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.137.127)(PORT=1521)))Services Summary...Service "beijing" has 1 instance(s). Instance "PROD", status UNKNOWN, has 1 handler(s) for this service...The command completed successfully
使用连接字符串登录
[oracle@prod1 admin]$ sqlplus system/beijing@192.168.137.127:1521/beijing
使用网络服务名登录
#根据tns文件bj= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp)(HOST=prod1)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=beijing) (SERVER=dedicated) ) )[oracle@prod1 admin]$ sqlplus system/beijing@bj
监听常见的错误
1TNS-12541: TNS:no listener
#查看服务器端监听状态,如果是如下显示[oracle@prod1 admin]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-FEB-2015 20:33:21Copyright (c) 1991, 2009, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.137.127)(PORT=1521)))TNS-12541: TNS:no listener TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: 111: Connection refused#开启监听[oracle@prod1 admin]$ lsnrctl start
2
[oracle@prod1 dbs]$ sqlplus sys/beijing@bj as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Thu Feb 19 20:49:38 2015Copyright (c) 1982, 2009, Oracle. All rights reserved.ERROR:ORA-01031: insufficient privileges
出现这个错误说明oracle试图去找口令文件,但是找不到
解决方法#生成口令文件[oracle@prod1 dbs]$ orapwd file='/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPROD' password=beijing entries=5 force=y#SYSDB为true,说明sys已经有了sysdba权限sys@PROD> select * from v$pwfile_users; USERNAME SYSDB SYSOP SYSAS------------------------------ ----- ----- -----SYS TRUE TRUE FALSE#重新连接[oracle@prod1 dbs]$ sqlplus sys/beijing@bj as sysdba
3
禁止以操作系统认证方式登录oracle[oracle@prod1 admin]$ vi sqlnet.ora SQLNET.AUTHENTICATION_SERVICES=(NTS)