secureCRT连接到数据库所在的linux机器,切换到oracle用户模式下
[root@nstlbeta ~]# su - oracle
然后用sqlplus登录到数据库,关闭数据库
[oracle@nstlbeta bin]$ sqlplus /nolog //登录sqlplus
SQL>connect /as sysdba //连接oracle
SQL>startup //起动数据库
SQL>exit //退出sqlplus ,起动监听
起动监听
[oracle@nstlbeta bin]$ cd $ORACLE_HOME/bin //进入oracle安装目录
[oracle@nstlbeta bin]$ lsnrctl start //起动监听
4
客户端连接
https://jingyan.baidu.com/article/fa4125acbbd19a28ad709211.html
1. 修改监听器配置文件Linux下Oracle监听器配置文件在:$ ORACLE_HOME/network/admin/listerer.ora, 如:
/bank/oracle/oracle10g/product/10.2.0/network/admin/listener.ora
修改并配置要监听SID的相关信息,如:
#listener.ora Network Configuration File: /bank/oracle/oracle10g/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /bank/oracle/oracle10g/product/10.2.0)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL DBNAME = bkserver)
(SID_NAME = bkserver)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.7.13.242)(PORT = 1521))
)
)
2. 启动监听器
(1). 切换至oracle安装用户(一般为oracle)
su - oracle
(2). 启动监听器
lsnrctl start
另:停止监听器
lsnrctl stop
3. 测试监听器是否运行正常
在客户端修改tnsnames.ora配置文件就访问Oracle数据库,如:
BKSERVER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.7.13.242)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = BKSERVER)
)
)
通过命令tnsping测试是否能访问到监听器,如:
M:\>tnsping bkserver
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 12-8月 -
2010 17:11:04
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的参数文件:
D:\oracle\product\10.2.0\client_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 10.7.13.242)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVIC
E_NAME = BKSERVER)))
OK (20 毫秒)
注意: 监听器是否能被tnsping通跟数据库的开启/关闭无关,所以就算可以tnsping通监听器但未必能连接到数据库,这时请检查listener.ora文件配置信息是否正确,还有数据库是否已经被开启。
这个不是命令配置的,是改文件
如果是服务端:
$ORACLE_HOME/network/ADMIN目录,修改LISTENER.ORA
到$ORACLE_HOME/bin下,通过lnsrctl start启动监听 lnsrctl stop | lnsrctl status 分别是停止监听和查看监听状态
如果是客户端:
$ORACLE_HOME/network/ADMIN目录,修改tnsnames.ora
==========================================================
配置LISTENER.ORA的demo:
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
#BEQUEATH CONFIG
(GLOBAL_DBNAME=salesdb.mycompany)
(SID_NAME=sid1)
(ORACLE_HOME=/private/app/oracle/product/8.0.3)
#PRESPAWN CONFIG
(PRESPAWN_MAX=20)
(PRESPAWN_LIST=
(PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
)
)
)
配置tnsnames.ora的demo:
ora_xxx =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora11g) <-----这个地方填SID_NAME也行
)
)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)