After an ECS instance is restarted for the first time, the hostname (hostname) of some CentOS 7 instances is changed from uppercase letters to lowercase letters. This topic lists the impacted image types and the solution.
Examples of hostname changes
The following table shows examples of changes before and after the initial restart of a CentOS instance with an uppercase hostname.
|Instance hostname example||Hostname change after the initial restart||Do the lowercase letters remain in subsequent restarts?|
The following CentOS public images and the custom images created by using these public images are impacted.
Impacted hostname types
If the applications deployed in your instance are case-sensitive to the hostname, and you restart the target instance, your services will be impacted. To resolve this issue, you can use an appropriate method described in this topic to fix this error according to the required hostname type or types:
|Hostname convention||Is the name changed?||When does the change occur?||Do I proceed with this topic?|
|The hostname has some uppercase letters in the instance that you create in the ECS console or by using the API.||Yes||Initial restart||Yes|
|The hostname has only lowercase letters in the instance that you create in the ECS console or by using the API.||No||N/A||No|
|The hostname had some uppercase letters, but were changed to lowercase letters after you log on to the instance.||No||N/A||Yes|
To retain a hostname with uppercase letters after you restart the instance, follow these steps:
- Connect to the instance.
- Run the following command to view the current hostname:
[root@izbp193nf1pk3i161uynzzx ~]# hostname izbp193nf1pk3i161uynzzx
- Run the following command to set the hostname:
hostnamectl set-hostname --static iZbp193nf1pk3i161uynzzX
- Run the following command to view the updated hostname:
[root@izbp193nf1pk3i161uynzzx ~]# hostname iZbp193nf1pk3i161uynzzX
What to do next
If you are using a custom image, update the cloud-init tool to the latest version, and then create the custom image again. Otherwise, the same error occurs when you use the original custom image to create a new instance. For more information, see Install cloud-init for Linux images and Create a custom image by using an instance.