Updated on 2024-10-21 GMT+08:00

Overview

Background

When you migrate a Linux source server, you need to ensure that the source server can identify and resolve the interface domain names of related cloud services. This usually involves editing the hosts file on the source server. If there are a large number of servers to be migrated, manual editing is time-consuming. To simplify this process, we provide example scripts for batch editing. You can use the scripts to quickly push the mappings between domain names and IP addresses to the hosts file on all source servers in batches.

Script Description

The scripts are developed using the Shell language and can run only on Linux. They are used to batch update and restore the /etc/hosts file on Linux source servers.

To prevent long script execution, a maximum of 100 servers can be modified at a time.

The following table describes for what and where the scripts are used.

Script

Function

Scenario

update_hosts_linux.sh

Batch update the /etc/hosts file on Linux source servers. The script will automatically log operations, alert for any exceptions, and generate a summary of the operations.

Before migrating Linux source servers, run this script to update the hosts file for the servers.

rollback_hosts_linux.sh

Batch restore the /etc/hosts file on the Linux source servers. The script will automatically log operations, alert for any exceptions, and generate a summary of the operations.

After the Linux source servers are migrated, run this script to restore the hosts file on the source servers to the state before the migration.