Changing ECS Hostnames
Scenarios
You can change the static hostnames of Linux ECSs after they are created.
The static hostname of a Linux ECS is user defined and injected using Cloud-Init during the ECS creation. After an ECS is created, you can change its name and hostname on the console. For details about Cloud-Init, see (Optional) Installing and Configuring Cloud-Init.
This section describes how to change the hostname of a Linux ECS online.
What Is a Hostname?
A hostname is used to identify a computer or server on a network. It helps you and network systems identify and access specific devices.
Hostnames are used in the following scenarios:
- Identifying ECSs: Hostnames help distinguish different devices. You can plan hostnames based on the location, usage, and owner of ECSs to easily identify different ECSs.
- Identifying the source of logs and monitoring data: Hostnames can be used to identify the source of events in logs and monitoring data and accurately locate the ECSs where events occur. This reduces the time required for system analysis or troubleshooting and improves O&M efficiency.
- Simplifying configuration management: You can use hostnames instead of IP addresses when configuring network services, applications, and system settings For details, see Configuring Mapping Between Hostnames and IP Addresses in the Same VPC.
Notes and Constraints
- Cloud Operations Center (COC) needs to be enabled and authorized.
For IAM users, permissions for COC operations need to be granted. For details, see Configuring Custom Policies for ECS Self-Service O&M.
- UniAgent must be installed. UniAgent is a unified data collection agent that supports script delivery and execution.
If an ECS does not have UniAgent installed, its hostname cannot be changed. To install UniAgent, see Installing UniAgent on an ECS.
- You can only change the hostname of a Linux ECS.
- If you log in to an ECS using a remote login tool, such as VNC or CloudShell, the new hostname may not be applied immediately due to the system cache. In this case, you need to exit the ECS and log in again to apply the change.
You are advised to exit the ECS using the following command:
exit
Procedure
You can change the hostnames of one or more ECSs to the same hostname.
- Log in to the ECS console and access the Elastic Cloud Server page.
- In the Operation column of an ECS whose hostname is to be changed, choose More > Change Hostname.
- (Optional) On the Enable COC and Grant Permissions page, read and agree to the service statement, and click Enable and Authorize.
This page is displayed if COC is not enabled and authorized.
- In the slide-out panel, configure required parameters.
UniAgent is required for changing a hostname. If a message is displayed indicating that UniAgent is not installed or failed to be installed, install it first by referring to Installing UniAgent on an ECS.
Figure 1 Changing a hostnameTable 1 Parameters related to hostname changes Parameter
Description
ECS Name (Optional)
Specifies the new ECS name. This parameter is optional. When you are changing the hostname, you can also change the ECS name at the same time. The change is applied immediately.
Only letters, digits, underscores (_), hyphens (-), and periods (.) are allowed.
Hostname
Specifies the new static hostname of the ECS. The change is applied immediately.
Only letters, digits, hyphens (-), and periods (.) are allowed. The periods (.) and hyphens (-) cannot be used consecutively or at the beginning or end of the hostname.
- Click OK. The ECS hostname is changed.
- Log in to the ECS console and access the Elastic Cloud Server page.
- In the ECS list, select the ECSs whose hostnames are to be changed.
- Above the ECS list, choose More > Change Hostname.
- In the slide-out panel, configure required parameters.
UniAgent is required for changing a hostname. If a message is displayed indicating that UniAgent is not installed or failed to be installed, install it first by referring to Installing UniAgent on an ECS.
When the names or hostnames of multiple ECSs are changed in a batch, the new names or hostnames of these ECSs are the same.
Figure 2 Changing hostnamesTable 2 Parameters related to hostname changes Parameter
Description
ECS Name (Optional)
Specifies the new ECS name. This parameter is optional. When you are changing the hostname, you can also change the ECS name at the same time. The change is applied immediately.
Only letters, digits, underscores (_), hyphens (-), and periods (.) are allowed.
Hostname
Specifies the new static hostname of the ECS. The change is applied immediately.
Only letters, digits, hyphens (-), and periods (.) are allowed. The periods (.) and hyphens (-) cannot be used consecutively or at the beginning or end of the hostname.
- Click OK. The ECS hostnames are changed.
Check Whether a Hostname Has Been Changed
- Log in to the ECS.
- Run the following command to view the hostname.
hostname
If the new hostname is displayed in the command output, the hostname has been changed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot