In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
one
Today, a student asked Jango a question: how to change the Computername of the Azure virtual machine?
Although this is a relatively simple operation, what Django wants to share with you today is, is there anything special about Azure's virtual machine management?
First of all, we need to distinguish between two concepts:
Azure virtual machine name (VM Name): this is the name of the virtual machine, which is the name of the virtual machine resource displayed on the Azure Portal. Currently, Azure does not provide the operation to change the virtual machine name, so it can only be redeployed by deleting the virtual machine.
Hostname of the Azure virtual machine operating system: this is the hostname seen in the operating system, and for virtual machines deployed through Azure Marketplace, it is the same as the virtual machine name by default.
two
If it is an On-Premises server, whether it is a physical machine or a virtual machine, I believe everyone is familiar with-Windows's operating system through the remote desktop, Linux's operating system through SSH, connected to the operating system, and then through the corresponding command or operation can change the host name.
If the physical machine or virtual machine is not connected to the network for the time being, or if the subnet of the administrator cannot connect to the operating system through remote desktop or SSH, you can also open the management terminal (Console) of the virtual machine through the corresponding management client, while the physical machine can change the host name and the corresponding network settings by connecting the mouse, keyboard and monitor.
three
For the virtual machine of Azure, because the monitor cannot be physically connected, and Azure does not provide the corresponding management terminal (Azure Portal provides the virtual machine Boot Diagnostics, but can only see the current Screenshot of the virtual machine, can not operate), so there is no way to change the host name in this way. But Azure provides us with more ways to achieve this:
For virtual machines that have been deployed:
Log in to the virtual machine operating system through remote Desktop (Windows) or SSH (Linux) in the same way as traditional On-Premise servers.
Modify via Run Command (Portal / Powershell / Azure CLI) remote execution command
For the virtual machine to be deployed:
Linux can modify the operating system hostname directly at deployment time by calling the Cloud-init API.
Next, several ways are explained respectively.
1. Log in to the virtual machine operating system via remote Desktop (Windows) or SSH (Linux).
I believe you are already quite familiar with this approach, and the focus here is how to obtain the IP address of the virtual machine.
For virtual machines deployed through Azure Marketplace, Windows opens port RDP (3389) by default, and Linux opens port SSH (22). Therefore, for an Azure virtual machine configured with a Public IP address, and if the corresponding NSG (Network Security Group) is not configured, as long as you find the IP address of the virtual machine, you can connect to the virtual machine operating system to modify the host name.
How to obtain the Public IP address of the Azure virtual machine:
FAVORITES
Log in to Azure Portal (https://portal.azure.com/), find "Virtual Machine" under "FAVORITE" on the left, then find the corresponding virtual machine, and you can see the Public IP address of the virtual machine under the "PUBLIC IP ADDRESS" column on the right.
After finding the Public IP address, you can connect to the virtual machine via remote Desktop (Windows) or SSH (Linux) to modify the hostname. Brother Qiang won't repeat it here.
II. Modify through Run Command (Portal / Powershell / Azure CLI) remote execution command
Azure provides a way to run commands on a virtual machine without logging in to the virtual machine, Windows allows Powershell commands or scripts, and Linux runs Shell commands or scripts.
On Portal, this method can be found at "Run Command" under the management interface of the virtual machine
The following figure shows the interface of the Windows virtual machine:
The Run Command interface for the Linux virtual machine is slightly different:
Click "RunPowerShellScript" or "Run Command Script" to run PowerShell / Linux Shell commands or scripts here.
For example, this Windows virtual machine here:
Linux virtual machine:
However, for the era of cloud computing, it is a bit like taking off your pants and farting-you also need to connect to the graphical interface (Azure Portal). So how do you do it through commands?
Azure CLI
Azure CLI is a command line management tool provided by Microsoft to Azure administrators. It supports Windows,Linux and MacOS platforms, and the command format on each platform is exactly the same.
Go to the following address to download Azure CLI:
Https://aka.ms/installazurecliwindows (Windows)
The installation process is simple and you can take the next step all the way. After the installation is complete, run az login to log in to Azure. Running this command invokes a web browser to open https://login.microsoftonline.com. Enter the appropriate Azure administrator account here:
The result after login:
After logging in, you can use Azure CLI commands to manage your resources on Azure.
We use az vm run-command invoke to invoke the PowerShell command on the Azure virtual machine:
-g: name of the Resource Group where the virtual machine is located
-n: name of the virtual machine
-- scripts: the content of the script to be run
-- command-id: what command to call, here is RunPowerShellScript, that is, run the PowerShell script on the Azure virtual machine
Az vm run-command invoke-n Win2k12R2-AE-command-id RunPowerShellScript-g az-100-c2-scripts "hostname;Rename-Computer-NewName Win2k12R2-AE;restart-computer-force"
So here we have successfully modified the host name of this Azure virtual machine through Azure CLI.
For more Azure cloud computing courses, visit Johngo Cloud Computing:
Strong Brother Cloud Computing
To be continued... Please continue to follow Qiango Cloud Computing.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 247
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.