Registers a database instance with Data Management (DMS).
Prerequisites:
You are a DMS administrator or a database administrator (DBA). You can call the ListUsers or GetUser operation to obtain your user role from the RoleIdList parameter that is returned.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | RegisterInstance |
The operation that you want to perform. Set the value to RegisterInstance. |
Tid | Long | Yes | 3*** |
The ID of the tenant. You can call the GetUserActiveTenant operation to obtain the tenant ID. |
InstanceType | String | Yes | MySQL |
The type of the database. For more information about the valid values of this parameter, see DbType parameter. |
InstanceSource | String | Yes | RDS |
The source of the database instance. Valid values:
|
NetworkType | String | Yes | VPC |
The network type of the database instance. Valid values:
|
EnvType | String | Yes | product |
The type of the environment to which the database instance belongs. Valid values:
|
EcsInstanceId | String | No | i-2zei9gs1t7h8l7ac**** |
The ID of the ECS instance. Note This parameter is required if the InstanceSource parameter is set to ECS_OWN.
|
VpcId | String | No | vpc-xxxxxxxxxxxxxxxxxxxxx |
The ID of the VPC. Note This parameter is required if the InstanceSource parameter is set to VPC_IDC.
|
EcsRegion | String | No | cn-hangzhou |
The ID of the region in which the database instance resides. Note This parameter is required if the InstanceSource parameter is set to RDS, ECS_OWN,
or VPC_IDC.
|
Host | String | Yes | 172.XX.XXX.254 |
The host address that is used to connect to the database instance. |
Port | Integer | Yes | 3306 |
The port number that is used to connect to the database instance. |
Sid | String | No | XXX |
The system ID (SID) of the database. Note This parameter is required if the InstanceType parameter is set to ORACLE.
|
DatabaseUser | String | Yes | dmstest |
The account that is used to log on to the database. |
DatabasePassword | String | Yes | ****** |
The password that is used to log on to the database. |
InstanceAlias | String | Yes | Test instance |
The alias of the database instance. Specify an alias that can help you identify the database instance in DMS. |
DbaUid | Long | Yes | 22275482072787**** |
The ID of the user who assumes the DBA role of the database instance. You can call the ListUsers or GetInstance operation to obtain the user ID. |
SafeRule | String | Yes | Test |
The name of the security rule set for the database. You can call the ListStandardGroups or GetInstance operation to obtain the name of the security rule set that you want to use. |
QueryTimeout | Integer | Yes | 60 |
The timeout period for querying data in the database instance. Unit: seconds. |
ExportTimeout | Integer | Yes | 600 |
The timeout period for exporting data from the database instance. Unit: seconds. |
DataLinkName | String | No | dblink_test |
The name of the data link for cross-database query. Note
|
DdlOnline | Integer | No | 2 |
Specifies whether to enable the lock-free schema change feature for the database instance. Valid values:
Note Supported database types: ApsaraDB RDS for MySQL, PolarDB for MySQL, ApsaraDB MyBase
for MySQL, and MySQL databases from other sources.
|
UseDsql | Integer | No | 1 |
Specifies whether to enable the cross-database query feature for the database instance. Valid values:
Note Supported database types: MySQL, SQL Server, PostgreSQL, PolarDB for Oracle, and ApsaraDB
for Redis.
|
SkipTest | Boolean | No | true |
Specifies whether to skip connectivity test. Valid values:
|
RegionId | String | No | cn-hangzhou |
The ID of the region in which DMS is activated. For more information about the valid values of this parameter, see RegionID parameter. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | F4E2A94B-604F-43FF-93E7-F4EE3DCF412E |
The ID of the request. |
ErrorCode | String | 404 |
The error code that is returned. |
ErrorMessage | String | The specified instance already exists. |
The error message that is returned. |
Success | Boolean | true |
Indicates whether the request was successful. Valid values:
|
Examples
Sample request
http(s)://[Endpoint]/?Action=RegisterInstance
&Tid=3***
&InstanceType=MySQL
&InstanceSource=RDS
&NetworkType=VPC
&EnvType=product
&EcsInstanceId=i-2zei9gs1t7h8l7ac****
&VpcId=vpc-xxxxxxxxxxxxxxxxxxxxx
&EcsRegion=cn-hangzhou
&Host=172.XX.XXX.254
&Port=3306
&Sid=XXX
&DatabaseUser=dmstest
&DatabasePassword=******
&InstanceAlias=Test instance
&DbaUid=22275482072787****
&SafeRule=Test
&QueryTimeout=60
&ExportTimeout=600
&DataLinkName=dblink_test
&DdlOnline=2
&UseDsql=1
&SkipTest=true
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<RegisterInstanceResponse>
<RequestId>F4E2A94B-604F-43FF-93E7-F4EE3DCF412E</RequestId>
<ErrorCode>404</ErrorCode>
<ErrorMessage>The specified instance already exists.</ErrorMessage>
<Success>true</Success>
</RegisterInstanceResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "F4E2A94B-604F-43FF-93E7-F4EE3DCF412E",
"ErrorCode" : "404",
"ErrorMessage" : "The specified instance already exists.",
"Success" : true
}
Error codes
For a list of error codes, visit the API Error Center.
Sample code by using the SDK for Python
The following sample code provides an example on how to register a database instance that is deployed in a data center connected over a VPC with DMS.
#coding=utf-8
from aliyunsdkcore.client import AcsClient
from aliyunsdkdms_enterprise.request.v20181101.RegisterInstanceRequest import RegisterInstanceRequest
client = AcsClient(
"<your-access-key-id>",
"<your-access-key-secret>",
"<your-region-id>"
)
# Example
request = RegisterInstanceRequest()
# The ID of the tenant.
request.set_Tid(1)
# The host address that is used to connect to the database instance.
request.set_Host("192.168.16.113")
# The port number that is used to connect to the database instance.
request.set_Port(3314)
# The type of the database. In this example, the parameter is set to MySQL.
request.set_InstanceType("MySQL")
# The source of the database instance. In this example, the parameter is set to VPC_IDC.
request.set_InstanceSource("VPC_IDC")
# The network type of the database instance. In this example, the parameter is set to VPC.
request.set_NetworkType("VPC")
request.set_EnvType("PRODUCT")
# request.set_EcsInstanceId()
# The ID of the VPC in which the database instance is deployed.
request.set_VpcId("VPC ID of the database instance")
# The ID of the region in which the database instance resides. Example: cn-hangzhou.
request.set_EcsRegion("Region ID of the database instance")
# request.set_Sid();
# The account that is used to log on to the database.
request.set_DatabaseUser("Logon account of the database")
# The password that is used to log on to the database.
request.set_DatabasePassword("Logon password of the database")
# The alias of the database instance. Specify an alias that can help you identify the database instance in DMS.
request.set_InstanceAlias("Alias of the database instance")
# The ID of the user who assumes the DBA role of the instance. The user must be added to DMS Enterprise by using the console or the relevant API operation in advance.
request.set_DbaUid(-1)
request.set_SafeRule("Name of the security rule set that is configured in DMS Enterprise")
request.set_QueryTimeout(60)
request.set_ExportTimeout(600)
response = client.do_action_with_exception(request)
print response