google compute engine chien-chung shen [email protected]

13
Google Compute Engine Chien-Chung Shen [email protected]

Upload: rolf-morton

Post on 21-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Google Compute Engine

Chien-Chung [email protected]

Page 2: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Overall of GCE (1)• Create virtual machines (VM) with a variety of

configurations – Launch a standard boot image based on Debian, Windows, or

other standard images. – Create a 64 bit x86 Linux-based virtual machine (VM) instance. Google

Compute Engine offers a variety of machine types that you can choose from for your instances

• Maintain and store data in block storage – From a VM image, mount persistent block storage (persistent disk) that

maintains state beyond the life cycle of the VM instance

• Manage network access to your virtual machines– Use your VMs alone or connected together to form a compute cluster – Connect your machines to the Internet with a flexible networking

solution that offers static and ephemeral IPv4 addresses– Use the built-in load balancing service to distribute heavy workloads

across many virtual machines– Automatically scale your virtual machines in times of heavy or low

traffic; use firewall to set up network access to your instances

Page 3: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Overall of GCE (2)• Use a variety of tools and OAuth 2.0 authentication to

manage VMs – OAuth - an open standard for authorization

https://cloud.google.com/compute/docs/https://cloud.google.com/compute/docs/quickstart

Page 4: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Command-line Quickstart

• Install and use the command-line gcloud tool• Start a virtual machine (VM) on Google’s infrastructure• Configure a firewall to allow traffic to and from the Internet• Install an Apache web server to serve web pages• Delete VM and resources after you're done with them

Prerequisite and setup• Have a Google account• Have a Developers Console project

– Go to Developers Console; select an existing project or create a new project; visit the APIs page

– On the APIs page, look for Google Compute Engine in APIs list; Enable API

– Follow the prompts to set up billing– Download and install the gcloud command-line tool

Page 5: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Installing Cloud SDK

$ curl https://sdk.cloud.google.com | bashORDownload google-cloud-sdk.zip$ unzip google-cloud-sdk.zip$ ./google-cloud-sdk/install.sh

Restart “terminal” to allow changes to your PATH to take affectOR$ source ~/.<bash-profile-file>

Page 6: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Authentication & Set Project ID

• Authenticate gcloud $ gcloud auth login

• Set default project ID $ gcloud config set project <PROJECT>

Page 7: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Create an Instance• A virtual machine (VM) instance runs on the Compute Engine

infrastructure and functions like a regular computer, except that the physical machine runs in a Google datacenter

• When creating an instance, Compute Engine automatically creates a root persistent disk, which stores the root filesystem and OS image that the instance needs to boot

• Create and start instance$ gcloud compute instances create my-first-instance --image debian-7 --zone us-central1-a

• Get external IP address of the instance$ gcloud compute instances list

Page 8: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Add Firewall Rules• To install Apache and serve web pages, create a firewall

rule that permits incoming HTTP traffic on port 80, which by default is closed

• To create a new firewall rule named "allow-http" that allows traffic on port 80

$ gcloud compute firewall-rules create allow-http \ --description "Incoming http allowed." --allow tcp:80• To get more information about the firewall rule, use the

firewall-rules describe command and specify the name of the rule

$ gcloud compute firewall-rules describe allow-http• List firewall rules$ gcloud compute firewall-rules list

Page 9: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Log in to VM Instance$ gcloud compute ssh my-first-instance --zone us-central1-a

• At the command prompt in the instance home directory• Once you have logged in, you can do anything you could do on any

other standard Linux machine, including installing applications• You have root permissions on your instance and full control over

everything• Type exit to logout

Page 10: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Setup Apache Web Server• Install Apache HTTP Server$ sudo apt-get update$ sudo apt-get install apache2

• Create a new home page– Change the default webpage /www/var/index.html

$ echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>' | sudo tee /var/www/index.html

Page 11: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Browse Home Page

• Get external IP address$ gcloud compute instances list

• On a browser, type http://<IP-address>

Page 12: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Clean Up

• To delete VM instance and accompanying root persistent disk

$ gcloud compute instances delete my-first-instance --zone us-central1-a

Page 13: Google Compute Engine Chien-Chung Shen cshen@udel.edu

Hadoop on Google Cloud Platform