Skip to content

1.如何选择实例类型和购买选项

实例类型

  • 通用实例
  • 计算优化型实例
  • 内存优化型实例
  • 存储优化型实例
  • 加速计算实例

更多详情请查看官方文档https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/instance-types.html


实例购买选择

  • 按需实例(On-Demand Instances ) 按秒为启动的实例付费。
  • 预留实例 (Reserved Instances)以大幅折扣购买一年期到三年期的始终可用的实例。
  • 计划实例 (Scheduled Instances)以一年为期限购买按指定重复计划始终可用的实例。
  • Spot 实例 (Spot Instances)请求未使用的 EC2 实例,这可能会显著降低您的 Amazon EC2 成本。
  • 专用主机 (Dedicated Hosts)为完全专用于运行您的实例的物理主机付费,让您现有的按插槽、按内核或按 VM 计费的软件许可证降低成本。
  • 专用实例 (Dedicated Instances)为在单一租户硬件上运行的实例按小时付费。
  • 容量预留 (Capacity Reservations)可在特定可用区中为 EC2 实例预留容量,持续时间不限。

2. 查看实例

2.1 通过web界面

2.2 EC2 终端命令

bash
[root@saas ~]# ec2-metadata --help
ec2-metadata v0.1.2
Use to retrieve EC2 instance metadata from within a running EC2 instance. 
e.g. to retrieve instance id: ec2-metadata -i
		 to retrieve ami id: ec2-metadata -a
		 to get help: ec2-metadata --help
For more information on Amazon EC2 instance meta-data, refer to the documentation at
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

Usage: ec2-metadata <option>
Options:
--all                     Show all metadata information for this host (also default).
-a/--ami-id               The AMI ID used to launch this instance
-l/--ami-launch-index     The index of this instance in the reservation (per AMI).
-m/--ami-manifest-path    The manifest path of the AMI with which the instance was launched.
-n/--ancestor-ami-ids     The AMI IDs of any instances that were rebundled to create this AMI.
-b/--block-device-mapping Defines native device names to use when exposing virtual devices.
-i/--instance-id          The ID of this instance
-t/--instance-type        The type of instance to launch. For more information, see Instance Types.
-h/--local-hostname       The local hostname of the instance.
-o/--local-ipv4           Public IP address if launched with direct addressing; private IP address if launched with public addressing.
-k/--kernel-id            The ID of the kernel launched with this instance, if applicable.
-z/--availability-zone    The availability zone in which the instance launched. Same as placement
-c/--product-codes        Product codes associated with this instance.
-p/--public-hostname      The public hostname of the instance.
-v/--public-ipv4          NATted public IP Address
-u/--public-keys          Public keys. Only available if supplied at instance launch time
-r/--ramdisk-id           The ID of the RAM disk launched with this instance, if applicable.
-e/--reservation-id       ID of the reservation.
-s/--security-groups      Names of the security groups the instance is launched in. Only available if supplied at instance launch time
-d/--user-data            User-supplied data.Only available if supplied at instance launch time.

[root@saas ~]# ec2-metadata -t
instance-type: c6i.xlarge
[root@saas ~]# ec2-metadata --help
ec2-metadata v0.1.2
Use to retrieve EC2 instance metadata from within a running EC2 instance. 
e.g. to retrieve instance id: ec2-metadata -i
		 to retrieve ami id: ec2-metadata -a
		 to get help: ec2-metadata --help
For more information on Amazon EC2 instance meta-data, refer to the documentation at
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

Usage: ec2-metadata <option>
Options:
--all                     Show all metadata information for this host (also default).
-a/--ami-id               The AMI ID used to launch this instance
-l/--ami-launch-index     The index of this instance in the reservation (per AMI).
-m/--ami-manifest-path    The manifest path of the AMI with which the instance was launched.
-n/--ancestor-ami-ids     The AMI IDs of any instances that were rebundled to create this AMI.
-b/--block-device-mapping Defines native device names to use when exposing virtual devices.
-i/--instance-id          The ID of this instance
-t/--instance-type        The type of instance to launch. For more information, see Instance Types.
-h/--local-hostname       The local hostname of the instance.
-o/--local-ipv4           Public IP address if launched with direct addressing; private IP address if launched with public addressing.
-k/--kernel-id            The ID of the kernel launched with this instance, if applicable.
-z/--availability-zone    The availability zone in which the instance launched. Same as placement
-c/--product-codes        Product codes associated with this instance.
-p/--public-hostname      The public hostname of the instance.
-v/--public-ipv4          NATted public IP Address
-u/--public-keys          Public keys. Only available if supplied at instance launch time
-r/--ramdisk-id           The ID of the RAM disk launched with this instance, if applicable.
-e/--reservation-id       ID of the reservation.
-s/--security-groups      Names of the security groups the instance is launched in. Only available if supplied at instance launch time
-d/--user-data            User-supplied data.Only available if supplied at instance launch time.

[root@saas ~]# ec2-metadata -t
instance-type: c6i.xlarge

2.3 AWS CLI 查看

需要配置key

bash
aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,InstanceType]" --output table
aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,InstanceType]" --output table