How to interface an AWS hosted website with Database on EBS? - amazon-web-services

The startup I'm working for is constructing a website, and we want to use AWS to run and host our site and the accompanying mysql database. Apparently when you terminate an AWS instance, any data stored on it is lost, so we would be keeping the database on the EBS system. The thing I can't figure out, though, is how to interface things running on these two different platforms. How do I tell the web server where the database is?
Sorry if this is a really noob question. Still trying to grasp how this whole cloud service works.

If I am reading correct, your DB is on the EBS mounted on the same machine, if that is the case, you have to make sure you tell MySQL (my.cnf) to point it's datadir to EBS directory.
Rest is as usual. Your host is localhost and your user credentials.
BTW, FYI, there is one more option from Amazon for DB that is RDS (http://aws.amazon.com/rds/) which provides lots of functionality + advantages, take a look at it.

Related

Migrating on premise web application to AWS ec2

Can some one please advise the steps required for migrating a web application which is currently running on tomcat server at onpremise to AWS ec2 instance. I understand this is not a straight forward and requires some detailed process.
The code is wrriten in Java and database used as oracle.
So it would be helpfull if someone can suggest me any relavent document or any website which gives some demo to refer me and proceed with this scenario.
If it's a personal project then I would recommend Lightsail as the simplest way to deploy existing Java application.
For a database a small instance of MySQL or if relational database is not needed then a document database like DynamoDB. https://aws.amazon.com/products/databases/?nc2=h_m1
There are multiple choices one how to migrate a Java application to AWS.
You could potentially use existing AWS services like:
Lightsail - https://aws.amazon.com/lightsail/
Beanstock - https://aws.amazon.com/elasticbeanstalk/
or
EC2 instance and install Tomcat manually
Use ECS with Docker https://aws.amazon.com/getting-started/tutorials/deploy-docker-containers/?nc2=type_a
As for Database solution Oracle is an option but quite expensive one.
When moving to AWS it's better to use one of the RDS managed databases like MySQL, Postgress or more expensive like Aurora.
In order to propose an architecture some details would be needed on predicted load, the size of the application and volume of data. Is the product regional or global, are there any additional issues that need to be addressed while moving to a cloud (performance, availability etc), how users are authenticated (are any other services needed).

Does an AWS Lightsail database instance support multiple databases?

I am trying to understand exactly what a "Database" is within Amazon Lightsail. I've attempted to research this as much as possible through Google and various forums, but information on this particular issue seems limited.
My impression (and hope) is that a "Database" as far as Lightsail is concerned is actually a database instance, or in other words a virtual machine running a database server, that once created is able to be used to hold multiple databases.
I tried to test this theory by creating a Database instance on lightsail, then connecting to it using MySQL Workbench, and running a "CREATE test_db" query. From what I could tell, this seemed to work, but it was the first time I'd used Workbench, so was not entirely convinced I'd created a database within my instance.
Can anyone please offer some clarity on this matter?
A Lightsail database instance is a MySQL server running in Amazon RDS. You have exclusive use of this server -- is isn't shared. You can create as many databases ("schemas") on it as you want using standard queries.

querying Amazon Aurora with Java

I apologize if this is too broad, but I am very new to AWS and I have a specific task I want to do but I can't seem to find any resources to explain how to do it.
I have a Java application that at a high level manages data, and I want that application to be able to store and retrieve information from Amazon Aurora. The simplest task I want to achieve is to be able to run the query "SELECT * FROM Table1" (where Table1 is some example table name in Aurora) from Java. I feel like I'm missing something fundamental about how AWS works, because I've thus far been drowning in a sea of links to AWS SDKs, none of which seem to be relevant to this task.
If anyone could provide some concrete information toward how I could achieve this task, what I'm missing about AWS, etc, I would really appreciate it. Thank you for your time.
You don't use the AWS SDK to query an RDS database. The API/SDK is for managing the servers themselves, not for accessing the RDBMS software running on the servers. You would connect to AWS Aurora via Java just like you would connect to any other MySQL database (or PostgreSQL if you are using that version of Aurora), via the JDBC driver. There's nothing AWS specific about that, other than making sure your code is running from a location that has access to the RDS instance.

Accessing a database inside an EC2 instance

Is it possible to create a database server (MySQL or PostgreSQL) inside an EC2 instance (running Windows 2016) and access it the way we access an RDS or do I need to have a separate RDS for that purpose?
My plan was to have an EC2 instance and use it as a server for accessing some Windows applications to my (small) company as well as an always-available database to store our reports.
Please let me know if I am on the wrong path.
Yes, you can install MySQL or PostgreSQL on an EC2 instance, just like you would for a server that was within your company.
You of course won't have all of the extra redundancy/backup features that RDS provides for you - unless you start adding all of that yourself i.e. automated backups, slave/master configurations, read replicas etc. (and if you do start adding all of those extra features in I would reconsider your decision not to use RDS).
I do this for some smaller, less mission critical solutions I support, and generally have not had many issues; I still prefer RDS when possible, but its not always an option for me.
You can install and configure DB on windows and access from your app. the endpoint will be windows machine IP and running service port. you have to allow the application from the security group.

updating all files on AWS EC2

I'm trying to determine the "best" way for a small company to keep web app EC2 instances in sync with current files while using autoscaling.
From my research, CloudFormation, Chef, Puppet, OpsWorks, and others seem like the tools to do so. All of them seem to have a decent learning curve, so I am hoping someone can point me in the right direction and I'll learn one.
The initial setup I am after is:
Route53
1x Load Balancer
2x EC2 (different AZ) - Apache/PHP
1x ElastiCache Redis
2x EC2 (different AZ) w/ MySQL
Email thru Google Apps
Customer File/Image Storage via S3
CloudFront for CDN
The only major challenge I can see is versioning/syncing the web/app server. We're small now, so I could probably just manually update the EBS or even using rsync, but I would rather automate it and be setup for autoscaling.
This is probably too broad of a question and may be closed, but let me give you a few thoughts.
Why not use RDS for MySQL?
You need to get into the thought of how to make and promote disk images. In the cloud world, you don't want to be rsyncing around a bunch of files from server to server. When you are ready to publish a revised set of code, just make am image from your staging environment, start new EC2 instances in your ELB based on that image, and turn off old instances. You may have a little different deployment sequence if you need to coordinate with DB schema changes, but that is a pretty straightforward approach.
You should still seek to automate some of your activities using tools such as those you mentioned. You don't need to do this all at once. Just figure out a manual part in your process that you want to automate and do it.