Your SlideShare is downloading. ×
0
Christopher M. Judd
in the cloud
Thursday, August 29, 13
Christopher M. Judd
CTO and Partner at
leader
Columbus Developer User Group (CIDUG)
Thursday, August 29, 13
https://github.com/zendern/nuez
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
What is cloud
computing?
How is different
from what I am
doing today?
How do I get
started?
Will I get a raise?
Thursday, ...
Cloud Computing
Thursday, August 29, 13
Cloud computing is the delivery of computing as a service
rather than a product, whereby shared resources, software,
and i...
Software as a service (SaaS) - “on-demand” software
Platform as a service (PaaS) - solution stack
Infrastructure as a serv...
PaaS IaaS
AWS Elastic Beanstalk
➡flexibility
➡complexity
➡cost
Thursday, August 29, 13
DevOps
an emerging set of principles, methods and practices for communication, collaboration and integration between
softw...
treat infrastructure like
cattle not like pets
Thursday, August 29, 13
Current
Architecture
Thursday, August 29, 13
traditional Java architecture
Thursday, August 29, 13
traditional Java architecture
Thursday, August 29, 13
traditional Java architecture
Thursday, August 29, 13
traditional Java architecture
Thursday, August 29, 13
traditional Java architecture
Thursday, August 29, 13
traditional Java architecture
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
AWS architecture
Thursday, August 29, 13
AWS architecture
Thursday, August 29, 13
Amazon web services architecture
Thursday, August 29, 13
AWS Elastic Beanstalk architecture
Thursday, August 29, 13
AWS architecture
Thursday, August 29, 13
Registration
Thursday, August 29, 13
http://aws.amazon.com/
start here
Thursday, August 29, 13
need a valid email address
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
AWS Account
admins opsdevelopers
user/group based security
Thursday, August 29, 13
Thursday, August 29, 13
developers
cmj njz jjs cmj0
* all accounts will be removed in a month
563700736850
Thursday, August 29, 13
http://escab.elasticbeanstalk.com/registration/
Register for your user account
You AWS Credentials will be emailed to you....
https://github.com/zendern/escab
Thursday, August 29, 13
https://563700736850.signin.aws.amazon.com/console
initials
codemash
AWS account #
Thursday, August 29, 13
https://console.aws.amazon.com
Thursday, August 29, 13
Interfaces
Thursday, August 29, 13
Web Console
Thursday, August 29, 13
Command-line
Thursday, August 29, 13
SDK Language Support
http://aws.amazon.com/tools/
Thursday, August 29, 13
EC2
Thursday, August 29, 13
Thursday, August 29, 13
A virtual machine (VM) is a software implementation of a machine (i.e. a computer) that executes
programs like a physical ...
AMIs (Amazon Machine Images)
Thursday, August 29, 13
Public AMIs
8180 of them and counting
http://aws.amazon.com/amis
Thursday, August 29, 13
That's awesome....
All I have to do is find what I need and off I go. 
Someone else created it, maintains it.... 
Thursday,...
But there could be some issues
with using these.....
Thursday, August 29, 13
Did this guy setup this server?
Thursday, August 29, 13
Who knows....
Thursday, August 29, 13
Don't be discouraged....
http://cloud.ubuntu.com/ami/
http://fedoraproject.org/wiki/Cloud_images
http://blog.susestudio.co...
Amazon Elastic Compute Cloud (Amazon EC2)
is a web service that provides resizable compute capacity in
the cloud. It is de...
EC2 Instance Types
•Micro
•M1 Small
•M1 Medium
•M1 Large
•M1 Extra Large
•M3 Extra Large
•M3 Double Extra Large
•High Memo...
Cost for On Demand
Thursday, August 29, 13
Cost for Reserved Instances
Thursday, August 29, 13
Bandwidth Pricing
Thursday, August 29, 13
EC2
with
web console
Thursday, August 29, 13
Thursday, August 29, 13
start here
Thursday, August 29, 13
then here or here
Thursday, August 29, 13
launch here
Thursday, August 29, 13
Thursday, August 29, 13
search for codemash select JavaWebServer AMI
7.x
Thursday, August 29, 13
effects redundancy and scale effects price and performance
effects availability zone
Thursday, August 29, 13
nothing to do here
Thursday, August 29, 13
nothing to do here
Thursday, August 29, 13
name instance with naming convention
Thursday, August 29, 13
create or use key pair for remote login
create new key pair name key pair
download key pair
and copy it to ~/.ssh
Thursday...
ssh rule
allowed ip addresses
Thursday, August 29, 13
ssh
open to the world
tomcat
Thursday, August 29, 13
Increased Security
Thursday, August 29, 13
your done
Thursday, August 29, 13
ok, almost done
Thursday, August 29, 13
your new instance
server name
Thursday, August 29, 13
Thursday, August 29, 13
Remote access to your EC2 instance
$ ssh -i ~/.ssh/your-key-pair.pem ec2-user@ec2-23-22-9-39.compute-1.amazonaws.com
The a...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@...
$ssh -i ~/.ssh/your-key-pair.pem ec2-user@ec2-50-19-72-29.compute-1.amazonaws.com
Last login: Thu Dec 29 13:47:16 2011 fro...
SSHing using Putty
Thursday, August 29, 13
Importing the PEM file
Import PEM file
for conversion
Thursday, August 29, 13
Conversion of Pem to PPK
Save private key
(ppk)
Thursday, August 29, 13
Setting up Putty to use PPK
1. Navigate to
Connection> SSH
> Auth
2. Select ppk file here
Thursday, August 29, 13
Log in via Putty
When prompted for login enter ec2-user
Thursday, August 29, 13
create a new AMI from this
Thursday, August 29, 13
Regions and Availability Zones
Thursday, August 29, 13
Regions and Availability Zones
US West US East
us-east-1b us-east-1c
us-east-1aus-west-1a
us-west-1b us-west-1c
Thursday, ...
Regions and Availability Zones
N. California N.Virginia
us-east-1b us-east-1c
us-east-1aus-west-1a
us-west-1b us-west-1c
T...
Thursday, August 29, 13
change region here
Half/Half
Thursday, August 29, 13
EC2
with
Command Line
Thursday, August 29, 13
Setup For Console Usage
Thursday, August 29, 13
Console Environment Setup
• Download AWS Console API Tools
o http://developer.amazonwebservices.com/connect/entry.jspa?ext...
Console Usage
• ec2-describe-images -o amazon
• ec2-add-keypair <key-pair-name>
• ec2-add-group <sec-group> -d <descriptio...
EC2
with
Java SDK
Thursday, August 29, 13
//SETUP CREDENTIALS
AWSCredentials creds = new
PropertiesCredentials(this.getClass().getResourceAsStream("/awsCredentials....
Creating a New Key PairUsing Java SDK
CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest();
String keyNa...
Creating a Security Group
Using the Java SDK
CreateSecurityGroupRequest r1 = new CreateSecurityGroupRequest("webserver-gro...
Creating the EC2 InstanceUsing the Java SDK
// CREATE EC2 INSTANCES
RunInstancesRequest runInstancesRequest = new RunInsta...
Giving the Instance Metadata
// TAG EC2 INSTANCES WITH USER METADATA
List<Instance> instances = runInstances.getReservatio...
Stopping/Terminating EC2 Instance
TerminateInstancesRequest terminateInstanceRequest =
new TerminateInstancesRequest().wit...
http://puppetlabs.com/
http://www.opscode.com/chef/
Infrastructure Automation
AWS CloudFormation
http://aws.amazon.com/clo...
Lab 1
1. Start instance of UberConf-2013-JavaWebServer
2. Verify Tomcat is running accessible
3. ssh to JavaWebServer inst...
Storage
Thursday, August 29, 13
• Structured Data
• Amazon DynamoDB - NoSQL DB
• Relational Databases (in EC2 and EBS)
• Amazon RDS - Managed databases li...
instance
EBS
Thursday, August 29, 13
Thursday, August 29, 13
S3 Pricing
Thursday, August 29, 13
EBS Pricing
Thursday, August 29, 13
Database
Thursday, August 29, 13
Thursday, August 29, 13
launch here
Thursday, August 29, 13
search for codemash select MySqlServer AMI
5.5
Thursday, August 29, 13
Thursday, August 29, 13
nothing to do here
Thursday, August 29, 13
nothing to do here
Thursday, August 29, 13
name instance with naming convention
Thursday, August 29, 13
select existing key pairs
Thursday, August 29, 13
developer’s machine
web application security group
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
$ ssh -i ~/.ssh/your-key-pair.pem ec2-user@ec2-184-72-144-98.compute-1.amazonaws.com
$ mysql -u codemash -pcodemash -e ‘cr...
$ mysql -h ec2-54-243-16-144.compute-1.amazonaws.com -u codemash -p nuez
Thursday, August 29, 13
user = codemash
password = codemash
Thursday, August 29, 13
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:devDb;MV...
grails war
Thursday, August 29, 13
$ scp -i ~/.ssh/your-key-pair.pem target/nuez-0.1.war ec2-user@
ec2-23-22-9-39.compute-1.amazonaws.com:/usr/share/tomcat7/...
SCP using Windows
Enter ec2-user here
Select you ppk
file here
Enter machine name
here
Thursday, August 29, 13
Lab 2
1. Start instance of UberConf-2013-MySqlServer
2. Connect with mysql tool or ssh to instance
3. Create nuez database...
Load Balancing
Thursday, August 29, 13
Thursday, August 29, 13
Launch
Launch Similar EC2 Instance
Thursday, August 29, 13
Launch
Thursday, August 29, 13
Load Balancing Instances
Thursday, August 29, 13
Configure Health Check
Thursday, August 29, 13
Select EC2 Instances
Thursday, August 29, 13
Review
Thursday, August 29, 13
Almost done
Thursday, August 29, 13
Here is the base url
to access the load
balancer
Getting url to load balancer
Thursday, August 29, 13
Lab 3
1. Create/start another instance of UberConf-2013-
JavaWebServer
2. Create a new load balancer
3. Add both UberConf-...
CDN
Thursday, August 29, 13
Thursday, August 29, 13
CloudFront Pricing
Thursday, August 29, 13
Start by creating a bucket
Setting up S3 with CloudFront
Thursday, August 29, 13
Logging can also be enabled
to tell you more about
your S3 usage
Click here to name and
finish creating your
bucket
Name S3...
Create S3 directory structure
Click here to create a new
folder inside your bucket
After clicking you will be
prompted to ...
Create this structure using
the same names
Create S3 directory structure (continued)
Create this structure using
the same ...
Uploading Static Content
Upload content destination folder
Thursday, August 29, 13
Click here to add files
(Multi file selection is possible
when browse window opens)
Uploading (continued)
Thursday, August 2...
Select corresponding static
files located in the webapp on
your machine to be uploaded
into S3
Uploading (continued)
Thursd...
Finish by pressing “Start
Upload”
Uploading(Almost done)
Thursday, August 29, 13
Make All S3 Files Public
Click here to make all files
under this directory available
to the world
Thursday, August 29, 13
Creating a new Cloudfront
Start by clicking here
or here
Thursday, August 29, 13
Selecting CDN Type
(download vs. streaming)
Thursday, August 29, 13
Setting up S3 as Origin
Thursday, August 29, 13
Thursday, August 29, 13
<link rel="shortcut icon" href="${grailsApplication.config.cloudfront.cdn.url}
${resource(dir: 'images', file: 'favicon.ic...
environments {
development {
grails.logging.jul.usebridge = true
	 	 cloudfront.cdn.url = ""
}
production {
grails.logging...
Lab 4
1. Create new S3 bucket
2. Create directory structure in S3
3. Upload all static content to S3 in the appropriate
di...
Elastic Beanstalk
Thursday, August 29, 13
Elastic Beanstalk
Select you platform
Thursday, August 29, 13
Elastic Beanstalk (Default application)
Thursday, August 29, 13
Elastic Beanstalk (Default application)
Thursday, August 29, 13
Creating your own application
Start here
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Use these fields to construct
connection string for application
Thursday, August 29, 13
Update Nuez with RDS Connection
// environment specific settings
environments {
development {
dataSource {
dbCreate = "upd...
Deploy the latest version of nuez
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Start here to modify
server configurations
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
Pricing
Thursday, August 29, 13
pay as you use
Thursday, August 29, 13
use small EC2 instance for one hour and pay $0.065
Thursday, August 29, 13
On-Demand - pay by hour no long-term commitment
Reserved - one-time payment and discounted hourly rate
Spot - bid for unus...
Thursday, August 29, 13
http://aws.amazon.com/calculator
Thursday, August 29, 13
Thursday, August 29, 13
Resources
Thursday, August 29, 13
Thursday, August 29, 13
Thursday, August 29, 13
http://aws.amazon.com/architecture/
Thursday, August 29, 13
http://aws.amazon.com/architecture/
Thursday, August 29, 13
Thursday, August 29, 13
http://www.infoq.com/presentations/Netflix-in-the-Cloud
Thursday, August 29, 13
CTO and Partner
email: cjudd@juddsolutions.com
web: www.juddsolutions.com
blog: juddsolutions.blogspot.com
twitter: javaju...
Upcoming SlideShare
Loading in...5
×

Java in the (Amazon) Cloud

2,081

Published on

Wonder what all the Cloud Computing hype is about? Want to know how to deploy a standard Java web application to the cloud and get limitless scalability? Well, this hands on tutorial will answer all your questions and provide confidence by walking you through the process of deploying a sophisticated Java web application to the Amazon Web Service (AWS) Cloud. During this tutorial you will provision clustered servers (EC2), relational database (EC2 and EBS), load balancer (Elastic Load Balancing), content delivery (Cloud Front) and how to monitor your whole infrastructure. Other Amazon Web Services will be demonstrated and discussed as appropriate.

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,081
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
46
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Java in the (Amazon) Cloud"

  1. 1. Christopher M. Judd in the cloud Thursday, August 29, 13
  2. 2. Christopher M. Judd CTO and Partner at leader Columbus Developer User Group (CIDUG) Thursday, August 29, 13
  3. 3. https://github.com/zendern/nuez Thursday, August 29, 13
  4. 4. Thursday, August 29, 13
  5. 5. Thursday, August 29, 13
  6. 6. What is cloud computing? How is different from what I am doing today? How do I get started? Will I get a raise? Thursday, August 29, 13
  7. 7. Cloud Computing Thursday, August 29, 13
  8. 8. Cloud computing is the delivery of computing as a service rather than a product, whereby shared resources, software, and information are provided to computers and other devices as a metered service over a network (typically the Internet). Thursday, August 29, 13
  9. 9. Software as a service (SaaS) - “on-demand” software Platform as a service (PaaS) - solution stack Infrastructure as a service (IaaS) - virtual computing infrastructure Thursday, August 29, 13
  10. 10. PaaS IaaS AWS Elastic Beanstalk ➡flexibility ➡complexity ➡cost Thursday, August 29, 13
  11. 11. DevOps an emerging set of principles, methods and practices for communication, collaboration and integration between software development (application/software engineering) and IT operations (systems administration/ infrastructure) professionals. It has developed in response to the emerging understanding of the interdependence and importance of both the development and operations disciplines in meeting an organization's goal of rapidly producing software products and services. Thursday, August 29, 13
  12. 12. treat infrastructure like cattle not like pets Thursday, August 29, 13
  13. 13. Current Architecture Thursday, August 29, 13
  14. 14. traditional Java architecture Thursday, August 29, 13
  15. 15. traditional Java architecture Thursday, August 29, 13
  16. 16. traditional Java architecture Thursday, August 29, 13
  17. 17. traditional Java architecture Thursday, August 29, 13
  18. 18. traditional Java architecture Thursday, August 29, 13
  19. 19. traditional Java architecture Thursday, August 29, 13
  20. 20. Thursday, August 29, 13
  21. 21. Thursday, August 29, 13
  22. 22. Thursday, August 29, 13
  23. 23. AWS architecture Thursday, August 29, 13
  24. 24. AWS architecture Thursday, August 29, 13
  25. 25. Amazon web services architecture Thursday, August 29, 13
  26. 26. AWS Elastic Beanstalk architecture Thursday, August 29, 13
  27. 27. AWS architecture Thursday, August 29, 13
  28. 28. Registration Thursday, August 29, 13
  29. 29. http://aws.amazon.com/ start here Thursday, August 29, 13
  30. 30. need a valid email address Thursday, August 29, 13
  31. 31. Thursday, August 29, 13
  32. 32. Thursday, August 29, 13
  33. 33. Thursday, August 29, 13
  34. 34. Thursday, August 29, 13
  35. 35. Thursday, August 29, 13
  36. 36. Thursday, August 29, 13
  37. 37. AWS Account admins opsdevelopers user/group based security Thursday, August 29, 13
  38. 38. Thursday, August 29, 13
  39. 39. developers cmj njz jjs cmj0 * all accounts will be removed in a month 563700736850 Thursday, August 29, 13
  40. 40. http://escab.elasticbeanstalk.com/registration/ Register for your user account You AWS Credentials will be emailed to you. If you don’t see it check your spam folder. Thursday, August 29, 13
  41. 41. https://github.com/zendern/escab Thursday, August 29, 13
  42. 42. https://563700736850.signin.aws.amazon.com/console initials codemash AWS account # Thursday, August 29, 13
  43. 43. https://console.aws.amazon.com Thursday, August 29, 13
  44. 44. Interfaces Thursday, August 29, 13
  45. 45. Web Console Thursday, August 29, 13
  46. 46. Command-line Thursday, August 29, 13
  47. 47. SDK Language Support http://aws.amazon.com/tools/ Thursday, August 29, 13
  48. 48. EC2 Thursday, August 29, 13
  49. 49. Thursday, August 29, 13
  50. 50. A virtual machine (VM) is a software implementation of a machine (i.e. a computer) that executes programs like a physical machine. Virtual machines are separated into two major categories, based on their use and degree of correspondence to any real machine. A system virtual machine provides a complete system platform which supports the execution of a complete operating system (OS). In contrast, a process virtual machine is designed to run a single program, which means that it supports a single process. An essential characteristic of a virtual machine is that the software running inside is limited to the resources and abstractions provided by the virtual machine—it cannot break out of its virtual world. Thursday, August 29, 13
  51. 51. AMIs (Amazon Machine Images) Thursday, August 29, 13
  52. 52. Public AMIs 8180 of them and counting http://aws.amazon.com/amis Thursday, August 29, 13
  53. 53. That's awesome.... All I have to do is find what I need and off I go.  Someone else created it, maintains it....  Thursday, August 29, 13
  54. 54. But there could be some issues with using these..... Thursday, August 29, 13
  55. 55. Did this guy setup this server? Thursday, August 29, 13
  56. 56. Who knows.... Thursday, August 29, 13
  57. 57. Don't be discouraged.... http://cloud.ubuntu.com/ami/ http://fedoraproject.org/wiki/Cloud_images http://blog.susestudio.com/2011/03/opensuse-114-for-amazon-ec2.html Thursday, August 29, 13
  58. 58. Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers. • Elastic • Completely Controlled • Flexible • Reliable Thursday, August 29, 13
  59. 59. EC2 Instance Types •Micro •M1 Small •M1 Medium •M1 Large •M1 Extra Large •M3 Extra Large •M3 Double Extra Large •High Memory Extra Large •High Memory Double Extra Large •High Memory Quadruple Extra Large •High CPU Medium •High CPU Extra Large •Cluster Compute Eight Extra Large •Cluster GPU Quadruple Extra Large •High I/O Quadruple Extra Large •High Storage Thursday, August 29, 13
  60. 60. Cost for On Demand Thursday, August 29, 13
  61. 61. Cost for Reserved Instances Thursday, August 29, 13
  62. 62. Bandwidth Pricing Thursday, August 29, 13
  63. 63. EC2 with web console Thursday, August 29, 13
  64. 64. Thursday, August 29, 13
  65. 65. start here Thursday, August 29, 13
  66. 66. then here or here Thursday, August 29, 13
  67. 67. launch here Thursday, August 29, 13
  68. 68. Thursday, August 29, 13
  69. 69. search for codemash select JavaWebServer AMI 7.x Thursday, August 29, 13
  70. 70. effects redundancy and scale effects price and performance effects availability zone Thursday, August 29, 13
  71. 71. nothing to do here Thursday, August 29, 13
  72. 72. nothing to do here Thursday, August 29, 13
  73. 73. name instance with naming convention Thursday, August 29, 13
  74. 74. create or use key pair for remote login create new key pair name key pair download key pair and copy it to ~/.ssh Thursday, August 29, 13
  75. 75. ssh rule allowed ip addresses Thursday, August 29, 13
  76. 76. ssh open to the world tomcat Thursday, August 29, 13
  77. 77. Increased Security Thursday, August 29, 13
  78. 78. your done Thursday, August 29, 13
  79. 79. ok, almost done Thursday, August 29, 13
  80. 80. your new instance server name Thursday, August 29, 13
  81. 81. Thursday, August 29, 13
  82. 82. Remote access to your EC2 instance $ ssh -i ~/.ssh/your-key-pair.pem ec2-user@ec2-23-22-9-39.compute-1.amazonaws.com The authenticity of host 'ec2-23-22-9-39.compute-1.amazonaws.com (50.19.72.29)' can't be established. RSA key fingerprint is 0b:c1:e1:b4:50:ec:cf:e7:a5:cb:20:4f:74:34:c5:29. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'ec2-23-22-9-39.compute-1.amazonaws.com,50.19.72.29' (RSA) to the list of known hosts. key downloaded earlier login as ec2-user server name Thursday, August 29, 13
  83. 83. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '~/.ssh/your-key-pair.pem' are too open. It is recommended that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: ~/.ssh/your-key-pair.pem Permission denied (publickey). don’t panic $ chmod 400 ~/.ssh/your-key-pair.pem Thursday, August 29, 13
  84. 84. $ssh -i ~/.ssh/your-key-pair.pem ec2-user@ec2-50-19-72-29.compute-1.amazonaws.com Last login: Thu Dec 29 13:47:16 2011 from 70.60.135.250 __| __|_ ) _| ( / Amazon Linux AMI ___|___|___| See /usr/share/doc/system-release/ for latest release notes. There are 3 security update(s) out of 4 total update(s) available -bash: EXPORT: command not found [ec2-user@ip-10-245-202-126 ~]$ your in, now you can: install software start services Thursday, August 29, 13
  85. 85. SSHing using Putty Thursday, August 29, 13
  86. 86. Importing the PEM file Import PEM file for conversion Thursday, August 29, 13
  87. 87. Conversion of Pem to PPK Save private key (ppk) Thursday, August 29, 13
  88. 88. Setting up Putty to use PPK 1. Navigate to Connection> SSH > Auth 2. Select ppk file here Thursday, August 29, 13
  89. 89. Log in via Putty When prompted for login enter ec2-user Thursday, August 29, 13
  90. 90. create a new AMI from this Thursday, August 29, 13
  91. 91. Regions and Availability Zones Thursday, August 29, 13
  92. 92. Regions and Availability Zones US West US East us-east-1b us-east-1c us-east-1aus-west-1a us-west-1b us-west-1c Thursday, August 29, 13
  93. 93. Regions and Availability Zones N. California N.Virginia us-east-1b us-east-1c us-east-1aus-west-1a us-west-1b us-west-1c Thursday, August 29, 13
  94. 94. Thursday, August 29, 13
  95. 95. change region here Half/Half Thursday, August 29, 13
  96. 96. EC2 with Command Line Thursday, August 29, 13
  97. 97. Setup For Console Usage Thursday, August 29, 13
  98. 98. Console Environment Setup • Download AWS Console API Tools o http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88 • Setup Your Path o export EC2_HOME=<Path to extracted download above> o export PATH=$PATH:$EC2_HOME/bin o export EC2_PRIVATE_KEY=<Path to downloaded key pair> o export EC2_CERT=<Path to downloaded X.509 certificate> o export JAVA_HOME=<Path to java install> Thursday, August 29, 13
  99. 99. Console Usage • ec2-describe-images -o amazon • ec2-add-keypair <key-pair-name> • ec2-add-group <sec-group> -d <description> • ec2-authorize <sec-group> -p 22 • ec2-run-instances <ami-id> -k <key-pair-name> -g <sec-group> • ec2-describe-instances • ssh -i <key-pair-pem-file> ec2-user@ec2-xx-xxx-xx- xx.compute-1.amazonaws.com • ec2-stop-instances <instance-id> • ec2-terminate-instances <instance-id> Thursday, August 29, 13
  100. 100. EC2 with Java SDK Thursday, August 29, 13
  101. 101. //SETUP CREDENTIALS AWSCredentials creds = new PropertiesCredentials(this.getClass().getResourceAsStream("/awsCredentials.properties"));  //CREATING EC2 CLIENT AmazonEC2 ec2 = new AmazonEC2Client(creds); Letting AWS know who you are Using Java SDK Thursday, August 29, 13
  102. 102. Creating a New Key PairUsing Java SDK CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest(); String keyName = "testKeyPair-fromjava"; createKeyPairRequest.withKeyName(keyName); CreateKeyPairResult createKeyPairResult = ec2.createKeyPair(createKeyPairRequest); KeyPair keyPair = createKeyPairResult.getKeyPair(); File pemFile = new File(keyName + ".pem"); BufferedWriter out = new BufferedWriter(new FileWriter(pemFile)); out.write(keyPair.getKeyMaterial()); out.close(); Thursday, August 29, 13
  103. 103. Creating a Security Group Using the Java SDK CreateSecurityGroupRequest r1 = new CreateSecurityGroupRequest("webserver-group", "Sec Group for My Web Servers"); ec2.createSecurityGroup(r1); AuthorizeSecurityGroupIngressRequest r2 = new AuthorizeSecurityGroupIngressRequest(); r2.setGroupName("webserver-group");  IpPermission permission = new IpPermission();  permission.setIpProtocol("tcp");  permission.setFromPort(80);  permission.setToPort(80);  List ipRanges = new ArrayList();  //use CIDR notation, see http://en.wikipedia.org/wiki/CIDR_notation ipRanges.add("0.0.0.0/0"); permission.setIpRanges(ipRanges);  List permissions = new ArrayList();  permissions.add(permission);  r2.setIpPermissions(permissions);   ec2.authorizeSecurityGroupIngress(r2); Thursday, August 29, 13
  104. 104. Creating the EC2 InstanceUsing the Java SDK // CREATE EC2 INSTANCES RunInstancesRequest runInstancesRequest = new RunInstancesRequest()     .withInstanceType("micro")     .withImageId("ami-4bb96d22")     .withMinCount(1)     .withMaxCount(1)     .withSecurityGroupIds("webserver-group")     .withKeyName("testKeyPair-fromjava"); RunInstancesResult runInstances = ec2.runInstances(runInstancesRequest); Thursday, August 29, 13
  105. 105. Giving the Instance Metadata // TAG EC2 INSTANCES WITH USER METADATA List<Instance> instances = runInstances.getReservation().getInstances(); for (Instance instance : instances) { CreateTagsRequest createTagsRequest = new CreateTagsRequest(); createTagsRequest.withResources(instance.getInstanceId()) .withTags(new Tag("Name", "MyFirstEC2Instance")); ec2.createTags(createTagsRequest); } Thursday, August 29, 13
  106. 106. Stopping/Terminating EC2 Instance TerminateInstancesRequest terminateInstanceRequest = new TerminateInstancesRequest().withInstanceIds(instanceIds); ec2.terminateInstances(terminateInstanceRequest); StopInstancesRequest stopInstanceRequest = new StopInstancesRequest().withInstanceIds(instanceIds); ec2.terminateInstances(stopInstanceRequest); Thursday, August 29, 13
  107. 107. http://puppetlabs.com/ http://www.opscode.com/chef/ Infrastructure Automation AWS CloudFormation http://aws.amazon.com/cloudformation/ Thursday, August 29, 13
  108. 108. Lab 1 1. Start instance of UberConf-2013-JavaWebServer 2. Verify Tomcat is running accessible 3. ssh to JavaWebServer instance 4. Stop JavaWebServer instance 5. Restart JavaWebServer instance Thursday, August 29, 13
  109. 109. Storage Thursday, August 29, 13
  110. 110. • Structured Data • Amazon DynamoDB - NoSQL DB • Relational Databases (in EC2 and EBS) • Amazon RDS - Managed databases like mysql • Amazon ElasticCache - in-memory cache • Amazon Redshift - petabyte-scale data warehouse • Unstructured Data • Amazon EC2 Instance Storage - local filesystem • Amazon EBSVolumes - remote mounted filesystem • Amazon S3 - bucket storage • Amazon Glacier - archiving and backup Storage Options Thursday, August 29, 13
  111. 111. instance EBS Thursday, August 29, 13
  112. 112. Thursday, August 29, 13
  113. 113. S3 Pricing Thursday, August 29, 13
  114. 114. EBS Pricing Thursday, August 29, 13
  115. 115. Database Thursday, August 29, 13
  116. 116. Thursday, August 29, 13
  117. 117. launch here Thursday, August 29, 13
  118. 118. search for codemash select MySqlServer AMI 5.5 Thursday, August 29, 13
  119. 119. Thursday, August 29, 13
  120. 120. nothing to do here Thursday, August 29, 13
  121. 121. nothing to do here Thursday, August 29, 13
  122. 122. name instance with naming convention Thursday, August 29, 13
  123. 123. select existing key pairs Thursday, August 29, 13
  124. 124. developer’s machine web application security group Thursday, August 29, 13
  125. 125. Thursday, August 29, 13
  126. 126. Thursday, August 29, 13
  127. 127. $ ssh -i ~/.ssh/your-key-pair.pem ec2-user@ec2-184-72-144-98.compute-1.amazonaws.com $ mysql -u codemash -pcodemash -e ‘create database nuez’ Thursday, August 29, 13
  128. 128. $ mysql -h ec2-54-243-16-144.compute-1.amazonaws.com -u codemash -p nuez Thursday, August 29, 13
  129. 129. user = codemash password = codemash Thursday, August 29, 13
  130. 130. // environment specific settings environments { development { dataSource { dbCreate = "update" url = "jdbc:h2:mem:devDb;MVCC=TRUE" } } test { dataSource { dbCreate = "update" url = "jdbc:h2:mem:testDb;MVCC=TRUE" } } production { dataSource { driverClassName = "com.mysql.jdbc.Driver" dialect = "org.hibernate.dialect.MySQL5Dialect" username = "codemash" password = "codemash" dbCreate = "update" url = "jdbc:mysql://ec2-184-72-144-98-compute-1.amazonaws.com:3306/nuez" pooled = true properties { maxActive = -1 minEvictableIdleTimeMillis = 1800000 timeBetweenEvictionRunsMillis = 1800000 numTestsPerEvictionRun = 3 testOnBorrow = true testWhileIdle = true testOnReturn = true validationQuery = "SELECT 1" } } } } mysql instance urlusername/password grails-app/conf/DataSource.groovy Thursday, August 29, 13
  131. 131. grails war Thursday, August 29, 13
  132. 132. $ scp -i ~/.ssh/your-key-pair.pem target/nuez-0.1.war ec2-user@ ec2-23-22-9-39.compute-1.amazonaws.com:/usr/share/tomcat7/webapps/nuez.war nuez-0.1.war 100% 27MB 666.3KB/s 00:42 Secure Copy War Thursday, August 29, 13
  133. 133. SCP using Windows Enter ec2-user here Select you ppk file here Enter machine name here Thursday, August 29, 13
  134. 134. Lab 2 1. Start instance of UberConf-2013-MySqlServer 2. Connect with mysql tool or ssh to instance 3. Create nuez database (if not created already) 4. Change nuez application database string 5. Deploy nuez application 6. Test nuez application Thursday, August 29, 13
  135. 135. Load Balancing Thursday, August 29, 13
  136. 136. Thursday, August 29, 13
  137. 137. Launch Launch Similar EC2 Instance Thursday, August 29, 13
  138. 138. Launch Thursday, August 29, 13
  139. 139. Load Balancing Instances Thursday, August 29, 13
  140. 140. Configure Health Check Thursday, August 29, 13
  141. 141. Select EC2 Instances Thursday, August 29, 13
  142. 142. Review Thursday, August 29, 13
  143. 143. Almost done Thursday, August 29, 13
  144. 144. Here is the base url to access the load balancer Getting url to load balancer Thursday, August 29, 13
  145. 145. Lab 3 1. Create/start another instance of UberConf-2013- JavaWebServer 2. Create a new load balancer 3. Add both UberConf-2013-JavaWebServer EC2 instances to load balancer Thursday, August 29, 13
  146. 146. CDN Thursday, August 29, 13
  147. 147. Thursday, August 29, 13
  148. 148. CloudFront Pricing Thursday, August 29, 13
  149. 149. Start by creating a bucket Setting up S3 with CloudFront Thursday, August 29, 13
  150. 150. Logging can also be enabled to tell you more about your S3 usage Click here to name and finish creating your bucket Name S3 Bucket Thursday, August 29, 13
  151. 151. Create S3 directory structure Click here to create a new folder inside your bucket After clicking you will be prompted to enter the name here Thursday, August 29, 13
  152. 152. Create this structure using the same names Create S3 directory structure (continued) Create this structure using the same names Thursday, August 29, 13
  153. 153. Uploading Static Content Upload content destination folder Thursday, August 29, 13
  154. 154. Click here to add files (Multi file selection is possible when browse window opens) Uploading (continued) Thursday, August 29, 13
  155. 155. Select corresponding static files located in the webapp on your machine to be uploaded into S3 Uploading (continued) Thursday, August 29, 13
  156. 156. Finish by pressing “Start Upload” Uploading(Almost done) Thursday, August 29, 13
  157. 157. Make All S3 Files Public Click here to make all files under this directory available to the world Thursday, August 29, 13
  158. 158. Creating a new Cloudfront Start by clicking here or here Thursday, August 29, 13
  159. 159. Selecting CDN Type (download vs. streaming) Thursday, August 29, 13
  160. 160. Setting up S3 as Origin Thursday, August 29, 13
  161. 161. Thursday, August 29, 13
  162. 162. <link rel="shortcut icon" href="${grailsApplication.config.cloudfront.cdn.url} ${resource(dir: 'images', file: 'favicon.ico')}" type="image/x-icon"> Grails Resource Change to Support CDN url Thursday, August 29, 13
  163. 163. environments { development { grails.logging.jul.usebridge = true cloudfront.cdn.url = "" } production { grails.logging.jul.usebridge = false cloudfront.cdn.url = "http://your.cloudfront.net" } } Configure Web App Config.groovy Thursday, August 29, 13
  164. 164. Lab 4 1. Create new S3 bucket 2. Create directory structure in S3 3. Upload all static content to S3 in the appropriate directories 4. Create new CloudFront distribution 5. Update nuez to use CloudFront distribution url 6. Redeploy nuez web app 7. Test Thursday, August 29, 13
  165. 165. Elastic Beanstalk Thursday, August 29, 13
  166. 166. Elastic Beanstalk Select you platform Thursday, August 29, 13
  167. 167. Elastic Beanstalk (Default application) Thursday, August 29, 13
  168. 168. Elastic Beanstalk (Default application) Thursday, August 29, 13
  169. 169. Creating your own application Start here Thursday, August 29, 13
  170. 170. Thursday, August 29, 13
  171. 171. Thursday, August 29, 13
  172. 172. Thursday, August 29, 13
  173. 173. Thursday, August 29, 13
  174. 174. Thursday, August 29, 13
  175. 175. Use these fields to construct connection string for application Thursday, August 29, 13
  176. 176. Update Nuez with RDS Connection // environment specific settings environments { development { dataSource { dbCreate = "update" url = "jdbc:h2:mem:devDb;MVCC=TRUE" } } test { dataSource { dbCreate = "update" url = "jdbc:h2:mem:testDb;MVCC=TRUE" } } production { dataSource { driverClassName = "com.mysql.jdbc.Driver" dialect = "org.hibernate.dialect.MySQL5Dialect" username = "codemash" password = "codemash" dbCreate = "update" url = "jdbc:mysql://aa1w2u6dik6dppm.cdrw92njsm5b.us-west-1.rds.amazonaws.com:3306/ebdb" pooled = true properties { maxActive = -1 minEvictableIdleTimeMillis = 1800000 timeBetweenEvictionRunsMillis = 1800000 numTestsPerEvictionRun = 3 testOnBorrow = true testWhileIdle = true testOnReturn = true validationQuery = "SELECT 1" } } } } rds url Thursday, August 29, 13
  177. 177. Deploy the latest version of nuez Thursday, August 29, 13
  178. 178. Thursday, August 29, 13
  179. 179. Thursday, August 29, 13
  180. 180. Start here to modify server configurations Thursday, August 29, 13
  181. 181. Thursday, August 29, 13
  182. 182. Thursday, August 29, 13
  183. 183. Thursday, August 29, 13
  184. 184. Pricing Thursday, August 29, 13
  185. 185. pay as you use Thursday, August 29, 13
  186. 186. use small EC2 instance for one hour and pay $0.065 Thursday, August 29, 13
  187. 187. On-Demand - pay by hour no long-term commitment Reserved - one-time payment and discounted hourly rate Spot - bid for unused capacity Example: * small instance for one year On-Demand - $569.40 ($0.065/hr) Light Reserved - $410.64 ($0.039/hr + $69) Medium Reserved - $370.24 ($0.024/hr + $160) Heavy Reserved - $335.16 ($0.016/hr + $195) Thursday, August 29, 13
  188. 188. Thursday, August 29, 13
  189. 189. http://aws.amazon.com/calculator Thursday, August 29, 13
  190. 190. Thursday, August 29, 13
  191. 191. Resources Thursday, August 29, 13
  192. 192. Thursday, August 29, 13
  193. 193. Thursday, August 29, 13
  194. 194. http://aws.amazon.com/architecture/ Thursday, August 29, 13
  195. 195. http://aws.amazon.com/architecture/ Thursday, August 29, 13
  196. 196. Thursday, August 29, 13
  197. 197. http://www.infoq.com/presentations/Netflix-in-the-Cloud Thursday, August 29, 13
  198. 198. CTO and Partner email: cjudd@juddsolutions.com web: www.juddsolutions.com blog: juddsolutions.blogspot.com twitter: javajudd Christopher M. Judd Thursday, August 29, 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×