首页 > 代码库 > CentOS7 Mini安装Oracle后用PL/SQL连接数据库

CentOS7 Mini安装Oracle后用PL/SQL连接数据库

1、本来是安装完数据库后,本地可以访问了,而Win10下Oracle客户端配置Oracle Net Manager时报连接超时

解决方法:

这种连接超时,让我想到telnet连接问题,就用telnet测试,连接被拒绝

然后就安装telnet和telnet service,而centos默认防火墙是firewall不是iptables,所以就关闭firewwall,安装iptables,并开启23端口

操作方法可参考····················

2、telnet连通了,再在oracle net manager测试连接数据库,报连接字符串错误,本以为和上次解决错误一样,就删除监听,重新配置监听,重启系统,还是不行

解决方法:

在ORACLE_HOME/network/admin/路径下打开并编辑文件listener.ora,我本地的文件如下(感觉这个错是环境变量没配置好导致)

# listener.ora Network Configuration File: /opt/oracle/product/11gR2/network/admin/listener.ora# Generated by Oracle configuration tools.SID_LIST_LISTENER =   (SID_LIST =     (SID_DESC =       (SID_NAME = orcl)          (ORACLE_HOME = /opt/oracle/product/11gR2)     )   )LISTENER =  (DESCRIPTION_LIST =    (DESCRIPTION =      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.36.133)(PORT = 1521))    )  )ADR_BASE_LISTENER = /opt/oracle

这个文件改好后,又把tnsnames.ora文件中localhost改为本地IP,不知这个是否起了作用,反正改了也没错

# tnsnames.ora Network Configuration File: /opt/oracle/product/11gR2/network/admin/tnsnames.ora# Generated by Oracle configuration tools.ORCL =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.36.133)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = orcl)    )  )

修改完这些后,停止监听,启动监听

[oracle@localhost root]$ lsnrctl stop[oracle@localhost root]$ lsnrctl start

3、再用oracle net manager测试连接数据库,报错

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist Linux-x8

解决方法:

centos7本机系统oracle用户登录,连接数据库

[oracle@localhost ~]$ sqlplus /nologSQL> conn / as sysdbaSQL> startup

如果startup报已经启动,则先关闭,再启动

SQL> shutdown immediateSQL> startup

 

CentOS7 Mini安装Oracle后用PL/SQL连接数据库