All Products
Search
Document Center

Simple Application Server:Migrate data from an ECS instance to a simple application server

Last Updated:Jan 23, 2024

You can migrate the web applications deployed on an Elastic Compute Service (ECS) instance to a simple application server based on your business requirements. This topic describes how to migrate data from an ECS instance to a simple application server.

Prerequisites

  • A simple application server whose operating system (OS) version is the same as the OS version of the ECS instance is created. For more information, see Create a server.

    Note
    • If you have created a simple application server whose OS is different from that of the ECS instance, you can reset your simple application server. For more information, see Reset a simple application server.

    • The versions of OS images provided by Simple Application Server are fewer than the versions of public images provided by ECS. When you migrate data from an ECS instance to a simple application server, you can choose an OS version for the server that is similar to the OS version of the ECS instance. For example, if the ECS instance uses a public image of CentOS 7.X, you can change the image used by the simple application server to the CentOS 7.3 or CentOS 7.6 OS image.

  • A password is set for the simple application server. For more information, see Set or reset the password of a server.

  • The required ports are enabled. For more information, see the Manage a firewall section of the Manage the firewall of a simple application server topic.

    In this topic, you must enable port 3306 (the default port used for MySQL), port 8888 (the default port used for aaPanel), and port 888 (the default port used for the phpMyAdmin database management tool).

    Warning

    Enabling these default ports may cause server intrusion. We recommend that you disable the ports at the earliest opportunity after they are used or change the default port numbers to other available port numbers.

Background information

In this topic, a WordPress website is migrated from an ECS instance that is deployed in the LNMP (Linux, NGINX, MySQL, and PHP) environment to a simple application server. After the data is migrated, the website must be workable, and the data must be complete. The following tables describe the ECS instance, the simple application server, and tools used to migrate data in the example.

  • The ECS instance and the simple application server

    ECS instance

    Simple application server

    • Image: CentOS 7.8 public image.

    • Runtime environment and application: The WordPress website is deployed in the LNMP environment.

      Versions:

      • NGINX: 1.16.1.

      • MySQL: 5.7.28.

      • PHP: 7.0.33.

      • WordPress: 5.1.10.

      Note

      For more information about how to build an LNMP environment and deploy a WordPress website on an ECS instance, see Build a WordPress website on a CentOS 7 instance.

    Image: CentOS 7.6.

  • Tools

    Tool

    Description

    Free aaPanel

    aaPanel is an O&M panel for servers. In this topic, aaPanel is used to build the same LNMP environment on the simple application server as that on the ECS instance.

    scp command

    This command is used to remotely copy files by using the Secure Shell (SSH) protocol. The web application (excluding the data stored in the web application database) deployed on the ECS instance is copied to the simple application server by running the scp command.

    Alibaba Cloud Data Transmission Service (DTS)

    Data stored in the web application database of the ECS instance is migrated to the database of the simple application server by using DTS. For more information about DTS, see What is DTS?

Usage notes

  • Create snapshots to back up data.

    For more information, see the following topics:

    Warning

    We recommend that you create snapshots for the ECS instance and the simple application server. If data exceptions occur due to migration failures, you can use snapshots to roll back the disks of the instance and server.

  • Make sure that runtime environments on the instance and the server must be of the same version.

    Some websites have high version requirements for the runtime environment. If the versions of the runtime environment before and after the migration are different, the websites may not run normally. You must understand the version information of the runtime environment on the ECS instance. For example, if the runtime environment of the instance is LNMP, you must understand the version information of the NGINX, MySQL, and PHP applications and make sure that the applications of the same versions are deployed on the simple application server to build an identical runtime environment.

  • Check the network.

    Make sure that the server and the instance can access the Internet. If you migrate data across regions in different countries, the network environment may not be stable. You may experience low migration speeds.

Impacts of the migration

Item

Description

Authorized applications on the ECS instance and the simple application server

The ECS instance and the simple application server reside in different virtual private clouds (VPCs). After data is migrated from the ECS instance to the server, the underlying hardware may change, and hardware-locked application licenses may become invalid. You are responsible for maintaining the application licenses valid.

Public IP address

The public IP address of the ECS instance is different from that of the server. If a domain name is associated with the ECS instance, you must resolve the domain name to the public IP address of the server after you migrate data from the ECS instance to the server.

Step 1: Install and configure aaPanel in the simple application server

In this topic, we recommend that you use aaPanel to efficiently configure the runtime environment of the server. Make sure that the runtime environment version of the server is the same as that of the ECS instance.

Note

When you migrate data in actual data migration scenarios, you must manually configure the website runtime environment of the server based on your business requirements to ensure that the website runtime environment of the server is identical to that of the instance.

  1. Connect to your simple application server in the Simple Application Server console.

    For more information, see Connect to a Linux server.

  2. Run the following command to switch to the root user:
    sudo su root
  3. Install aaPanel.

    You can visit the aaPanel official website to obtain installation packages for different OSs. In this topic, the OS of the simple application server is CentOS 7.6. Therefore, you need to run the following command to install free aaPanel:

    yum install -y wget && wget -O install.sh http://www.aapanel.com/script/install_6.0_en.sh && bash install.sh aapanel

    If the command output is similar to the following message, aaPanel is installed. You need to save the information of aaPanel Internet Address, aaPanel Internal Address, username, and password.

    ==================================================================
    Congratulations! Installed successfully!
    ==================================================================
    aaPanel Internet Address: https://8.218.XX.XX:7800/d55e4627
    aaPanel Internal Address: https://172.19.XX.XX:7800/d55e4627
    username: k6tzrhwj
    password: d2ae****
    Warning:
    If you cannot access the panel,
    release the following port (7800|888|80|443|20|21) in the security group
    ==================================================================
    Time consumed: 1 Minute!
  4. On your computer, enter the aaPanel Internet address in the address bar of your browser and use the username and password that you saved in the previous step to connect to aaPanel.

    After you connect to aaPanel, you need to use your aaPanel account to log on to aaPanel. If you do not have an aaPanel logon account, follow the instructions on the aaPanel logon page to register an account.

    The following figure shows the page of aaPanel after you log on to aaPanel.adad

  5. In aaPanel, build the same runtime environment as that of the ECS instance.

    1. In the left-side navigation pane, click App Store.

    2. In the App Sort section, click Deployment.

    3. Find the following applications in the Software name column and click Install in the Operation column.

      • Nginx

        Click Install, select the nginx 1.16 version, and then click Submit.

      • MySQL

        Click Install, select the mysql 5.7 version, and then click Submit.

      • PHP-7.0

        Click Install, use the default settings, and then click Submit.

      • phpMyAdmin

        Click Install, select the phpmyadmin 4.9 version, and then click Submit.

      It takes time to install applications. Wait until the applications are installed.

  6. In aaPanel, add website information.

    1. In the left-side navigation pane, click Website.

    2. On the PHP Project tab, click Add site.

    3. On the Create site tab of the Add site - Support batch site building dialog box, configure parameters and click Submit.

      The following table describes the main parameters. For other parameters, use the default settings.

      Parameter

      Description

      Example

      Domain name

      • If you have bound and resolved a domain name to the simple application server, you can enter the domain name in the Domain name field.

      • If you have not bound and resolved a domain name to the simple application server, you can enter the public IP address of the simple application server for subsequent test operations. After data is migrated, you must bind and resolve a domain name to the simple application server and modify the configuration in the Domain name field.

      Enter the public IP address of the simple application server. The public IP address can be used to check whether the website can be accessed after the migration is complete.

      Description

      The description for the website. This parameter can be left empty.

      Enter server-B.

      Website Path

      The root directory of the website. The default root directory is /www/wwwroot when you use aaPanel to create a website.

      Enter /www/wwwroot/wordpress.

      The following figure shows that the website is added.添加站点

  7. In aaPanel, configure MySQL.

    1. In the left-side navigation pane, click Databases.

    2. On the Database Manager page, change the root password.

      1. Click Root password.

      2. Enter a new value for Root password and click Submit.

        In this topic, Test@123 is entered as the new password.

        Important

        In actual scenarios, you must keep the password secure to prevent the risk of server exceptions due to password leaks.

    3. On the Database Manager page, click phpMyAdmin.

    4. On the phpMyAdmin page, enter the username and password of the MySQL root user and click Go.

    5. In the top navigation bar, click SQL. Enter the following commands and click Go.

      When you migrate data stored in a database, users of MySQL databases must have remote connection permissions. You must create a user of the MySQL database for remote connection on the simple application server.

      -- Switch to the MySQL database. 
      use mysql;
      -- Create a user of the MySQL database for remote connection named testUser. Set the password to Test@123. 
      create user 'testUser'@'%' IDENTIFIED BY 'Test@123';
      -- Grant remote connection permissions to testUser. 
      grant all privileges on *.* to 'testUser'@'%' with grant option;
      -- Make the configurations immediately take effect. 
      flush privileges;
    6. In the top navigation bar, click SQL. Enter the following commands and click Go.

      To allow the WordPress website to connect to the MySQL database after the website is migrated, you must create the same database and database user on the simple application server based on the information of the MySQL database on the ECS instance.

      In this topic, the MySQL database on the ECS instance is named wordpress, the username of the database is user, and the password is PASSword123.

      -- Create a database named wordpress. 
      create database wordpress;
      -- Create a user named user and set the password to PASSword123. 
      create user 'user'@'localhost' identified by 'PASSword123.';
      -- Grant the user all permissions on the wordpress database. 
      grant all privileges on wordpress.* to 'user'@'localhost' identified by 'PASSword123.';
      -- Make the configurations immediately take effect. 
      flush privileges;
  8. In aaPanel, configure the firewall.

    1. In the left-side navigation pane, click Security.

    2. In the Firewall section, enable the default port 3306 of the MySQL database.

      The following figure shows the parameters.宝塔防火墙

    3. Click Open.

Step 2: Configure the ECS instance

Perform the following operations to configure the ECS instance before you use DTS to migrate the data in the database:

  1. Configure the security group.

    Before you migrate data, you must enable the specified ports of the security group to which the ECS instance belongs. MySQL databases are installed on both the ECS instance and the simple application server. You must add rules to the security group to which the ECS instance belongs to enable the default port 3306 of MySQL databases. For more information, see Add a security group rule.

  2. Configure the MySQL database.

    When you migrate data stored in a database, users of MySQL databases must have remote connection permissions. You must create a user of the MySQL database for remote connection on the ECS instance.

    1. Connect to the ECS instance.

      For more information, see Connection method overview.

    2. Run the following command to log on to the MySQL database:

      mysql -uroot -p
    3. Enter the password of the MySQL root user in the Enter password: command line.

      You must enter the logon password used to connect to the MySQL database.

      Note

      For data security purposes, no output is returned when you enter a password. You need only to enter the correct password and then press the Enter key.

    4. Run the following command to use the wordpress database.

      The data of the WordPress website is stored in the wordpress database.

      use wordpress;
    5. Run the following command to create a user of the database for remote connection.

      In this topic, create a user named testUser and set the password to Test@123.

      Important

      The password is for demonstration only. You must set a password and keep the password secure to prevent the risk of data exceptions due to password leaks.

      create user 'testUser'@'%' IDENTIFIED BY 'Test@123';
    6. Run the following commands in sequence to grant the remote connection permissions to the testUser user.
      1. Grant the remote connection permissions.
        grant all privileges on *.* to 'testUser'@'%' with grant option;
      2. Make the configuration immediately take effect.
        flush privileges;
    7. Run the following command to exit MySQL:
      \q;

Step 3: Run the scp command to copy web applications

  1. Check the information about the simple application server.

    When you run the scp command to copy web applications, you must specify the public IP address and file storage path of the destination server. Therefore, you must check the following information of the simple application server:

    • The public IP address

      For more information about how to view the public IP address, see the View the card of a server on the Servers page section of the View server information topic.

    • The website root directory

      In this topic, the website root directory of the simple application server is /www/wwwroot/wordpress.

  2. Connect to the ECS instance.

    For more information, see Connection method overview.

  3. Run the following scp command to migrate web applications deployed on the ECS instance to the simple application server:

    scp -r /usr/share/nginx/html/wordpress/* root@<Public IP address of the simple application server>:/www/wwwroot/wordpress

    The following section describes the parameters in the scp command:

    • -r indicates a recursive copy of the entire directory. If you want to copy a single file, delete -r.

    • /usr/share/nginx/html/wordpress/* indicates all files (/*) in the folder of the web applications on the ECS instance.

    • root@<Public IP address of the simple application server> indicates connecting to the simple application server over the SSH protocol.

    • /www/wwwroot/wordpress indicates the website root directory on the simple application server.

  4. Enter the logon password of the simple application server in the root@<Public IP address of the simple application server>'s password: command line.

    Note

    For data security purposes, no output is returned when you enter a password. You need only to enter the correct password and then press the Enter key.

    When you run the scp command to remotely copy files, data transmission is encrypted, and the transmission speed is limited. Wait until the files are copied.

Step 4: Migrate data stored in the database by using DTS

  1. Log on to the DTS console.
  2. In the left-side navigation pane, click Data Migration. In the upper-left corner of the page, click Create Task.

  3. Configure the data migration task.

    The following section describes the main parameters. For other parameters, use the default settings.

    • Task Name: Enter a name for the task. Example: test-swas-01.

    • Source Database (information about the ECS instance): The following table describes the relevant parameters of the source database.

      Parameter

      Description

      Database Type

      The type of the source database. Select MySQL.

      Access Method

      The access method of the source database. Select Self-managed Database on ECS.

      Instance Region

      The region where the ECS instance resides. Example: China (Hangzhou).

      Replicate Data Across Alibaba Cloud Accounts

      Specify whether to track data across Alibaba Cloud accounts. In this example, No is selected.

      ECS Instance ID

      The ID of the ECS instance.

      Port Number

      The port number. Default value: 3306.

      Database Account

      The database user account that has the remote connection permissions. Example: testUser.

      Database Password

      The password. Example: Test@123.

      Important

      The password is for demonstration only. You must set a password and keep the password secure to prevent the risk of data exceptions due to password leaks.

    • Destination Database (information about the simple application server): The following table describes the relevant parameters of the destination database.

      Parameter

      Description

      Database Type

      The type of the destination database. Select MySQL.

      Access Method

      The access method of the destination database. Select Public IP Address.

      Instance Region

      The region where the simple application server resides. Example: China (Hangzhou).

      Hostname or IP address

      The public IP address of the simple application server.

      Port Number

      The port number. Default value: 3306.

      Database Account

      The database user account that has the remote connection permissions. Example: testUser.

      Database Password

      The password. Example: Test@123.

      Important

      The password is for demonstration only. You must set a password and keep the password secure to prevent the risk of data exceptions due to password leaks.

  4. After all parameters are specified, click Test Connectivity and Proceed to check the connectivity between DTS and the MySQL databases on the ECS instance and the simple application server.

  5. In the CIDR Blocks of DTS Servers dialog box, click Test Connectivity and Proceed.

  6. In the Configure Objects and Advanced Settings step, configure the required parameters and click Next: Advanced Settings.

    The following section describes the parameters. For more information, see Manage a data migration task.

    • Task Stages: Select Schema Migration, Full Data Migration, or Incremental Data Migration based on your business requirements.

    • Source Objects: In the Source Objects section, select Select All and click the 图标1 icon.

    The following figure shows the page after you configure the migration task.sadl

  7. In the Advanced Settings step, use the default settings and click Next: Save Task Settings and Precheck.

    Wait until the precheck is complete. If the precheck fails, click View Details next to Failed to resolve the cause of the failure and perform the precheck again.

  8. Click Next: Purchase Instance.adada56

  9. In the Purchase step, select Data Transmission Service (Pay-as-you-go) Service Terms and click Buy and Start.

    In this topic, you are not charged for migrating data by using DTS. However, when you migrate data by using DTS in actual scenarios, you are charged based on your operations, and the actual price that is displayed on the page takes precedence. For more information about billing of DTS, see Billing overview.

    After you start the data migration task, wait until the task is complete.adad

Step 5: Verify migration results

  1. On your computer, use a browser to log on to aaPanel of the simple application server.

  2. View the application files of the WordPress website.

    1. In the left-side navigation pane of aaPanel, click Website.

    2. On the PHP Project page, click the website root directory in the Document Root column.

      adsad

      The following figure shows the files of the web application deployed on the simple application server.dada

    3. Check whether the web application can run as expected.

      Check whether the web application deployed on the simple application server is the same as that deployed on the ECS instance based on actual business scenarios. For example, in this topic, the wp-config.php file in the ECS instance is set with a symbolic link. After the file is migrated, the symbolic link becomes invalid. As a result, the permissions on the wp-config.php file of the simple application server change and must be modified.

      The operation of modifying permissions on files can be performed on aaPanel. Perform the following operations:

      1. Move the pointer over the file whose permissions you want to modify and click PMSN.adada56

      2. In the Set permission dialog box, set permissions on the file and click OK.

        You can grant permissions on the file based on your business requirements. In this topic, grant all permissions on the wp-config.php file.asda

  3. View the information of the database in which the data of the WordPress website is stored.

    1. In the left-side navigation pane of aaPanel, click Databases.

    2. Click Get DB from server.

      The following figure shows the wordpress database information that is obtained from the simple application server. If the database password fails to be obtained, you can click reset to reset the database password.adad56

    3. Click Tools in the Operation column to view the table information of the wordpress database.

      The following figure shows that the table information in the simple application server is the same as that in the ECS instance.ada566

  4. On your computer, access http://<Public IP address of the simple application server> by using a browser to test the access to the WordPress website.

    • As shown in the following figure, if the WordPress website can be accessed and the data displayed on the website is identical to the data before the migration, the data is migrated.sdad5

    • If the WordPress website cannot be accessed and the following error is reported: Warning: require_once(/www/wwwroot/wordpress/wp-config.php): failed to open stream: Permission denied in /www/wwwroot/wordpress/wp-load.php on line 37, you need to set required permissions on the files based on the error message. For more information, see the Check whether the web application can run as expected. section of this topic.asda

What to do next

The public IP address changes because data is migrated from Server A to Server B. If you bind and resolve a domain name to Server A, you must bind and resolve the domain name to Server B after data is migrated. For more information, see Bind and resolve a domain name.