connecting to database on ec2 Virtual Machine from sql developer - amazon-ec2

I am using Oracle SQL Developer 4 to connect to databases . We are running an Oracle 11g on Amazon EC2 Virtual Machine (not RDS) and I can’t connect remotely. inside the Virtual Machine as local host it work fine.
how can I set up my Virtual Machine to be able to connect remotely via sql developer to database installed on that Virtual Machine.

I encountered the same problem today and here is my configuration.
The Oracle 11g is installed on a RHEL EC2 instance and the SQL developer is installed on a Windows 2008 R2 Server instance.
We need to do these three things to fix the problem:
1) In the security group of the Amazon instances, add the inbound rules to allow connections to the Linux server. Notice that the Source IP address has to be the AWS private IP in the format of 172.31.0.0/16 instead of the public IP of 52.76.0.0/16.
2) Add the entry as below to your tnsnames.ora file:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ec2-52-76-XX-XX.us-west-2.compute.amazonaws.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.us-west-2.compute.internal)
)
)
3) On the RHEL instance, only the ports of 22 (SSH) and 5904 (TightVNC) are opened now. We need to use the following command from ec2-user account to punch a hole in the firewall to open the port of 1521 which is used by Oracle database service.
sudo iptables -I INPUT -p tcp --dport 1521 -j ACCEPT

Related

Issue connecting with local database from sql developer

I am getting the following error while connecting to a local database (After I enter the
username and password
Following are the properties for this database that I am trying to
The services 1. OracleXETNSListener 2. OracleServiceXE
are running. I am not sure what could be causing this error and I am able to connect
to local DB with sqlplus command although with a different username and password
The listener.ora has the following entry:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = L05015765)(PORT = 1521))
)
)
Also, I couldn't find any output for
netstat -aof | findstr :1521
netstat -aof | findstr :8080
netstat -aof | findstr :8082
which probably means nothing is running on 1521, and so the local connection that I
want to make it on port 1521 as per the properties window in SQL developer.
I am not sure how to debug this further and what could be going wrong
Your listener configuration shows that is listening on port 1521 on L05015765. That is your PC's name, and in network terms will presumably resolve to your LAN IP address (e.g. 192.168.0.1).
Your SQL Developer connection is to port 1521 on localhost, which is a different network adapter, which will resolve to a different private, fixed , IP address, 127.0.0.1. (Although it may not actually work at all by default on Windows, I believe).
If you change your connection to use L05015765 to match the listener configuration, you will be able to connect.

Connecting from Host-SQLDeveloper to Virtualbox VM Oracle Database [duplicate]

I'm in real need of a help here. I setup a Oracle Database server on a VirtualBox VM and until yesterday everything seemed to work just fine. Today when I initiated the database to keep working, and turned on SQLDeveloper in my local machine (Client machine) it threw me this error:
Erro de ES: The Network Adapter could not establish the connection
My VirtualBox VM network setting is configure to bridged adapter. And I was able to connect just fine and today, out of nothing this error started occurring.
I did some research but none of them worked for me. Tried to follow this guy solution:
Oracle SQL Developer: Failure - Test failed: The Network Adapter could not establish the connection?
And didn't work as well. I'm gonna share my lsnrctl status and my file here so you can take a look.
First this is how I start my setup:
1. lsnrctl start to start the listener. Resulting in:
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 24-AUG-2020 10:40:56
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbserver)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 24-AUG-2020 10:40:56
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
2. sqlplus / as sysdba to start sqlplus shell and then startup to start the database instance, which gives:
ORACLE instance started.
Total System Global Area 2550136832 bytes
Fixed Size 8623928 bytes
Variable Size 671090888 bytes
Database Buffers 1862270976 bytes
Redo Buffers 8151040 bytes
Database mounted.
Database opened.
Then my lsnrctl status gives:
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 24-AUG-2020 10:46:34
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbserver)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 24-AUG-2020 10:40:56
Uptime 0 days 0 hr. 5 min. 38 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=dbserver)(PORT=5500))(Security=(I removed the path for security))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
My listener.ora:
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbserver)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
My tnsnames.ora:
GNU nano 2.9.8 tnsnames.ora Modified
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbserver)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbserver)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
When I try to connect in the database through the SQLDeveloper installed inside the Virtual Machine (That is the server side) it works ok, but when I try to connect from the SQLDeveloper on the local machine (Client side) i throws the error.
Every post I saw, told me to look on the listener status, but that is not the problem, I think.
I'd appreciate any help guys. And thank you very much, any additional information I`m here to answer. =D
EDIT: forgot to mention that I'm using version 12c of the Oracle Databse
EDIT: Here is how I'm trying to connect to the DB:
EDIT: When I ping the host for the DB I get this:
[oracle#dbserver admin]$ ping dbserver
PING dbserver(dbserver (fe80::f8dd:c03c:920c:5442%enp0s3)) 56 data bytes
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=2 ttl=64 time=0.053 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=3 ttl=64 time=0.051 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=4 ttl=64 time=0.072 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=5 ttl=64 time=0.049 ms
^C
--- dbserver ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 131ms
rtt min/avg/max/mdev = 0.049/0.060/0.075/0.011 ms
I used to fight with VM networking settings such that my host could 'see' my vm, and vice versa.
I stopped worrying about this once i learned about port forwards.
You can simply tell VirtualBox to take traffic from your local port, say 1521, and forward that to the VM, say also 1521.
So when connecting to the VM from my host in SQL Developer, I can go to localhost:1521, and have my connection traffic go to the Oracle Listener on my Linux VBox image, listening on port 1521
Click on Port Forwarding
Add an entry for TCP 1521 and 1521
Then, in SQL Developer you can simply do this to connect to your DB on the VM
I'm glad you got it working, but as an alternative, let me say that I'm not a big fan of port forwarding for this issue, nor am I a fan of using the bridged adapter. I've created scores of VMs under VBox, both on Windows and on Ubuntu hosts. In every case I create HOSTONLY adapter, and configure it with a fixed IP address. I then add an entry for the vm in the host's 'hosts' file. See more detail at https://edstevensdba.wordpress.com/2012/12/15/configure-the-virtualbox-network-2/

sqldeveloper on Host - VirtualBox (NAT network) - Virtual Machine Guest (ORA 12c DB)

I have a problem with connection to ORA DB configured on Virtual Machine, where windows server 2016 is also installed.
In first configuration, I installed ORA DB 11G on Ubuntu, I opened port 1521 on Ubuntu. Virtualbox has NAT network setting and unfortunately it won't change because of administration restrictions (I won't get any new ip from bridged network,etc.). In virtual box NAT FORWARDING I set host port 2223 and guest port 1521.
Then I put a proper configuration in tnsnames in both machines (host and guest), next I connected to ORA DB on ubuntu via sql developer from the host machine using such a configuration:
UBUNTU_XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 2223))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
It works perfectly
I configured ORA DB 12C on Windows Server 2016, in firewall inbound/outbound rule I opened port 1521 for Oracle. ORA Services is running on local user name: oracle which was created before ORA installation. I logged in as user name: oracle to conduct oracle installation. In virtual box NAT FORWARDING I set host port 2225 and guest port 1521.
Then I put a proper configuration in tnsnames in both machines (host and guest), next I connected to ORA DB on Windows server (guest) via sql developer from the host machine using such a configuration:
PDB_WIN_SERV16_FORWARD_127.0.0.1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 2225))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)
)
)
I tried also:
PDB_WIN_SERV16_FORWARD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 2225))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)
)
)
I want to confirm that above-mentioned connection works perfectly on Windows Server 2016 (of course with replacing port 2225 with 1521), on the other hand is not working on the host computer, the connection process in sql developer is still lasting. When I pick stop I get a communicate "Socket read interrupted, connect lapse 1857ms, authentication lapse 0 ms.
What is missing in configuration in windows server 2016 so as I could connect to ORA DB from the host?
Greetings
The problem was the same as always. Listner.ora should have listened in a static registration on 10.0.2.15 (IP in NAT configuration). Then you have to restart listener via cmd line>lsnrctl restart. After you open listener port in inbound tcp rules and set proper nat forwarding in virtual box network configuration, e.g. PORT HOST 2223 GUEST PORT 1521, you will be able to connect to ORA DB on Virtual Machine using a connection from tnsnames on host computer:
WIN_SERV16_FORWARD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 2223))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb4)
)
)

getting ORA-12545 even though host name is correct

I am try to access remote database by making these changes to my tnsnames.ora file (sorry won't declare host names and service name here)
MYDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host_name)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xxxx.edu)
)
)
sqlnet.ora
# sqlnet.ora Network Configuration File: C:\app\nsm\product\12.1.0\admin\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
However,I am getting ORA-12545 and looks like hostname is not right.Actually,one other person connected to the db using the very same host name but I can't connect.Is there anything wrong with my ora file? I am using Windows.
Any help is appreciated.
I had this problem with a Windows 10 client, where both IPv6 and IPv4 were active. Apparently, it was trying to resolve the host name through IPv6 where the domain doesn't exist, instead of our IPv4 DNS.
Disabling IPv6 on the network adapter fixed the problem, until we can get the name resolution working on both 4 and 6.

telnet : could not open connection to host

I am trying to remotely access oracle DB using jdbc but got problems, after searching through i learned that ports might be blocked by the firewall.
I am getting the following error when i am executing the command to test if port is opened or not,
telnet MyIP 1521
Connecting to MyIP...Could not open connection to the host, on port 1521 : Connect failed
I tried opening the ports by making new inbound rule but still the error exists.
Atlast i turned my firewall off but it's still the same.
If i try the same command for localhost, i.e.,
telnet localhost 1521
It works, but using my ip address it's not.
How can i resolve this ?
Some ISP's block certain ports that might be targets for certain attacks. I know with MSSQL it uses port 1433 or something similar, and my service provider blocks connections to that port.
Try setting up your dB to use a different port than the standard and see if that works. You could also call your provider to see if they're actually blocking the port.
Configuring the connection between client and server Oracle 10g
In a comment you have an extract from lsnrctl status:
Listening Endpoints summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services summary...
Your listener is only listening on 127.0.0.1, so connections can only be made from the server. There is nothing listening on your external address 10.0.2.39, so connections to port 1521 on that address fail.
Your listener.ora presumably has something either a single ADDRESS, or no ADDRESS at all, which will default to localhost:1521. You need to modify it to something like:
LISTENER =
...
(ADDRESS_LIST =
...
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.39)(PORT = 1521))
)
or your machine's host name if that's resolvable to that address. Ideally this would be done through netca rather than by editing the file by hand.

Resources