Google Compute Engine中的Oracle数据库 [英] Oracle Database in Google Compute Engine

查看:122
本文介绍了Google Compute Engine中的Oracle数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Google Compute Engine(GCE)虚拟机(Windows Server 2012 Datacenter)中安装了Oracle 11g标准版.我已经在Windows防火墙中为tcp:1521创建了入站和出站规则.同时,我为GCE网络创建了tcp:1521防火墙规则.

I have installed Oracle 11g Standard Edition in a Google Compute Engine (GCE) virtual machine (Windows Server 2012 Datacenter). I have created an inbound and outbound rule for tcp:1521 in the Windows Firewall. At the same time, I have created a tcp:1521 firewall rule for GCE network.

当我从本地主机使用SQL Developer连接到数据库时,一切正常.但是,如果尝试从远程主机(也使用SQL Developer)连接到数据库,则会收到错误消息:

When I connect to my database using SQL Developer from localhost everything works. However, if I try to connect to the database from a remote host (also using SQL Developer) I obtained an error:

Status: Failure - Test failed: IO Error: The Network Adapter could not establish the connection.

我成功ping通了从远程主机托管数据库的虚拟机,但是,当我通过telnet进行连接时,连接失败了:

I successfully ping the virtual machine that hosts the database from a remote host, nonetheless when I telnet it the connection fails:

Connecting To <host-ip>... Could not open connection to the host, on port 1521: Connect failed

此外,nmap指出在虚拟机中对端口1521进行了过滤.

Moreover, nmap states that port 1521 is filtered in the virtual machine.

我想念什么?感谢您的帮助.

What am I missing? Thanks for your help.

推荐答案

考虑到您的回答,我进行了更多研究,这是我们应该考虑的问题:

I research a little bit more taking into account your answer and this is what we should consider:

1.配置Windows Server防火墙: 转到Control Panel-> System and Security-> Windows Firewall-> Advanced settings.然后使用以下功能创建一个新的入站规则:

1. Configure Windows Server Firewall: Go to Control Panel -> System and Security -> Windows Firewall -> Advanced settings. Then create a new inbound rule with the follow features:

规则类型: Port

协议: TCP

端口号: 1521(除非您在Oracle数据库中指定了另一个端口)

Port number: 1521 (unless you have specified a different one at your Oracle database)

操作: Allow the connection

个人资料: Domain + Private + Public(或适用于您的案例的个人资料)

Profile: Domain + Private + Public (or the one that applies to your case)

名称: Oracle DB(或您想要的任何名称)

Name: Oracle DB (or any name you want)

完成后,请使用与入站规则指定的功能相同的功能创建出站规则.

Once you have finished, create an outbound rule with the same features specified for the inbound rule.

2.配置Google Compute Engine网络防火墙:在Google Compute Engine(GCE)控制台上,转到Networking-> Firewall rules.然后单击New firewall rule并进行配置:

2. Configure Google Compute Engine Network Firewall: At Google Compute Engine (GCE) console go to Networking -> Firewall rules. Then click on New firewall rule, and configure it:

名称: oracle-db(或您想要的任何名称)

Name: oracle-db (or any name you want)

网络: default(或您已部署虚拟机的网络.请通过VM实例仪表板进行验证)

Network: default (or the one where you have deployed your virtual machine. Verify it form VM instances dashboard)

源过滤器: Allow from any source (0.0.0.0/0)(警告:如果您只想启用一个主机或一组主机,则应选择IP范围.然后指定您的域或IP地址)

Source filter: Allow from any source (0.0.0.0/0) (WARN: you should select IP ranges if you just want to enable a host or a set of hosts. Then specify your domain or IP address)

允许的协议和端口: tcp:1521(或适用于您的情况的协议和端口-与您为Windows防火墙规则定义的相同)

Allowed protocols and ports: tcp:1521 (or the one that applies to your case - the same that you have defined for your Windows Firewall rules)

最后,单击创建.

3.配置Oracle Net Listener:默认情况下,Oracle数据库不接受远程连接.它只接受本地主机请求.因此,在您的Oracle数据库服务器上以管理员身份打开CMD.我们将在执行时停止数据库网络侦听器:

3. Configure Oracle Net Listener: By default Oracle database does not accept remote connections. It just accepts localhost requests. Therefore, at your Oracle database server open a CMD as administrator. We will stop the database net listener while executing:

lsnrctl STOP

现在,转到Oracle安装路径ORACLE_PATH(通常:ORACLE_PATH = C:\app\<user_name>).然后导航至:ORACLE_PATH\product\11.2.0\dbhome_1\NETWORK\ADMIN.在那里,您将找到两个重要文件:listener.oratnsnames.ora.打开listener.ora并通过您的服务器主机名更改所有LOCALHOST的发生(警告:没有IP地址,而是服务器HOSTNAME).

Now, go to the Oracle installation path ORACLE_PATH (usually: ORACLE_PATH = C:\app\<user_name>). Then navigate to: ORACLE_PATH\product\11.2.0\dbhome_1\NETWORK\ADMIN. There you will find two important files: listener.ora and tnsnames.ora. Open listener.ora and change all LOCALHOST ocurrences by your server hostname (WARN: no the IP address, instead the server HOSTNAME).

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = <server_hostname>)(PORT = 1521))
    )
  )

保存您的更改.然后,打开tnsnames.ora文件.并为您的服务做同样的事情:

Save your changes. Then, open the tnsnames.ora file. And do the same for your services:

YOUR_SERVICE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <server_hostname>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = your_service_name)
    )
  )

LISTENER_YOUR_SERVICE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = <server_hostname>)(PORT = 1521))

保存您的更改.最后,我们应该重新启动网络监听器.因此,以管理员身份进入CMD并执行以下命令:

Save your changes. Finally, we should restart the net listener. So go to the CMD as an administrator and execute the following command:

lsnrctl START

打开浏览器,然后输入: http://localhost:1158/em .您的数据库和侦听器应正在运行.现在,您可以从远程主机进行连接.

Open your browser and type: http://localhost:1158/em. Your database and listener should be running. Now you can connect from remote hosts.

有关更多信息,请参阅: http://docs.oracle.com/cd/B28359_01/network.111/b28316/listenercfg.htm

For more information, please refer to: http://docs.oracle.com/cd/B28359_01/network.111/b28316/listenercfg.htm

这篇关于Google Compute Engine中的Oracle数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆