AWS - EC2学习笔记

Instance Type

Instance type control the virtual hardware dedicated to the instance when it is launched.
Instance types are varying in the following dimensions:

  • Virtual CPUs(vCUPs)
  • Memory
  • Storage(size and type)
  • Network Performance

Instance types are grouped into families based on the ration of these values to each other.
For example:

Family Description
C4 Compute Optimized
R3 Memory Optimized
I2 Storiage Optimized
G2 GPU-based instances Intended for graphics and general-purpose GPU workload compute

many instance types support enhanced networking, such as M4,C4,C3,D2,I2 and R3 families,enhanced networking is only available for instances launched in Amazon VPC(Amazon Virtual Private Cloud).

AMI(Amazon Machine Image)

The AMI defines the initial software that will be on an instance when it is launched. An AMI defines every aspect of the software state at instance launch, including:

  • The OS(Operating System) and its configuration.
  • The initial state of any patched.
  • Application or System software.
    All AMIs are based on x86 OSs, either linux or Windows.

Four sources of AMI

  • Published by AWS
  • The AWS marketplace
  • Generated from Existing instances
  • Uploaded Virtual Servers
    It is incumbent on customers to remain compliant with the licensing terms of there OS vendors.

Addressing an Instances

There are several ways that an instance may be addressed over the web upon creation:

  • Public DNS name
    Then the instance is launched, AWS creates a DNS name that can be used to access the instance. This DNS name is created automatically and cannot be specified by the customer. The DNS name persists only while the instance is running and cannot be transfered to another instance.
  • Public IP
    The instance may have an Public IP which is assigned from the address reserved by AWS and cannot be specified. This IP address is unique on the internet, persist only while the instance is running and cannot be transferred to another instance.
  • Elastic IP
    The customer reserved the IP which is unique on the internet. The IP address persist until the customer released it and it can be transferred to another instance.
  • Private IP and Elastic Network Interface in VPC

Virtual Firewall Protection

AWS can control the traffic in and out of your instance through virtual firewall called Security Group. Every instance must have at least one security group but can have more.

Type of Security Group

Type of Security Group Capabilities
EC2 - Classic Security Group Control outgoing instance traffic
VPC Security Group Control outgoing and incoming instance traffic

Security Group Rule Attributes

Attribute Meaning
Port The Port Number affected by the rule
Protocol The communication Standard for the traffic affected by the rule
Source/Destination Identified the other end of the communication, the Source for incoming traffic rule, or the Destination for outgoing traffic rule. The can be defined in two ways: CIDR block(x.x.x.x/x IP range) or Security Group( Includes any instance that is associated with the given Security Group.

Launching Instance

There are several additional services that are useful when launching new EC2 instances.

  • Bootstrapping
    The process of providing code to be run on an instance at launch is called bootstrapping.
    One of the parameters when an instance is launched is a string value called UserData.
  • VM import/export
    VM import/ enables you to easily import VMs from your existing environments and export them back to your on-premise environment. You can only export previously imported Amazon EC2 instances. Instances launched within AWS from AMIs cannot be exported.
  • Instance Metadata
    Instance metadata is data about your instance that you can use to
    configure or manage the running instance. This is unique in that it is a mechanism to obtain
    AWS properties of the instance from within the OS without making a call to the AWS API

Managing Instance

Tags are key/value pair associated with instance or other service. It can be used to identify attributes of the instance. You can apply up to 10 Tags per instance.

Monitoring Instance

Amazon CloudWatch provides monitoring and alerting for EC2 instances.

Modifying an Instance

  • Instance Type
    Set the instance state to Stop
    Choose the “Change Instance Type” in the tools of your choice.
    Select the desired Instance Type.
    Restart the instance.
  • Security Group
    If the instance is running in an Amazon VPC, you can change which Security Groups are associated with an instance while the instance is running. For instance out of an Amazon VPC(called EC2-Classic), the association of the security group cannot be changed after launch.

Termination Protection

When an EC2 instance is no longer needed, its state can be set to Terminated and the instance will be shutdown and removed from AWS infrastructure. In order to prevent termination, Termination Protection can be enabled. This helps to prevent accidental termination through human error.
Note that this just protects from termination from the AWS Management Console, CLI or API.
It does not prevent termination trigger by OS shutdown command, termination from an Auto Scaling Group or Termination of a Spot Instance due to Price Changes.

Pricing Options

  • On-Demand Instances
  • Reserved Instances
    You can modify your whole reservation, or just a subset, in one or more of the following ways:
    Switch Availability Zones within the same region.
    Change between EC2-VPC and EC2-Classic.
    Change the instance type within the same instance family (Linux instances only).
  • Spot Instances
    The instances will run until:
    The customer terminates them.
    The Spot price goes above the customer’s bid price.
    There is not enough unused capacity to meet the demand for Spot Instances.
    Because of the possibility of interrupting, Spot Instances should only be used for workloads tolerant of interruption. This could includes analytics, financial modeling, big data,media encoding, scientific computing and testing.

Tenancy Options

  • Shared Tenancy
    A single Host machine may house instances from different customers.
  • Dedicated Instances
    Dedicated Instances run on hardware dedicated to a single customer.
  • Dedicated Host
    A physical server with EC2 instance capacity is fully dedicated to a single customer. The customer has complete control over which specific host runs on instance at launch. It differs from Dedicated Instances in that a Dedicated Instance can launch on any hardware that has been dedicated to a customer account

Placement Group

A placement group is a logical group of instances within a single AZ(Available Zone). Placement Group enables applications to participate in a low-latency, 10 Gps network.

Instance Store

An instance store(ephemeral storage) provides temporary block-level for your instance. Instance stores are included in the cost of an Amazon EC2 instance, the key aspect of instance stores is that they are temporary. Data in the instance store is lost when:

  • The underlying disk drive fails.
  • The instance stop(the data will persist if an instance reboot).
  • The instance terminates.

你可能感兴趣的:(AWS - EC2学习笔记)