google compute engine chien-chung shen [email protected]
TRANSCRIPT
Google Compute Engine
Chien-Chung [email protected]
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
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
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
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>
Authentication & Set Project ID
• Authenticate gcloud $ gcloud auth login
• Set default project ID $ gcloud config set project <PROJECT>
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
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
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
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
Browse Home Page
• Get external IP address$ gcloud compute instances list
• On a browser, type http://<IP-address>
Clean Up
• To delete VM instance and accompanying root persistent disk
$ gcloud compute instances delete my-first-instance --zone us-central1-a
Hadoop on Google Cloud Platform