You need to enable JavaScript to run this app.
导航

查看实例元数据

最近更新时间2024.03.20 16:02:56

首次发布时间2022.07.01 09:19:39

实例元数据包含了云服务器在云平台的基本信息,本文介绍如何查看实例元数据。

使用须知

实例元数据只能从实例内部访问,数据并未被加密保护,可访问实例的人员均可查看其元数据。如果元数据中包含了敏感信息,您应当采取适当的措施来保护敏感数据,比如限制访问范围、加密等。

操作步骤

访问实例元数据的格式为http://100.96.0.96/latest/[metadata],请将其中的[metadata]替换为具体需要查询的实例元数据项,可参考实例元数据项

本文以查看实例ID为例,为您介绍如何查看实例元数据,更多示例请参见查看元数据示例

  1. 登录实例
  2. 执行如下命令查看实例ID。
    • Linux
      curl http://100.96.0.96/latest/instance_id
      
    • Windows(PowerShell)
      Invoke-RestMethod http://100.96.0.96/latest/instance_id
      

查看元数据示例

Linux

  • 查看实例元数据的根目录:
    curl http://100.96.0.96/latest
    
  • 查看网卡主私有IP地址:
    curl http://100.96.0.96/latest/network/interfaces/macs/$mac/primary_ip_address   
    
  • 查看实例计费类型:
    curl http://100.96.0.96/latest/payment/charge_type
    

Windows

  • 查看实例元数据的根目录:
    Invoke-RestMethod http://100.96.0.96/latest
    
  • 查看网卡主私有IP地址:
    Invoke-RestMethod http://100.96.0.96/latest/network/interfaces/macs/$mac/primary_ip_address
    
  • 查看实例计费类型:
    Invoke-RestMethod http://100.96.0.96/latest/payment/charge_type
    

实例元数据项

说明

  • 下表中的[mac][volume_id]需替换为实例真实的MAC地址、磁盘ID。
  • 忽略大小写。
  • 支持":"、"-"、"/"。
元数据项
说明
示例
mac实例的MAC地址。00:16:3e:53:xx:xx
hostname实例的主机名。iv-ybo19qc2zqijuuub****
uuid实例的唯一标识符。8508262e-df5a-11ec-9ec1-0c42a14c****
instance_id实例ID。i-ybo19qc2zqijuuub****
instance_type_id实例规格。ecs.g1.large
image_id启动实例时所用的镜像ID。image-4ay4awvwifaqrvqd****
region_id实例所在地域ID。cn-beijing
availability_zone实例所在可用区。cn-beijing_a
network/interfaces/macs/[mac]/primary_ip_address网卡主私网IP地址。172.XX.XX.127
network/interfaces/macs/[mac]/eip_address实例绑定的公网IP地址列表。10.XX.XX.1
network/interfaces/macs/[mac]/vpc_id实例所属私有网络ID。vpc-mini07ggfxmo5smt1b5f****
network/interfaces/macs/[mac]/subnet_id实例所属子网ID。subnet-13g3mh3hjglj43n6nu5if****
network/interfaces/macs/[mac]/private_ip_addresses网卡分配的私网IPv4地址列表。172.XX.XX.127
network/interfaces/macs/[mac]/subnet_cidr_block网卡对应的子网掩码。172.XX.XX.0/24
network/interfaces/macs/[mac]/gateway网卡对应的IPv4网关地址。172.XX.XX.1
network/interfaces/macs/[mac]/interface_type网卡属性。
  • primary:主网卡
  • secondary:辅助网卡
  • payment/charge_type实例计费类型。
  • PostPaid:按量付费
  • PrePaid:包年包月
  • payment/created_at实例创建时间。2022-4-30 13:39:12
    payment/expired_at包年包月实例到期时间。2022-5-30 13:39:12
    network/interfaces/macs/[mac]/security_group_ids实例绑定的安全组ID。sg-mini0ddjs3k05smt1b6n****
    network/interfaces/macs/[mac]/security_group_names实例绑定的安全组名称。default
    block_devices磁盘ID列表。vol-3tf33o3o254bwbhd****

    block_devices/[volume_id]/device_type

    根据磁盘ID查询磁盘类型,包含云盘和本地盘。

    • 云盘类型,取值:
      • ESSD_PL0:极速型SSD PL0
      • ESSD_FlexPL:极速型SSD FlexPL
    • 本地盘类型,取值:
      • LOCAL_SSD:SSD本地盘
      • LOCAL_HDD:HDD本地盘
    iam/security_credentials实例IAM角色列表。ServiceRoleForECS
    spot_instance_termination_time抢占式实例中断时间。2023-02-23T17:35:00Z
    instance_network_bandwith_baseline网络基准带宽能力(出+入),单位:Mbps。2560
    instance_network_bandwith_maximum网络峰值带宽能力(出+入),单位:Mbps。12288
    instance_network_throughput_maximum网络收发包能力(出+入),单位:Kpps。150