Can amazon ec2 connect to an external oracle database server? - database

my project requires me to use PHP and connect to the oracle database service hosted by our department. I want to use amazon ec2 to deploy the project. Is it able to connect to an external oracle database from amazon ec2 by PHP?
I've tried google app engine. It doesn't support external database connection. what a drawback!

Yes, it does. By default, Ec2 instances launched in EC2-Classic have full outbound access. So, the Ec2 instance can connect to your Oracle DB Provided your Oracle DB is accessible over the internet (in other words, your Oracle DB has a public IP address and you have firewall rules configured on your end to allow inbound access to Oracle DB).
If you Oracle DB is in a private network, then you need proxy server or SSH tunnel (or something similar) to connect to the instance.
Overall, there is no limitation on EC2 side.

Related

Connecting RDS SQL Server from AWS EC2 SQL Server Management Studio

I am unable to connect my RDS SQL Server instance from my AWS EC2 instance.
I have installed SQL Server Management Studio on my AWS EC2 Windows Server 2019 instance.
I am neither able to ping my RDS endpoint from that machine nor able to connect using SSMS. In the security group inbound rules for RDS I have entered IP of my EC2 instance under all traffic option, also tried using SQL Server option in security inbound rules.
There's two key questions that are relevant here: 1) is the connectivity allowed in AWS, and 2) is the connectivity allowed by the host/applications on the individual instances.
For 1, you need visibility into the networking aspect of your cloud. I use Batfish's virtual traceroute in your environment. There's an free and open source project (https://batfish.org) or you can try a free trial of the enterprise offering (https://www.intentionet.com/trial).
After you validate that the traffic is allowed in AWS (no Network ACLs or security groups are misconfigured, vpc peerings / routing tables are correct, etc.) you should move on to verifying application config on the actual hosts.
(Disclaimer: I work on Batfish and Batfish Enterprise).
What you need to do is:
The security group that you have attached to the RDS instance you need to add a rule for the inbound section of the security group to be SQL Server and have the source of that rule be the same name as the security group, this is called a self referencing security group rule. Then go to the EC2 instance and attach that same security group to the instance. This will solve the Security Group potential problem.
The other piece you need to check is if the EC2 instance is in a different subnet than the RDS SQL Server you need to make sure the Network Access Control List (NACL) will allow the inbound/outbound traffic of SQL between the subnets.

How to pull data from an AWS hosted DB to on-prem or Azure SQL DB

How do I make connection to an AWS hosted database, and pull or query data into a local or Azure hosted SQL server DB? Can I be directed to the right place or resource?
Thanks.
There's nothing special about the fact that they're in AWS or Azure VMs. For this to work, you need TCP/IP connectivity from your client to the server, and you need port 1433 to not be blocked along the way.
The VM in AWS or Azure needs to have an externally visible IP address, or you need to be connecting via a VPN to the internal network of the cloud-hosted system. The operating system on that VM that's hosting SQL Server needs to have a firewall rule that allows port 1433 inbound.
Once you can do that, you can then just set up a Linked Server on your end, that refers to the SQL Server at the other end. That will allow you to query the tables on the server via 4 part names i.e. linkedservername.databasename.schemaname.tablename.
If you have SQL Server with the same collation at both ends, also ensure you set "collation compatible" on the linked server configuration. (It can make a huge performance difference)

Connect to Internal SQL database from Azure Web Application

I'm trying to build a webservice that talks to a SQL database hosted on a server in our internal network. The service is hosted by Azure as a Web App. Is there a good way of doing this? Do I have to use Azure Sql databases, and if I do, is there a way to have the Azure database act as a proxy for our internal database?
There are already rules permitting connections to the ports on our database server, so I don't think that's the problem. I see a lot of questions regarding connecting to Azure hosted sql databases, but nothing about connecting Azure web apps to other kinds of databases.
The error occurs when I try to call a stored procedure (via generated entity framework code) and is as follows:
Error occurred: System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Our database is configured to allow remote connections, so what I'm guessing the Web App is having difficulty connecting to our vpn.
Please let me know if you need any additional information.
Thanks,
Josh
You can leverage Azure Hybrid Connections which is a feature of App service. Within App Service, Hybrid Connections can be used to access application resources in other networks. It provides access from your app to an application endpoint and uses Azure Relay service to connect to on-premise.
Check out the below link for more details :
https://learn.microsoft.com/en-us/azure/app-service/app-service-hybrid-connections
First option is to look on azure app service hybrid connection but for you to do that you should have Windows server 2012 or above.
Azure App Service Hybrid
Azure App Service hybrid connection is good if you are pulling small amount of data.
If you are pulling large amount of data or your SQL server version is below server 2012 you have two options:
Azure Site to Site VPN
Azure SQL Data Sync
Azure SQL DB Sync is a feature that available on Azure SQL database. You can create a Azure SQL database on azure and sync your on-premise SQL database or SQL database table to Azure SQL database and you can connect your application to Azure SQL database instead of connecting to on-premise database server. This will increase your performance of your application.
We ended up adding the application to an Azure Virtual network that allowed connections to our on-prem servers. The remaining difficulties were due the wrong port numbers being open.
What was very helpful in debugging this was the Kudu console in Azure, under Advanced tools -> console. There you can run commands from the machine hosting your application like ping, or the below:
sqlcmd -S tcp:servername,1433 -U Username -d databasename -P password -q "SELECT * FROM tablename"

Connecting to oracle database using connection on another server

we have oracle database hosted at a third party location. we can only access that database from one server on our network. the third party only allowed access to the database from that server. our web apps are hosted on a different server and there is no way that we can open connection to the database from the web server. is there a way that we can use the allowed server to access the database from the web server which resides on the same network, kind of a centralized connection hub
As a practice industry wise . From Web-Server access to the database is not allowed from security point of view . Consult your network team by sending the ping of the IP address of the database server from web server . The result will show what is happening between web server and database server

Connect to an external (Oracle) database using JDBC

I want to use CF as an app container but as CF doesn't provide an Oracle DB service I have to use an external Oracle DB. Can my Java app that runs on CF infrastructure connect to an external Oracle DB that is located on another server using JDBC?
In Google App Engine you can't use JDBC at all.
you should be able to. The only outbound port that is block from CloudFoundry.com I believe, is port 25 (for obvious reasons).

Resources