修改为:
CentOS Linux release 7.0.1406 (Core)
11.登录Oracle
[oracle@localhost ~]$ lsnrctl stop #先关闭监听服务
[oracle@localhost ~]$ lsnrctl start #开启监听服务
[oracle@localhost ~]$ sqlplus / as sysdba #登入
SQL> shutdown immediate #立即关闭数据库服务(一般是关闭状态)
SQL> startup #开启数据库服务(重要,必输)
SQL> exit #退出
SQL> sqlplus scott/tiger@192.168.47.131/orcl #连接scott用户
SQL> select * from tab; #test查询表
12,使用PL/SQL连接时,可能会“ORA-12514 TNS 监听程序当前无法识别连接描述符中请求服务”
解决办法简述:
1.修改\oracle\product\11.2.0\db_1\network\admin\listener.ora中的(host)bt-199-039.bta.net.cn改为192.168.47.131
2.修改\oracle\product\11.2.0\db_1\network\admin\tnsnames.ora中的(host)bt-199-039.bta.net.cn 改为192.168.47.131
3.修改后,重启oracle,监听,并注册,主win10上的plsql就可以远程连接虚拟机上的数据库了.
具体操作步骤如下:
一、修改数据库服务器中listener.ora文件内容
[oracle@localhost admin]$ vim /oracle/product/11.2.0/db_1/network/admin/listener.ora
原始内容:
# listener.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = bt-199-039.bta.net.cn)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /oracle
修改为
# listener.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /oracle/product/11.2.0/db_1)
(SID_NAME = orcl)
)
)
LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.47.131)(PORT = 1521)))
ADR_BASE_LISTENER = /oracle
修改数据库服务器中tnsnames.ora文件内容
[oracle@localhost admin]$ vim /oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
原始内容:
# tnsnames.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
修改后的内容:
# tnsnames.ora Network Configuration File: /oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.47.131)(PORT = 1521))
)
(CONNECT_DATA =
(SID = orcl)
)
)
在数据库服务器中启动监听并更新注册
1、命令:
[oracle@localhost ~]$ lsnrctl stop #先关闭监听服务
输出:
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-FEB-2017 21:19:42
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.78.130)(PORT=1521)))
The command completed successfully
[oracle@localhost ~]$
2、命令:
[oracle@localhost ~]$ lsnrctl start #开启监听服务
输出:
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-FEB-2017 21:24:22
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /data/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /data/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written t