工作需要在Linux服务器上安装oracle11g,发现远程过去通过命令行执行SQL命令比较麻烦,想在自己的window系统上安装PL/SQL软件链接到ORACLE。开始以为很简单,发现一直配置不上。看了一些文章都不是很清楚。但最终还是配置成功。
首先Linux上安装oracle,这个过程很容易图形界面一直下一步基本就能完成。在安装完oracle后需要设置监听,可以使用图形界面,也可以直接修改文件或是通过命令。
1、通过命令:SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.99)(PORT=1521)(SID=orcl))'
2、修改文件:/usr/local/oracle/app/product/11.2.0/network/admin/listener.ora
# listener.ora Network Configuration File: /usr/local/oracle/app/product/11.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME =/usr/local/oracle/app/product/11.2.0)//linux安装的目录
(PROGRAM = extproc)
)
(SID_DESC=
(GLOBAL_DBNAME=ORCL)
(ORACLE_HOME=/usr/local/oracle/app/product/11.2.0)
(SID_NAME=ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.99)(PORT = 1521)) //ip
)
)
ADR_BASE_LISTENER = /usr/local/oracle/app
/usr/local/oracle/app/product/11.2.0/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /usr/local/oracle/app/product/11.2.0/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.99)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
在window客户端使用PL/SQL登陆的时候在数据栏直接使用 ip+port+实例名
我的是192.168.1.99:1521/orcl
点击确定就可以登陆。
如果登陆不上去,很可能是linux服务器的防火墙没有开发1521端口
修改linux 下面的防火墙文件 /etc/sysconfig/iptables文件: 红色的是添加的内容
service iptables status //查看状态
service iptables stop //关闭防火墙
service iptables start //启动防火墙
service iptables restart //重启防火墙
如果开了端口 还是连接不上 ,我建议关闭防火墙!!
# Generated by iptables-save v1.4.7 on Mon Aug 17 11:45:38 2015
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [77:9565]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 1521 -j ACCEPT
COMMIT
# Completed on Mon Aug 17 11:45:38 2015
~
~