Elizabeth
Engineer
Engineer
  • UID625
  • Fans5
  • Follows1
  • Posts68
Reads:38792Replies:1

[Share]Advanced Commands

Created#
More Posted time:Jul 21, 2016 9:43 AM
Advanced Commands
ECS Advanced Commands
Instance Export Function

For ECS products, Alicloudcli supports exporting instances to files, which is an extended function of the tool. You can choose an instance ID to export the corresponding instance to a file. Specific sample commands are as follows:

$ alicloud ecs ExportInstance --InstanceId XXXXX --filename test

--InstanceId : This is a required parameter, indicating the ID of the ECS instance to be exported

--filename : This is a required parameter, indicating the file to which the instance is to be exported. It can be an absolute path or a single filename. If it is a single filename, the default path ~/.alicloudcli/ will be chosen.

The exported file content is in the json format, which is convenient for you to view or use in programming. Meanwhile, it is also an import template file. You can undertake personalized modifications on this template file, and then import the file to create multiple ECS instances.
Instance Import Function

For ECS products, Alicloudcli supports instance creation via file import to easily create multiple identical instances. You can create multiple identical instances simply by specifying a template file and calling a command. Note: By default, no public IP address is allocated during instance import. If you need a public IP address, you need to include the --allocatepublicip parameter

Example:

$ alicloud ecs ImportInstance --filename test --instancecount 5 --allocatepublicip yes

--filename : Template file, which can be a filename or an absolute path. If it is a single filename, the system will search the file under the~/.alicloudcli/ path.

--instancecount : Number of instances to be created. This parameter is followed by a number. If this number is illegal, one instance is created by default

--allocatepublicip : Specifies whether to allocate a public IP address to the created instances. Only when this parameter is set to "yes", can a public IP address be applied during instance import. No public IP address is applied if this parameter is not included or is set to a value other than "yes", and in this case, only intranet IP addresses are available for the created instances.

Template file: We strongly recommend that you use the file exported with the alicloudcli ecs ExportInstance command as a template to edit. Do not create templates. Thus to avoid mistakes.
Special note:

It must be declared that the instances created through ECS open APIs can only be charged on the Pay-As-You-Go basis currently, not in the subscription way (which will be supported in later versions). Therefore, your template file will be created as Pay-As-You-Go instances (Postpaid). Please pay special attention to this point. When an instance is exported, the value of the parameter InternetMaxBandwidthIn may be -1

Please check in the exported file whether the value of the exported InternetMaxBandwidthIn is -1. If yes, change it to a number between [1-200].
RDS Advanced Commands
Instance Export Function

For RDS products, Alicloudcli supports exporting DB instances to files, which is an extended function of the tool. You can choose an instance ID to export the corresponding instance to a file.

Specific sample commands are as follows:

$ alicloud rds ExportDBInstance --DBInstanceId XXXXX --filename test

--DBInstanceId : This is a required parameter, indicating the ID of the instance to be exported

--filename : This is a required parameter, indicating the file to which the instance is to be exported. It can be an absolute path or a single filename. If it is a single filename, the default path ~/.alicloudcli/ will be chosen.

The exported file content is in the json format, which is convenient for you to view or use in programming. Meanwhile, it is also an import template file. You can undertake personalized modifications according to the file, and then import the file to create multiple DB instances.
Instance Import Function

For RDS products, Alicloudcli supports instance creation via file import to easily create multiple identical DB instances. You can create multiple identical instances simply by specifying a template file and calling a command.

Example:

$ alicloud rds ImportDBInstance --filename test --count 5

--filename : Template file, which can be a filename or an absolute path. If it is a single filename, the system will search the file under the~/.alicloudcli/ path.

--count : Number of DB instances to be created. This parameter is followed by a number. If this number is illegal, one DB instance is created by default. We strongly recommend that you use the file exported with the alicloudcli rds ExportDBInstance command as a template to edit. Do not create templates. Thus to avoid mistakes.
Special note:

It must be declared that DB instances created through RDS open APIs can only be charged on the Pay-As-You-Go basis currently, not in the subscription way (which will be supported in later versions). Therefore, your template file will be created as Pay-As-You-Go instances (Postpaid). Please pay special attention to this point.

Instructions on Complex Commands The following are examples of complex commands for certain products, which can be used as a reference
SLB products
Example of the AddBackendServers command

$ alicloud slb AddBackendServers --LoadBalancerId 14fd07a7569-cn-ningxia-am7-c01 --BackendServers "[{'ServerId':'i-21os1d7jr'},{'ServerId':'i-21h2knaxy'}]"

Note: The parameter forms following BackendServers should be noted
Example of the RemoveBackendServers command

$ alicloud slb RemoveBackendServers  --LoadBalancerId 14ffe8a7a47-cn-hangzhou-dg-a01  --BackendServers "['i-23glad1uz','i-236tbrnzn']"

Note: The parametric form of BackendServers should be noted
RDS products
Example of the DescribeSlowLogs command

$ alicloud rds DescribeSlowLogs --DBInstanceId xxxxx --StartTime 2015-09-24Z --EndTime 2015-09-24Z --DBName hms --PageSize 30 --PageNumber 1

Note: The incorrect time format cannot be identified. The --PageSize parameter is used to specify the number of data items displayed on each page, and only several fixed values are allowed.
The DescribeMetricDatum Command for CMS products

$ alicloud cms DescribeMetricDatum  --MetricName MySQL_CpuUsage --StartTime 2015-10-08T00:00:00Z --EndTime 2015-10-08T00:01:00Z --Dimensions "{instanceId:'rds2izeze2izeze'}"  --Period 5m --NextToken 1 --Length 100

Note:

CMS has only one action. All parameter obtaining is determined according to the incoming parameters such as --Dimensions "{instanceId:'rds2izeze2izeze'}", and the incoming time is GTM time

The above command returns both CPU and memory information. When a certain information item is needed, you can use the --Dimensions "{instanceId:'rds445qv67ce32y4v1gi', type:'cpuusage'}" parameter to filter.
Multiple profile usage

To use the corresponding configuration of profile, you only need to include the —profile XXX parameter, for example:

$ alicloud  ecs  DescribeInstanceStatus

In this case, the default configuration is used, which is also the global configuration;

$ alicloud  ecs  DescribeInstanceStatus –-profile tes

In this case, the configuration under test is used, which takes effect for one time.

KhurramRahim
Assistant Engineer
Assistant Engineer
  • UID10426
  • Fans0
  • Follows0
  • Posts71
1st Reply#
Posted time:Feb 23, 2021 21:10 PM
greate article
Guest