All Products
Search
Document Center

Elastic Compute Service:Manage servers that are not provided by Alibaba Cloud

Last Updated:Dec 26, 2023

This topic describes how to register a server that is not provided by Alibaba Cloud as an Alibaba Cloud managed instance. After a server is registered as a managed instance, the server can use various online services provided by Alibaba Cloud such as Cloud Assistant, CloudOps Orchestration Service, and Alibaba Cloud DevOps.

Prerequisites

  • The server runs an operating system of one of the following versions:

    • Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3 and later

    • CentOS 6, CentOS 7, and CentOS 8 and later

    • CoreOS

    • Debian 8, Debian 9, and Debian 10 and later

    • OpenSUSE

    • RedHat 5, RedHat 6, and RedHat 7 and later

    • SUSE Linux Enterprise Server (SLES) 11, SLES 12, and SLES 15 and later

    • Ubuntu 12, Ubuntu 14, Ubuntu 16, and Ubuntu 18 and later

    • Windows Server 2012, Windows Server 2016, and Windows Server 2019 and later

  • The server can access the Internet.

  • You can have up to 5,000 activation codes per Alibaba Cloud region. When the number of activation codes exceeds 1,000, the usage of the activation codes must be greater than 50% before you can proceed to create more activation codes.

    Note

    You can go to the Cloud Assistant page in Elastic Compute Service (ECS) console and click Register Instance on the Manage Instances tab to view the usage of activation codes.

Preparations

We recommend that you select the region where the network is connected at the fastest speed.

The managed instance feature is supported in the following regions: China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Hangzhou), China (Shanghai), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Hong Kong), Singapore, Japan (Tokyo), US (Silicon Valley), and US (Virginia).

Note

The managed instance feature is provided by Alibaba Cloud free of charge.

You can run the Ping command to test the connection speed and then select the region where your server is connected at the fastest speed.

  • Run the following command to test the connection between the server and ECS in the China (Beijing) region:

    ping -c 4 cn-beijing.axt.aliyuncs.com
  • Run the following command to test the connection between the server and ECS in the China (Hangzhou) region:

    ping -c 4 cn-hangzhou.axt.aliyuncs.com
  • Run the following command to test the connection between the server and ECS in the China (Shanghai) region:

    ping -c 4 cn-shanghai.axt.aliyuncs.com

Procedure

Step 1: Create an activation code for managed instances

This section describes how to create an activation code for managed instances in the ECS console and generate an installation script.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Maintenance & Monitoring > Cloud Assistant.

  3. In the upper-left corner of the top navigation bar, select a region. 地域

  4. On the Cloud Assistant page, click the Manage Instances tab.

  5. Open the Create Registration Code panel.

    • If no managed instances exist in the region, click Create Registration Code. Create an activation code

    • If managed instances exist in the region, perform the following operations:

      1. Click Register Instance. Registered instances

      2. In the Register Instance panel, click Create Registration Code.

  6. In the Create Registration Code panel, configure the parameters described in the following table.

    Parameter

    Description

    Instance Name Prefix

    The prefix of the names of instances that you want to use for subsequent management.

    Source IP Address

    The IP addresses or CIDR blocks of managed instances.

    • If you enter the public IP addresses or CIDR blocks, only the servers whose IP addresses are within the specified IP address range can be managed.

    • If you do not specify this parameter, all servers can be registered as managed instances.

    Instance Quota

    The number of managed instances.

    Valid values: 1 to 1000. Default value: 10.

    Validity Period

    The validity period of the activation code. If the activation code is not used during its validity period, the code becomes invalid when the validity period ends and you must create another one.

    Valid values: 1 to 24. Default value: 4. Unit: hours.

    Description

    The description of the activation code. You can enter information such as the purpose of the code for subsequent management.

    Tag

    The tag that you want to add to the activation code for subsequent classification and management. Tag Key: the key of the tag. Tag Value: the value of the tag.

    Important

    After you specify Tag Key and Tag Value to add a tag to an activation code, the tag is automatically added to the managed instances that are registered with the activation code.

  7. Click Generate Registration Code.

    After the activation code is generated, installation scripts are generated. Generate scripts

  8. Select an installation script suitable for the operating system type of your server and click Download or Copy to save the script to your computer.

    Important
    • After the activation code is generated, the installation scripts are displayed only once. You must save the suitable installation scripts to your computer.

    • If your servers run different operating systems, you must download the corresponding installation scripts.

Step 2: Install Cloud Assistant Agent on a server and register the server as a managed instance (direct connection)

After you obtain the installation script, install Cloud Assistant Agent on your server and register the server as a managed instance. If your server can directly access the Internet, perform the following steps.

Install Cloud Assistant Agent on a Linux server and register the server as a managed instance

  1. Log on to the server by using SSH.

    For more information, see Connection method overview.

  2. Create an installation script in the server.

    1. Run the following command to create a script by using the Vim editor:

      vim installAssistant.sh
    2. Press the I key to enter the Insert mode.

    3. Paste the content of the script that was generated in the ECS console. For more information, see the Step 1: Create an activation code for managed instances section of this topic.

      You can add the tag parameter to the script to specify tags for the managed instance. Use the following syntax to configure the tag parameter: --tag <Tag key>=<Tag value>. Up to 20 tags can be specified. Separate the tags with spaces. For example, if you add --tag ECS=Document Test=demo to the script, tag A (ECS:Document) and tag B (Test:demo) are added to the managed instance.

      Before you use this method to add tags to the managed instance, make sure that the version of Cloud Assistant Agent is not earlier than the following ones:

      • Linux: 2.2.3.421

      • Windows: 2.1.3.421

      Important

      Take note of the following items when you add tags to the managed instance:

      • If you use the tag parameter to specify tags for the managed instance in the script that was generated in the ECS console, the specified tags are added to the managed instance, regardless of whether the activation code that is used to register the instance has tags added.

      • If you do not use the tag parameter to specify tags for the managed instance in the script and the activation code that is used to register the instance has tags added, the instance inherits the tags of the activation code. For more information, see the Step 1: Create an activation code for managed instances section of this topic.

      • If you do not specify tags in the script and the activation code that is used to register the managed instance has no tags added, the instance is not added with tags.

    4. Press the Esc key to exit the Insert mode.

    5. Enter :wq and press the Enter key to save the script and exit the Vim editor.

  3. Run the following command to grant execution permissions on the installation script:

    sudo chmod 755 installAssistant.sh
  4. Run the following command to install Cloud Assistant Agent on the server:

    sudo ./installAssistant.sh

    If the Cloud Assistant client is installed, a command output similar to the following one is returned. Command output in Linux

Install Cloud Assistant Agent on a Windows server and register the server as a managed instance

  1. Log on to the server by using Remote Desktop Connection.

    For more information, see Connection method overview.

  2. Upload the installation script to the server.

    For information about how to obtain the installation script, see the Step 1: Create an activation code for manage instances section of this topic.

    Note

    Remote Desktop Connection allows you to copy and paste the script file to the server. If the script file cannot be copied due to network environment limits, you can upload scripts by using FTP or other software.

  3. Right-click the installation script and select Run with PowerShell to install Cloud Assistant Agent.

    Windows installation script

Step 2: Install Cloud Assistant Agent on a server and register the server as a managed instance (proxy method)

After you obtain the installation script, install Cloud Assistant Agent on your server and register the server as a managed instance. If your server must use a proxy server to access the Internet, perform the following steps.

Install Cloud Assistant Agent on a Linux server and register the server as a managed instance

This section describes how to configure a proxy server. In this example, a server that runs CentOS 7.8 is used. If your server runs an operating system such as Debian, you must modify the commands shown in the following figure based on the installation script generated in the ECS console. centos

  • ①: Download the Cloud Assistant Agent installation package.

  • ②: Install Cloud Assistant Agent.

  • ③: Register the server as an instance managed by Cloud Assistant.

If your server must use a proxy server to access the Internet, you must add the proxy server information to the commands.

  1. Log on to the server by using SSH.

    For more information, see Connection method overview.

  2. Run the following command to download Cloud Assistant Agent by using the proxy server:

    sudo https_proxy=<http://your_proxy_address> && wget https://aliyun-client-assist.oss-accelerate.aliyuncs.com/linux/aliyun_assist_latest.rpm
    Note

    Replace <http://your_proxy_address> with the address of your proxy server.

  3. Run the following command to install Cloud Assistant Agent:

    sudo rpm -ivh aliyun_assist_latest.rpm --force
  4. Configure a proxy server for Cloud Assistant.

    1. Modify the Cloud Assistant configuration file.

      Modify the Cloud Assistant service configuration file and configure the ALIYUN_ASSIST_PROXY environment variable. Perform the following steps:

      1. Create the vim /etc/sysconfig/aliyun file by using the VIM editor.

        sudo vim /etc/sysconfig/aliyun
      2. Enter the following content. Then, save and exit the file.

        ALIYUN_ASSIST_PROXY=<http://your_proxy_address>
        Note

        Replace <http://your_proxy_address> with the address of your proxy server.

    2. Run the following command to reload the systemd configuration:

      sudo systemctl daemon-reload
    3. Run the following command to restart Cloud Assistant:

       sudo systemctl restart aliyun.service

      After Cloud Assistant is started, if a proxy server is created for Cloud Assistant, Detected environment variable ALIYUN_ASSIST_PROXY for proxy setting appears in the logs of Cloud Assistant. The default log path is /usr/local/share/aliyun-assist/{version}/log/aliyun_assist_main.log.

  5. Run the following commands to register the server as an instance managed by Cloud Assistant by using the proxy server.

    1. Run the following command to configure the proxy server:

      sudo export ALIYUN_ASSIST_PROXY=<http://your_proxy_address>
      Note

      Replace <http://your_proxy_address> with the address of your proxy server.

    2. Run the following commands to register the server as an instance managed by Cloud Assistant:

      sudo aliyun-service --register --RegionId "cn-hangzhou" \
         --ActivationCode "a-hz0f5KlGmF/TsM5uBuq7Eqor+****" \
         --ActivationId "045CE381-0404-4F42-A44B-CC232B3E****"
      Note

      The preceding commands are provided only for reference. You must copy and paste the script generated in the ECS console. For more information, see the Step 1: Create an activation code for managed instances section of this topic.

Install Cloud Assistant Agent on a Windows server and register the server as a managed instance

This section describes how to configure a proxy server. In this example, a server that runs Windows Server 2016 Datacenter is used. The installation script of Cloud Assistant Agent for a Windows server is shown in the following figure. When you configure a proxy server, the RegionId, ActivationCode, and ActivationId parameters are required. Windows script

  1. Log on to the server by using Remote Desktop Connection.

    For more information, see Connection method overview.

  2. Configure a proxy server for the browser.

    1. Choose Start > Control Panel.

    2. Click Network and Internet.

    3. Click Network and Sharing Center.

    4. In the lower-left corner of the page that appears, click Internet Options.

      Configure a proxy

    5. Click the Connections tab and click LAN settings.

    6. In the Proxy server section of the Local Area Network (LAN) Settings dialog box, specify the address and the port of the proxy server and then click OK.

  3. Download the Cloud Assistant Agent installation package.

    1. Click Start and choose Windows PowerShell > Windows PowerShell.

    2. Right-click Windows PowerShell and select Run as administrator.

    3. In the Windows PowerShell window, run the following command to download the Cloud Assistant Agent installation package:

      Invoke-WebRequest -Uri 'https://aliyun-client-assist.oss-accelerate.aliyuncs.com/windows/aliyun_agent_latest_setup.exe' -OutFile 'C:\\aliyun_agent_latest_setup.exe'
  4. After the installation package is installed, install Cloud Assistant Agent.

    1. Open the C:\ drive.

    2. Double-click aliyun_agent_latest_setup.exe and follow the installation wizard to install Cloud Assistant Agent.

  5. Configure a proxy server for Cloud Assistant.

    1. Choose Start > Control Panel.

    2. Click System and Security.

    3. Click System.

    4. In the left-side navigation pane, click Advanced system settings.

      Configure a proxy

    5. Click the Advanced tab and click Environment Variables.

    6. In the System variables section, click New.

    7. Configure Variable name and Variable value and click OK.

      • Variable name: Set this parameter to ALIYUN_ASSIST_PROXY.

      • Variable value: Set this parameter to the IP address of your proxy server.

    8. Run the following commands in Windows PowerShell to restart Cloud Assistant.

      1. Run the following command to disable Cloud Assistant:

        net stop AliyunService
      2. Run the following command to restart Cloud Assistant:

        net start AliyunService
  6. Use the proxy server to register the Windows server as an instance managed by Cloud Assistant in Windows PowerShell.

    Run the following command to go to the directory where Cloud Assistant Agent is installed:

    cd C:\ProgramData\aliyun\assist\{version}
    Note

    {version} specifies the version of Cloud Assistant Agent. Set the value to a specific version number.

    Run the following command to register the Windows server as an instance managed by Cloud Assistant:

     .\aliyun_assist_service.exe  --register  --RegionId="cn-hangzhou" --ActivationCode="a-hz0f6dB8Fg6hhtK0A5n9xqqdH****" --ActivationId="0A2E5ECE-5C71-4FA3-807B-05962C25****"
    Note

    The preceding code is provided for reference only. You must change the values of RegionId, ActivationCode, and ActivationId to those in the script that was generated in the ECS console. For more information, see the Step 1: Create an activation code for managed instances section of this topic.

Step 2: Install Cloud Assistant Agent on a server and register the server as a managed instance by using Express Connect

If your on-premises server must use Express Connect to connect to an Alibaba Cloud virtual private cloud (VPC), you can use this method to register the server as an Alibaba Cloud managed instance. Then, you can connect the instance to the Cloud Assistant server and use Cloud Assistant features. For information about Express Connect, see What is Express Connect?

Install Cloud Assistant Agent on a Linux server and register the server as a managed instance

This section describes how to download and install Cloud Assistant Agent. In this example, a server that runs CentOS is used. The following code shows the installation script of Cloud Assistant Agent on a Linux operating system. If the server runs a Debian operating system, you must modify the command based on the installation script that was generated in the ECS console. CentOS parameters

  1. Log on to the server by using SSH.

    For more information, see Connection method overview.

  2. Run the following script to register the server as a managed instance by using the proxy server.

    • CentOS operating systems

      #/bin/bash
      
      ## Specify a region based on the geographical location of the server.
      regionId="cn-hangzhou"
      
      if [[ -n $regionId ]]; then
          bucket="aliyun-client-assist-${regionId}.oss-${regionId}-internal.aliyuncs.com"
          ## Download Cloud Assistant Agent.
          wget -q https://${bucket}/linux/aliyun_assist_latest.rpm
          ## Install Cloud Assistant Agent.
          sudo rpm -ivh aliyun_assist_latest.rpm --force
      fi
      
      ## Register the server as a managed instance in a VPC. Enter the following setting to set the network type to VPC: NetworkMode "vpc" 
      ## Copy values for the RegionId, ActivationCode, and ActivationId parameters from the page where activation codes are created in the ECS console.
      sudo aliyun-service --register \
        --NetworkMode "vpc" \
        --RegionId "${regionId}" \
        --ActivationCode "a-hz0f5KlGmF/TsM5uBuq7Eqor+****" \
        --ActivationId "2C217D35-FE6C-5636-BC3C-CC480D3*****"

      The preceding code is provided for reference only. You must change the values of RegionId, ActivationCode, and ActivationId to those in the script that was generated in the ECS console. For more information, see the Step 1: Create an activation code for managed instances section of this topic.

    • Debian and other Linux operating systems

      #/bin/bash
      
      ## Specify a region based on the geographical location of the server.
      regionId="cn-hangzhou"
      
      if [[ -n $regionId ]]; then
          bucket="aliyun-client-assist-${regionId}.oss-${regionId}-internal.aliyuncs.com"
          ## Download Cloud Assistant Agent.
          wget -q https://${bucket}/linux/aliyun_assist_latest.deb
          ## Install Cloud Assistant Agent.
          sudo dpkg -i aliyun_assist_latest.deb
      fi
      
      
      ## Register the server as a managed instance in a VPC. Enter the following setting to set the network type to VPC: NetworkMode "vpc" 
      ## Copy values for the RegionId, ActivationCode, and ActivationId parameters from the page where activation codes are created in the ECS console.
      sudo aliyun-service --register \
        --NetworkMode "vpc" \
        --RegionId "${regionId}" \
        --ActivationCode "a-hz0f5KlGmF/TsM5uBuq7Eqor+****" \
        --ActivationId "2C217D35-FE6C-5636-BC3C-CC480D3*****"
      Note

      The preceding code is provided for reference only. You must change the values of RegionId, ActivationCode, and ActivationId to those in the script that was generated in the ECS console. For more information, see the Step 1: Create an activation code for managed instances section of this topic.

Install Cloud Assistant Agent on a Windows server and register the server as a managed instance

This section describes how to install Cloud Assistant Agent. In this example, a server that runs Windows Server 2016 Datacenter is used. The following figure shows the installation script of Cloud Assistant Agent for a Windows server. Windows script

  1. Log on to the server by using Remote Desktop Connection.

    For more information, see Connection method overview.

  2. Click Start and choose Windows PowerShell > Windows PowerShell.

  3. Right-click Windows PowerShell and select Run as administrator.

  4. In the Windows PowerShell window, run the following commands:

    $RegionId = "cn-hangzhou"
    $Bucket = "aliyun-client-assist-${RegionId}.oss-${RegionId}-internal.aliyuncs.com"
    
    Invoke-WebRequest -Uri "https://${Bucket}/windows/aliyun_agent_latest_setup.exe" `
    -OutFile 'C:\\aliyun_agent_latest_setup.exe'
    &"C:\\aliyun_agent_latest_setup.exe" '/S' '--register' `
    '--NetworkMode="vpc"' '--RegionId="cn-hangzhou"' `
    '--ActivationCode="a-hz0f6dB8Fg6hhtK0A5n9xqqdH****"' `
    '--ActivationId="0A2E5ECE-5C71-4FA3-807B-05962C25****"'
    type C:\ProgramData\aliyun\assist\hybrid\instance-id
    Start-Sleep -s 30
    net stop AliyunService
    net start AliyunService
    Note

    The preceding code is provided for reference only. You must change the values of RegionId, ActivationCode, and ActivationId to those in the script that was generated in the ECS console. For more information, see the Step 1: Create an activation code for managed instances section of this topic.

Step 3: View the managed instance in the ECS console

After Cloud Assistant Agent is installed, go back to the ECS console to check whether the managed instance is connected.

  1. In the left-side navigation pane, choose Maintenance & Monitoring > Cloud Assistant.

  2. In the upper-left corner of the top navigation bar, select a region. 地域

  3. On the Cloud Assistant page, click the Manage Instances tab to view the list of managed instances.

    Managed instance list

    If the server is registered as a managed instance, Normal is displayed in the Connection Status column corresponding to the managed instance, as shown in the preceding figure.

You can use Cloud Assistant to manage the server without the need to log on to the server. For information about how to use Cloud Assistant, see Use the immediate execution feature and Upload files to ECS instances.

(Optional) Deregister managed instances and uninstall Cloud Assistant Agent

If Cloud Assistant is no longer needed, you can deregister managed instances and stop and uninstall Cloud Assistant Agent.

Linux operating system

  1. Log on to the server by using SSH.

    For more information, see Connection method overview.

  2. Run the following command to unregister the managed instances:

    sudo aliyun-service --deregister
  3. Disable and uninstall the Cloud Assistant daemon process.

    1. Run the following command to disable the Cloud Assistant daemon process:

      sudo /usr/local/share/assist-daemon/assist_daemon --stop
      Note

      In the preceding command, /usr/local/share/assist-daemon/assist_daemon is the default path of the Cloud Assistant daemon process.

    2. Run the following command to uninstall the Cloud Assistant daemon process:

      sudo /usr/local/share/assist-daemon/assist_daemon --delete
  4. Run the following command to stop Cloud Assistant Agent.

    Note

    Linux has different kernel versions and uses different initialization process services. Linux that uses a recent kernel version such as Ubuntu 18.04 generally uses the systemd initialization process service. In this example, the systemd initialization process is used. For more information about how to use other initialization process services, see Start, stop, or uninstall the Cloud Assistant Agent.

    sudo systemctl stop aliyun.service
  5. Run one of the following commands to uninstall Cloud Assistant Agent:

    • RPM package:

      sudo rpm -qa | grep aliyun_assist | xargs sudo rpm -e
    • DEB package:

      sudo dpkg -r aliyun_assist_latest.deb
  6. Delete the Cloud Assistant daemon process and Cloud Assistant Agent.

    1. Run the following command to delete the directory where the Cloud Assistant daemon process is stored:

      sudo rm -rf /usr/local/share/assist-daemon
    2. Run the following command to delete the directory where Cloud Assistant Agent is installed:

      sudo rm -rf /usr/local/share/aliyun-assist

Windows operating system

Note

In this example, a server that runs Windows Service 2019 is used. The paths for Windows PowerShell and services in other Windows versions may be different.

  1. Log on to the server by using Remote Desktop Connection.

    For more information, see Connection method overview.

  2. Start Windows PowerShell. Start Powershell

    1. Click Start.

    2. Choose Windows PowerShell > Windows PowerShell.

    3. Right-click Windows PowerShell and select Run as administrator.

  3. Run the following command in Windows PowerShell to unregister the managed instances:

    aliyun-service --deregister
  4. Open the service management window. Service

    1. Click Start.

    2. Choose Administrative Tools > Service.

  5. Find Aliyun Assist Service and click Stop the service. Stop service in Windows

References