Cloud Virtual Machine

Cloud Virtual Machine
Operations Guide
Product Documentation©2013-2022 Tencent Cloud. All rights reserved.

Page 1 of 242

Cloud Virtual Machine

Copyright Notice©2013-2024 Tencent Cloud. All rights reserved.
Copyright in this document is exclusively owned by Tencent Cloud. You must not reproduce, modify, copy or distributein any way, in whole or in part, the contents of this document without Tencent Cloud's the prior written consent.
Trademark Notice

All trademarks associated with Tencent Cloud and its services are owned by Tencent Cloud Computing (Beijing)
Company Limited and its affiliated companies. Trademarks of third parties referred to in this document are owned bytheir respective proprietors.
Service Statement
This document is intended to provide users with general information about Tencent Cloud's products and services
only and does not form part of Tencent Cloud's terms and conditions. Tencent Cloud's products or services are
subject to change. Specific products and services and the standards applicable to them are exclusively provided for in
Tencent Cloud's applicable terms and conditions.

©2013-2022 Tencent Cloud. All rights reserved.

Page 2 of 242

Cloud Virtual Machine

Contents
Operations Guide
Initializing Data Disks
Initializing Data Disks (Windows CVM)
Formatting & Mounting Data Disks
Reading/Writing EXT Data Disks after Reinstalling a Linux CVM to Windows CVM
Read/Write of the Original NTFS Data Disk After the Operating System Is Changed from Windows toLinuxEnvironment Configurations
Linux Power Management Configuration
Modifying etc/hosts Configuration of Linux Instance
Installing Software
Accelerating Software Package Downloading and Updating with Tencent Cloud Software Source
Installing Software via Apt-get (Ubuntu)
Installing Software via YUM (CentOS)
Installing Software via zypper (SUSE)
Switching CentOS 6 Source to YUM Repository
Installing chronyd Service on CentOS 8User Data
Configuring Custom Data (Linux CVM)
Setting Custom Data (Windows CVM)Work with Operating Systems
System Activation
Activating Windows with slmgr Command
Windows Server System Activation
System Updates
System Shutdown
Configuring High-performance Power Management
Windows Recovery Mode
Updating the Virtio ENI Driver
Modifying SID
Modifying VNC Resolution
Ensuring Unique SIDs for CVMs Using Sysprep
Use of the atop Monitoring Tools by Linux Instances
Introduction to Linux Kernel Parameters
OthersBooting into Linux Single User Mode©2013-2022 Tencent Cloud. All rights reserved.

Page 3 of 242

Cloud Virtual Machine

Using Rescue Mode
Setting Up Windows CVM for Multi-user Remote Login
Modifying the Default Remote Port of CVM
Getting Instance Login Logs

©2013-2022 Tencent Cloud. All rights reserved.

Page 4 of 242

Cloud Virtual Machine

Operations Guide
Initializing Data Disks
Initializing Data Disks (Windows CVM)：

Last updated 2024-01-06 17:38:11

Scenario
After purchasing or reinstalling CVM, you need to partition and format the data disk. This document describes how to
perform partitioning, formatting, and other initialization operations on a data disk on Windows CVM.

Notes
Formatting a data disk will erase all data. Please ensure that the data disk does not contain data, or important data
has been backed up.
To avoid service exceptions, ensure before formatting that the CVM has stopped external services.

Directions
Please select the appropriate operation guide based on disk capacity:
If the disk capacity is less than 2 TB, please initializing cloud disks.
If the disk capacity is greater than or equal to 2 TB, please initializing cloud disks.

©2013-2022 Tencent Cloud. All rights reserved.

Page 5 of 242

Cloud Virtual Machine

Formatting & Mounting Data Disks：

Last updated 2024-01-06 17:38:11

Overview
This document describes how to perform initialization operations such as formatting, partitioning, and creating a filesystem on a Linux CVM data disk.

Notes
Before formatting, ensure that no data is stored on the data disk and that important data has been backed up. Afterformatting, all data on the data disk will be cleared.
To prevent service exceptions, ensure that the CVM has stopped providing external services before formatting.

Directions
Follow the appropriate operation guide based on the disk capacity.
If the disk capacity is less than 2 TB, follow the instructions under Initializing Cloud Disks (Linux).
If the disk capacity is 2 TB or more, follow the instructions under Initializing Cloud Disks (Linux).

©2013-2022 Tencent Cloud. All rights reserved.

Page 6 of 242

Cloud Virtual Machine

Reading/Writing EXT Data Disks after
Reinstalling a Linux CVM to Windows CVM：

Last updated 2024-01-06 17:38:11

Scenario
Windows employs two major file systems, NTFS or FAT32, while EXT is the de factor file system for Linux. When an
operating system is changed from Linux to Windows after reinstallation, the data disk remains in its original format.
Therefore, the system might not be able to access data disk’s file system. In these cases, you will need to use a format
converter to read the data disk.
This document describes how to read a data disk when the operating system has been reinstalled from Linux toWindows.

Prerequisites
DiskInternals Linux Reader has been installed on the reinstalled Windows CVM.
Download DiskInternals Linux Reader: http://www.diskinternals.com/download/Linux_Reader.exe .
Suppose the data disk mounted to the Linux CVM before reinstallation has two partitions, vdb1 and vdb2, as shown
below:

Directions
Mounting a data diskNote:©2013-2022 Tencent Cloud. All rights reserved.

Page 7 of 242

Cloud Virtual Machine

If a data disk has been mounted, skip this step.
1. Log in to the Tencent Cloud CVM Console.
2. Click Cloud Block Storage from the left sidebar to enter the Cloud Block Storage management page.
3. Locate the instance with the reinstalled system, and click More > Mount on the right as shown below:

4. In the pop-up window, select the reinstalled Windows CVM and click Submit.

Viewing data disk information
1. Run DiskInternals Linux Reader to view the information of newly mounted data disk. /root/mnt and/root/mnt1 correspond to vdb1 and vdb2 respectively, which are the 2 data disk partitions on the Linux CVM
before reinstallation as shown below:
Note:
Note that the Linux data disk is read-only at this time. To perform read and write operations on the data disk as you do
on a Windows data disk, back up your needed files and re-format the disk into a standard Windows-supported filesystem. For more information, please see Data Disk Partition and Formatting of Windows CVMs.

2. Double-click to enter /root/mnt directory, right-click the file you want to copy, and select Save as shown
below:©2013-2022 Tencent Cloud. All rights reserved.

Page 8 of 242

Cloud Virtual Machine©2013-2022 Tencent Cloud. All rights reserved.

Page 9 of 242

Cloud Virtual Machine

Read/Write of the Original NTFS Data Disk
After the Operating System Is Changed from
Windows to Linux：Last updated 2024-01-06 17:38:11

Overview
Windows file system typically uses NTFS or FAT32 format, while Linux file system often uses EXT series format.
When the operating system of a CVM is reinstalled from Windows to Linux, the data disk of the CVM remains in theformat of the original operating system. As a result, after the system reinstallation, the CVM might be unable to accessthe data disk file system. This document describes how to read a data disk in the original Windows system after theoperating system is reinsalled from Windows to Linux.

Directions
Installing NTFS software on a Linux CVM
1. Log in to the Linux CVM after reinstallation.
2. Run the following command to install the ntfsprogs software to enable the Linux CVM to support access to the
NTFS file system.
Note:This document takes CentOS as an example. Different types of Linux systems have different installation commands.
Please use the corresponding installation commands.

©2013-2022 Tencent Cloud. All rights reserved.

Page 10 of 242

Cloud Virtual Machine

yum install-y ntfsprogs

Attaching a data disk from the Windows CVM to the Linux CVM
Note:
If the data disk in your Windows CVM has been attached to the Linux CVM, skip this operation.
If you want to attach a new data disk to the reinstalled Linux CVM, please Initialize Cloud Disks.
1. Log in to the CVM console.
2. In the left sidebar, click Cloud Block Storage to enter the Cloud Block Storage management page.

©2013-2022 Tencent Cloud. All rights reserved.

Page 11 of 242

Cloud Virtual Machine

3. Select the target Windows data disk. Click More > Attach.

4. In the pop-up window, choose the target Linux CVM, and click OK.
5. Log in to the Linux CVM to which the Windows data disk has been attached.
6. Run the following command to query the data disk attached from the Windows CVM.

©2013-2022 Tencent Cloud. All rights reserved.

Page 12 of 242

Cloud Virtual Machineparted -l
A message similar to the one below is returned:©2013-2022 Tencent Cloud. All rights reserved.

Page 13 of 242

Cloud Virtual Machine

Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start
End
Size
File system
1
17.4kB 134MB
134MB
2
135MB
53.7GB 53.6GB ntfs

Name
Microsoft reserved partition
Basic data partition

Flags
msftres

7. Run the following command to attach the data disk.

©2013-2022 Tencent Cloud. All rights reserved.

Page 14 of 242

Cloud Virtual Machine

mount -t ntfs-3g Data disk path Mount point
For example, if you need to attach the data disk in /dev/vdb2 to /mnt , run the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 15 of 242

Cloud Virtual Machine

mount -t ntfs-3g /dev/vdb2 /mnt
Since the file system is identifiable, Linux system can directly perform read and write operations on the attached data
disk.

©2013-2022 Tencent Cloud. All rights reserved.

Page 16 of 242

Cloud Virtual Machine

Environment Configurations
Linux Power Management Configuration：

Last updated 2024-01-06 17:38:11

Introduction
x86 machines use two power management methods, APM (Advanced Power Management) and ACPI (Advanced
Configuration and Power Interface). ACPI is a power management standard jointly developed by Intel, Microsoft, andToshiba, which provides a more flexible interface for computer and device management, whereas APM is the oldpower management standard.
Linux supports APM and ACPI, but the two standards cannot run simultaneously. Linux runs ACPI by default. Tencent
Cloud also recommends ACPI.
If ACPI is not installed in a Linux system, the soft shutdown will fail. This document describes how to check whether
ACPI has been installed and if not, how to install it.

Notes
For CoreOS, there is no need to install ACPI.

Directions
1. Execute the following command to see if ACPI has been installed.

©2013-2022 Tencent Cloud. All rights reserved.

Page 17 of 242

Cloud Virtual Machine

ps -ef|grep -w "acpid"|grep -v "grep"
If there is no process running, it means ACPI has not been installed. Please go to the next step.
If there is a process running, it means ACPI has been installed.
2. Execute the following command to install ACPI.
For Ubuntu or Debian:©2013-2022 Tencent Cloud. All rights reserved.

Page 18 of 242

Cloud Virtual Machinesudo apt-get install acpid
For Redhat or CentOS:©2013-2022 Tencent Cloud. All rights reserved.

Page 19 of 242

Cloud Virtual Machine

yum install acpid
For SUSE:©2013-2022 Tencent Cloud. All rights reserved.

Page 20 of 242

Cloud Virtual Machine

in apcid©2013-2022 Tencent Cloud. All rights reserved.

Page 21 of 242

Cloud Virtual Machine

Modifying etc/hosts Configuration of Linux
Instance：

Last updated 2024-01-06 17:38:11

Overview
From March 1, 2018, the Linux public image provided by Tencent Cloud has the open-source tool Cloud-Init preinstalled, and all initialization operations on an instance are done via Cloud-Init, making operations inside the instancemore transparent. For more information, see Cloud-Init and Cloudbase-Init.
In each launch, Cloud-Init generates a new /etc/hosts file according to the/etc/cloud/templates/hosts.${os_type}.tmpl template and overwrites the original /etc/hosts
file of the instance involved. Hence, after you manually modify the internal /etc/hosts configuration of theinstance and restart it, the /etc/hosts configuration goes back to the original default configuration.

Precautions
Tencent Cloud has fixed this problem for instances created by using a public image after September 2018, and the/etc/hosts configuration will not be overwritten.
For instance created before September 2018, follow the steps below for modification.

Directions
Solution 1
1. Log in to the Linux CVM.
2. Execute the following command to change the - update_etc_hosts in the /etc/cloud/cloud.cfg
configuration file to - ['update-etc-hosts', 'once-per-instance'] :©2013-2022 Tencent Cloud. All rights reserved.

Page 22 of 242

Cloud Virtual Machine

sed -i "/update_etc_hosts/c \\ - ['update_etc_hosts', 'once-per-instance']" /etc/cl
3. Execute the following command to create a config_update_etc_hosts file under the/var/lib/cloud/instance/sem/ path:©2013-2022 Tencent Cloud. All rights reserved.

Page 23 of 242

Cloud Virtual Machine

touch /var/lib/cloud/instance/sem/config_update_etc_hosts

Solution 2
Note:This solution takes the CentOS 7.2 operating system as an example.
Obtaining the hosts template file path
1. Log in to the Linux CVM.

©2013-2022 Tencent Cloud. All rights reserved.

Page 24 of 242

Cloud Virtual Machine

2. Execute the following command to view the system hosts template file:cat /etc/hosts
The hosts template file is as shown in the following figure:©2013-2022 Tencent Cloud. All rights reserved.

Page 25 of 242

Cloud Virtual Machine

Modifying the hosts template file
Note:
Taking adding 127.0.0.1 test test as an example, you can modify the hosts template and/etc/hosts file as needed.
1. Execute the following command to modify the hosts template file:©2013-2022 Tencent Cloud. All rights reserved.

Page 26 of 242

Cloud Virtual Machine

vim /etc/cloud/templates/hosts.redhat.tmpl
2. Press i to switch to the editing mode.
3. Add the following content to the end of the file:©2013-2022 Tencent Cloud. All rights reserved.

Page 27 of 242

Cloud Virtual Machine

127.0.0.1 test test
4. Press Esc and enter :wq to save and close the file.
Modifying the /etc/hosts file
1. Execute the following command to modify the /etc/hosts file:©2013-2022 Tencent Cloud. All rights reserved.

Page 28 of 242

Cloud Virtual Machine

vim /etc/hosts
2. Press i to switch to the editing mode.
3. Add the following content to the end of the file:©2013-2022 Tencent Cloud. All rights reserved.

Page 29 of 242

Cloud Virtual Machine

127.0.0.1 test test
4. Press Esc and enter :wq to save and close the file.

©2013-2022 Tencent Cloud. All rights reserved.

Page 30 of 242

Cloud Virtual Machine

Installing Software
Accelerating Software Package Downloading
and Updating with Tencent Cloud Software
Source：Last updated 2024-01-06 17:38:11

Overview
To solve the problem of slow access to official sources when installing dependencies, Tencent Cloud has set up acache service for some software. You can accelerate the installation of dependencies by using the Tencent Cloudsoftware repository, which currently supports public network access and private network access.
Public network access address: http://mirrors.tencent.com
Private network access address: http://mirrors.tencentyun.com/
Note:
This document takes the public network access address of the Tencent Cloud software repository as an example tointroduce how to use the software sources in the Tencent Cloud software repository in CVM. If you access therepository using a private network, please replace the public network access address with the private network
access address.
The source address used in this document is for reference only. Please obtain the latest address from the Tencent
Cloud software repository.

Notes
The Tencent Cloud software repository updates software sources from the official website of each software source
once per day.

Prerequisites
Log in to the CVM.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 31 of 242

Cloud Virtual Machine

Accelerating pip using the Tencent Cloud image source
Note:
Before using the Tencent Cloud image source, please confirm your CVM has Python installed.
Use the software source path temporarily
Execute the following command to install pip using Tencent Could PyPI.

pip install pip -i

the directory where PyPI is located in©2013-2022 Tencent Cloud. All rights reserved.

Page 32 of 242

Cloud Virtual Machine

For example, if you want to install the 17monip package, and the PyPI you need to use is in the
http://mirrors.tencent.com/pypi/simple directory, run the following command:

pip install 17monip -i http://mirrors.tencent.com/pypi/simple --trusted-host mirror

Set the default software source path
Execute the following command to modify the index-url parameter in the ~/.pip/pip.conf file to thesource path of the Tencent Cloud software repository.

©2013-2022 Tencent Cloud. All rights reserved.

Page 33 of 242

Cloud Virtual Machine[global]index-url = the directory where PyPI is located intrusted-host = public network/private network access address
For example, if the PyPI you need to use is in the http://mirrors.tencent.com/pypi/simple directory,
execute the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 34 of 242

Cloud Virtual Machine[global]index-url = http://mirrors.tencent.com/pypi/simple
trusted-host = mirrors.tencent.com

Accelerating Maven using the Tencent Cloud image source
Note:
Before using the Tencent Cloud image source, please confirm your CVM has JDK and Maven installed.
1. Open the settings.xml configuration file of Maven.

©2013-2022 Tencent Cloud. All rights reserved.

Page 35 of 242

Cloud Virtual Machine

2. Find the <mirrors> ... </ mirrors> code block and configure the following content into it.

<mirror><id>nexus-tencentyun</id><mirrorOf>*</mirrorOf><name>Nexus tencentyun</name><url>http://mirrors.tencent.com/nexus/repository/maven-public/</url></mirror>

Accelerating NPM using the Tencent Cloud image source©2013-2022 Tencent Cloud. All rights reserved.

Page 36 of 242

Cloud Virtual Machine

Note:
Before using the Tencent Cloud image source, please confirm your CVM has Node.js and NPM installed.
Execute the following command to install NPM using the Tencent Cloud NPM.

npm config set registry http://mirrors.tencent.com/npm/

Accelerating Docker using the Tencent Cloud image source
Using Tencent Cloud Docker on the TKE cluster©2013-2022 Tencent Cloud. All rights reserved.

Page 37 of 242

Cloud Virtual Machine

No manual configuration is required. When the CVM in the Tencent Kubernetes Engine (TKE) cluster creates a node,Docker will be installed automatically and configured with the Tencent Cloud private network image.
Using Tencent Cloud Docker on CVM
Note:
Before using the Tencent Cloud Docker, please confirm your CVM has Docker installed.
Only Docker 1.3.2 or later versions support the Docker Hub Mirror mechanism. If you have not installed Docker 1.3.2
or later versions, or if the installed version is too old, please install or upgrade it first.
Choose different operation steps based on the operating system of the CVM.
The following steps are for Ubuntu 14.04, Debian, CentOS 6, Fedora, openSUSE, and other operating systems. The
specific steps for other versions of operating systems may vary:
1.1 Execute the following command to open the /etc/default/docker configuration file.

©2013-2022 Tencent Cloud. All rights reserved.

Page 38 of 242

Cloud Virtual Machine

vim /etc/default/docker
1.2 Press i to switch to the editing mode, enter the following content, and save.

©2013-2022 Tencent Cloud. All rights reserved.

Page 39 of 242

Cloud Virtual Machine

DOCKER_OPTS="--registry-mirror=https://mirror.ccs.tencentyun.com"
For Centos 7:
1.1 Execute the following command to open the /etc/docker/daemon.json configuration file.

©2013-2022 Tencent Cloud. All rights reserved.

Page 40 of 242

Cloud Virtual Machine

vim /etc/docker/daemon.json
1.2 Press i to switch to the editing mode, enter the following content, and save.

©2013-2022 Tencent Cloud. All rights reserved.

Page 41 of 242

Cloud Virtual Machine{"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]}
For Windows with Boot2Docker installed:
1.1 Access the Boot2Docker Start Shell and execute the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 42 of 242

Cloud Virtual Machinesudo su echo "EXTRA_ARGS=\\"–registry-mirror=https://mirror.ccs.tencentyun.com\\""
1.2 Restart Boot2Docker.

Accelerating MariaDB using the Tencent Cloud image
Note:
The following steps take CentOS 7 as an example. Specific steps vary by operating system.
1. Execute the following command to create the MariaDB.repo file under /etc/yum.repos.d/ .

©2013-2022 Tencent Cloud. All rights reserved.

Page 43 of 242

Cloud Virtual Machinevi /etc/yum.repos.d/MariaDB.repo
2. Press i to switch to the editing mode, enter the following content, and save.

©2013-2022 Tencent Cloud. All rights reserved.

Page 44 of 242

Cloud Virtual Machine# MariaDB 10.2 CentOS7-amd64[mariadb]name = MariaDB
baseurl = http://mirrors.tencent.com/mariadb/yum/10.2/centos7-amd64/
gpgkey = http://mirrors.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
3. Execute the following command to empty the YUM cache.

©2013-2022 Tencent Cloud. All rights reserved.

Page 45 of 242

Cloud Virtual Machine

yum clean all
4. Execute the following command to install MariaDB.

©2013-2022 Tencent Cloud. All rights reserved.

Page 46 of 242

Cloud Virtual Machine

yum install MariaDB-client MariaDB-server

Accelerating MongoDB using the Tencent Cloud image
Note:
The following steps take MongoDB 4.0 as an example. If you need to install another version, please change theversion number in the mirror path.
Using Tencent Cloud MongoDB on CVMs with CentOS or Redhat systems©2013-2022 Tencent Cloud. All rights reserved.

Page 47 of 242

Cloud Virtual Machine

1. Execute the following command to create the mongodb.repo file under /etc/yum.repos.d/ .

vi /etc/yum.repos.d/mongodb.repo
2. Press i to switch to the editing mode, enter the following content, and save.

©2013-2022 Tencent Cloud. All rights reserved.

Page 48 of 242

Cloud Virtual Machine[mongodb-org-4.0]
name=MongoDB Repository
baseurl=http://mirrors.tencent.com/mongodb/yum/el7-4.0
gpgcheck=0
enabled=1
3. Execute the following command to install MongoDB.

©2013-2022 Tencent Cloud. All rights reserved.

Page 49 of 242

Cloud Virtual Machine

yum install -y mongodb-org

Using Tencent Cloud MongoDB on CVMs with the Debian system
1. Based on the different Debian versions, execute the following command to import the MongoDB GPG public key.

©2013-2022 Tencent Cloud. All rights reserved.

Page 50 of 242

Cloud Virtual Machinesudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 68818C72E52529D4
2. Execute the following command to configure the mirror path.

©2013-2022 Tencent Cloud. All rights reserved.

Page 51 of 242

Cloud Virtual Machine#Debian 8
echo "deb http://mirrors.tencent.com/mongodb/apt/debian jessie/mongodb-org/4.0 main
#Debian 9
echo "deb http://mirrors.tencent.com/mongodb/apt/debian stretch/mongodb-org/4.0 mai
3. Run the following command to clear the cache.

©2013-2022 Tencent Cloud. All rights reserved.

Page 52 of 242

Cloud Virtual Machinesudo apt-get clean all
4. Run the following command to update the software package list.

©2013-2022 Tencent Cloud. All rights reserved.

Page 53 of 242

Cloud Virtual Machinesudo apt-get update
5. Execute the following command to install MongoDB.

©2013-2022 Tencent Cloud. All rights reserved.

Page 54 of 242

Cloud Virtual Machinesudo apt-get install -y mongodb-org

Using Tencent Cloud MongoDB on CVMs with the Ubuntu system
1. Execute the following command to import the MongoDB GPG public key.

©2013-2022 Tencent Cloud. All rights reserved.

Page 55 of 242

Cloud Virtual Machinesudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 68818C72E52529D4
2. Execute the following command to configure the mirror path.

©2013-2022 Tencent Cloud. All rights reserved.

Page 56 of 242

Cloud Virtual Machine#Ubuntu 14.04
echo "deb [ arch=amd64 ] http://mirrors.tencent.com/mongodb/apt/ubuntu trusty/mongo#Ubuntu 16.04
echo "deb [ arch=amd64 ] http://mirrors.tencent.com/mongodb/apt/ubuntu xenial/mongo#Ubuntu 18.04
echo "deb [ arch=amd64 ] http://mirrors.tencent.com/mongodb/apt/ubuntu bionic/mongo
3. Run the following command to clear the cache.

©2013-2022 Tencent Cloud. All rights reserved.

Page 57 of 242

Cloud Virtual Machinesudo apt-get clean all
4. Run the following command to update the software package list.

©2013-2022 Tencent Cloud. All rights reserved.

Page 58 of 242

Cloud Virtual Machinesudo apt-get update
5. Execute the following command to install MongoDB.

©2013-2022 Tencent Cloud. All rights reserved.

Page 59 of 242

Cloud Virtual Machinesudo apt-get install -y mongodb-org

Accelerating Rubygems using the Tencent Cloud image source
Note:
Before using the Tencent Cloud image source, please confirm your CVM has Ruby installed.
Execute the following command to modify the RubyGems source address.

©2013-2022 Tencent Cloud. All rights reserved.

Page 60 of 242

Cloud Virtual Machine

gem source -r https://rubygems.org/
gem source -a http://mirrors.tencent.com/rubygems/©2013-2022 Tencent Cloud. All rights reserved.

Page 61 of 242

Cloud Virtual Machine

Installing Software via Apt-get (Ubuntu)：

Last updated 2024-01-06 17:38:11

Introduction
Advanced Package Tool (APT) is a free software user interface that works with core libraries to handle the installation
and removal of software on various Linux distributions. APT offers a centralized interface for software management
and a better experience than having to download and install software one by one. Tencent Cloud hosts APT sources
so you can install software without adding sources.

Prerequisites
Log in to a Linux CVM instance that runs Ubuntu.

Directions
Note:
In the following, Nginx is used as an example.

Listing available software
Run the following command to list available software:©2013-2022 Tencent Cloud. All rights reserved.

Page 62 of 242

Cloud Virtual Machinesudo apt-cache search all

Installing software
Run the following command to install Nginx:©2013-2022 Tencent Cloud. All rights reserved.

Page 63 of 242

Cloud Virtual Machinesudo apt-get install nginx
Make sure this is the software you want to install and enter Y to approve the installation. Wait until the software
installation is complete, as shown in the figure below:©2013-2022 Tencent Cloud. All rights reserved.

Page 64 of 242

Cloud Virtual Machine

Querying installed software
You can run different commands to query installed software.
Run the following command to query the directory of the software package and all the files in the software package.

©2013-2022 Tencent Cloud. All rights reserved.

Page 65 of 242

Cloud Virtual Machinesudo dpkg -L software_name
Run the following command to query the version information of the software package.

©2013-2022 Tencent Cloud. All rights reserved.

Page 66 of 242

Cloud Virtual Machinesudo dpkg -l software_nameView information on the installed Nginx, as shown in the figure below:©2013-2022 Tencent Cloud. All rights reserved.

Page 67 of 242

Cloud Virtual Machine©2013-2022 Tencent Cloud. All rights reserved.

Page 68 of 242

Cloud Virtual Machine

Installing Software via YUM (CentOS)：

Last updated 2024-01-06 17:38:11

Overview
YUM (Yellowdog Updater, Modified) allows you to easily download and install software, and simplifies yourinstallations on a CVM instance, saving you time and efforts. With it, you only need to run the yum command to
install software in the CentOS environment. Tencent Cloud provides a YUM repository so you can directly install
software packages without adding sources.

Directions
Installing software
Log in to your CVM instance with the root account and run the following commands to install software according to theoperating system of your CVM.
CentOS 8 or later versions
1. Run the following command to install software.

©2013-2022 Tencent Cloud. All rights reserved.

Page 69 of 242

Cloud Virtual Machine

dnf install [software name]
The system will automatically search for the relevant software package and dependencies, and ask for yourconfirmation.
For example, after you run the dnf install php command to install PHP, the following prompt will appear:©2013-2022 Tencent Cloud. All rights reserved.

Page 70 of 242

Cloud Virtual Machine

2. Confirm that the software package is correct. Enter y and press Enter to start the installation.
The Complete prompt indicates the installation is completed.
CentOS 7 or earlier versions
1. Run the following command to install software.
Note:
Starting from CentOS 7, MariaDB has become the default database in the YUM repository. If you are using CentOS 7
or later versions, MySQL installed using yum will be unusable. You can use the fully compatible MariaDB, or click
here to learn about how to install an older version of MySQL.

©2013-2022 Tencent Cloud. All rights reserved.

Page 71 of 242

Cloud Virtual Machine

yum install [software name]
The system will automatically search for the relevant software package and dependencies, and ask for yourconfirmation.
For example, after you run the yum install PHP command to install PHP, the following prompt will appear:©2013-2022 Tencent Cloud. All rights reserved.

Page 72 of 242

Cloud Virtual Machine

2. Confirm that the software package is correct. Enter y and press Enter to start the installation.
The Complete prompt indicates the installation is completed.

Viewing installed software information
After software installation is completed, you can run different commands to view related information.
View the installation directory of a software package©2013-2022 Tencent Cloud. All rights reserved.

Page 73 of 242

Cloud Virtual Machine

rpm -ql [software name]For example, run rpm -ql php to view the installation directory of PHP, as shown in the figure below:©2013-2022 Tencent Cloud. All rights reserved.

Page 74 of 242

Cloud Virtual Machine

View the version of the software package

rpm -q©2013-2022 Tencent Cloud. All rights reserved.

Page 75 of 242

Cloud Virtual Machine

For example, run rpm -q php to view the version of PHP, as shown in the figure below:©2013-2022 Tencent Cloud. All rights reserved.

Page 76 of 242

Cloud Virtual Machine

Installing Software via zypper (SUSE)：

Last updated 2024-01-06 17:38:11
Make sure that you have followed the steps in Installing Software via YAST in SUSE Environment install thenecessary software.

1. Configuration of nginx
1. Start nginx service
Start the nginx with the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 77 of 242

Cloud Virtual Machineservice nginx restart
2. Test whether nginx service is working properly
Test with the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 78 of 242

Cloud Virtual Machine

wget http://127.0.0.1
If the result is as shown below and displays "'index.html' saved" at the end, it means the nginx service is working
properly.

©2013-2022 Tencent Cloud. All rights reserved.

Page 79 of 242

Cloud Virtual Machine--2013-02-20 17:07:26-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 151 [text/html]
Saving to: 'index.html'
100%[==============================================================================
2013-02-20 17:07:26 (37.9 MB/s) - 'index.html' saved [151/151]
3. In the browser, visit the Public IP of CentOS CVM to check if the nginx service is working properly.
The appearance of the following page indicates that nginx has been installed and configured successfully.

©2013-2022 Tencent Cloud. All rights reserved.

Page 80 of 242

Cloud Virtual Machine

2. Configuration of PHP
1. Create a new configuration file php-fpm.conf with the following command:

vim /etc/php5/fpm/php-fpm.conf
Write the following:©2013-2022 Tencent Cloud. All rights reserved.

Page 81 of 242

Cloud Virtual Machine[global]error_log = /var/log/php-fpm.log[www]user = nobody
group = nobody
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3©2013-2022 Tencent Cloud. All rights reserved.

Page 82 of 242

Cloud Virtual Machine

3. Start services
Start all services with the following commands:/etc/init.d/mysql start; /etc/init.d/php-fpm start; /etc/init.d/nginx start
Example:©2013-2022 Tencent Cloud. All rights reserved.

Page 83 of 242

Cloud Virtual Machine

4. Environment configuration validation
Create index.php under a web directory using the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 84 of 242

Cloud Virtual Machine

vim /usr/share/nginx/html/index.php
Write the following:<?php
echo "<title>Test Page</title>";echo "hello world";?>
In the browser, visit the Public IP of SUSE CVM to check whether the environment configuration is successful. If the
webpage shows "hello world", it means the configuration is successful.

©2013-2022 Tencent Cloud. All rights reserved.

Page 85 of 242

Cloud Virtual Machine

Switching CentOS 6 Source to YUM
Repository：

Last updated 2024-01-06 17:38:11

Overview
The CentOS 6 is an end-of-life (EOL) operating system since November 30, 2020, and no longer maintained by theLinux community. Therefore, the CentOS 6 source is unavailable in http://mirror.centos.org/centos6/ , a third-party image site, or Tencent Cloud at http://mirrors.tencent.com/ andhttp://mirrors.tencentyun.com/ . If you continue to use the default CentOS 6 source configured inTencent Cloud, an error may occur.
Note:
Upgrading your operating system to CentOS 7 or a later version is recommended. If you still need to use the CentOS 6
dependencies during the transition period, switch the CentOS 6 source as instructed below.

Directions
1. Log in to the Linux instance. Logging in via Web Shell is recommended.. You can also use other login methods as
required.
Logging In to Linux Instances (Remote Login)
Logging In to Linux Instance (SSH Key)
2. Run the following command to check the CentOS version of the current operating system.

©2013-2022 Tencent Cloud. All rights reserved.

Page 86 of 242

Cloud Virtual Machinecat /etc/centos-release
If the result as shown in the following figure is returned, the operating system version is CentOS 6.9.

3. Run the following command to edit the CentOS-Base.repo file.

©2013-2022 Tencent Cloud. All rights reserved.

Page 87 of 242

Cloud Virtual Machine

vim /etc/yum.repos.d/CentOS-Base.repo
4. Press i to enter edit mode and modify baseurl according to the CentOS version and network environment.
Note:
See Private Network Access and Internet Access to determine the required source:
Source for private network access: http://mirrors.tencentyun.com/centos-vault/6.x/
Source for public network access: http://mirrors.tencent.com/centos-vault/6.x/
This document uses CentOS 6.9 that requires a private network access as an example. The modified CentOSBase.repo file is as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 88 of 242

Cloud Virtual Machine

You can configure as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 89 of 242

Cloud Virtual Machine[extras]gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-6
enabled=1
baseurl=http://mirrors.tencentyun.com/centos-vault/6.9/extras/$basearch/
name=Qcloud centos extras - $basearch[os]gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-6
enabled=1
baseurl=http://mirrors.tencentyun.com/centos-vault/6.9/os/$basearch/©2013-2022 Tencent Cloud. All rights reserved.

Page 90 of 242

Cloud Virtual Machine

name=Qcloud centos os - $basearch[updates]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-6
enabled=1
baseurl=http://mirrors.tencentyun.com/centos-vault/6.9/updates/$basearch/
name=Qcloud centos updates - $basearch
5. Press ESC, enter :wq, and press Enter to save the modification.
6. Run the following command to modify the CentOS-Epel.repo file.

©2013-2022 Tencent Cloud. All rights reserved.

Page 91 of 242

Cloud Virtual Machine

vim /etc/yum.repos.d/CentOS-Epel.repo
7. Press i to enter edit mode and modify baseurl based on the network environment.
In this example, change baseurl=http://mirrors.tencentyun.com/epel/$releasever/$basearch/
to baseurl=http://mirrors.tencentyun.com/epel-archive/6/$basearch/ . The result is as follows:

You can configure as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 92 of 242

Cloud Virtual Machine[epel]
name=epel for redhat/centos $releasever - $basearch
failovermethod=priority
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/epel/RPM-GPG-KEY-EPEL-6
enabled=1
baseurl=http://mirrors.tencentyun.com/epel-archive/6/$basearch/
8. Press ESC, enter :wq, and press Enter to save the modification.
9. Now you can use the yum install command to install the required software.

©2013-2022 Tencent Cloud. All rights reserved.

Page 93 of 242

Cloud Virtual Machine

Installing chronyd Service on CentOS 8：

Last updated 2024-01-06 17:38:11

Overview
Currently, native CentOS 8 does not support setting the NTP service. Instead, you need to use chronyd to deliveraccurate time. This document describes how to install and configure chronyd on a CentOS 8-based Tencent Cloud
CVM instance.

Directions
Installing and configuring the chronyd service
1. Log in to a Linux instance using standard login method.
2. Run the following command to install the chronyd service.

©2013-2022 Tencent Cloud. All rights reserved.

Page 94 of 242

Cloud Virtual Machine

yum -y install chrony
3. Run the following command to modify the chrony.conf configuration file.

©2013-2022 Tencent Cloud. All rights reserved.

Page 95 of 242

Cloud Virtual Machine

vim /etc/chrony.conf
4. Press i to enter the edit mode, and append the following content to the next line of #log measurements
statistics tracking .

©2013-2022 Tencent Cloud. All rights reserved.

Page 96 of 242

Cloud Virtual Machine

server time1.tencentyun.com iburst
server time2.tencentyun.com iburst
server time3.tencentyun.com iburst
server time4.tencentyun.com iburst
server time5.tencentyun.com iburst
The result should be as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 97 of 242

Cloud Virtual Machine

5. Press Esc and enter :wq to save and close the file.
6. Run the following commands in sequence to enable chronyd autostart and restart it.

©2013-2022 Tencent Cloud. All rights reserved.

Page 98 of 242

Cloud Virtual Machine

systemctl restart chronyd©2013-2022 Tencent Cloud. All rights reserved.

Page 99 of 242

Cloud Virtual Machine

systemctl enable chronyd

Verifying the configurations
1. Run the following command to check whether the clock is synced.

©2013-2022 Tencent Cloud. All rights reserved.

Page 100 of 242

Cloud Virtual Machinedate
2. Run the following command to check the clock source status.

©2013-2022 Tencent Cloud. All rights reserved.

Page 101 of 242

Cloud Virtual Machine

chronyc sourcestats -v
If a result similar to the following is returned, the configuration was successful.

©2013-2022 Tencent Cloud. All rights reserved.

Page 102 of 242

Cloud Virtual Machine

AppendixCommands
Command

Description

chronyc sources -v

Check the clock source.

chronyc sourcestats -v

Check the clock source status.

timedatectl set-local-rtc 1

Set the real time clock. The default format is UTC.

timedatectl set-ntp yes

Enable the NTP service for synchronization.

chronyc tracking

Calibrate the NTP server.

chronyc -a makestep

Force synchronization of the system clock.

©2013-2022 Tencent Cloud. All rights reserved.

Page 103 of 242

Cloud Virtual Machine

User Data
Configuring Custom Data (Linux CVM)：

Last updated 2024-01-06 17:38:11

Overview
When creating a CVM instance, you can configure an instance by specifying custom data. During the first launch of
the CVM, the custom data will be passed into the CVM in text format and be executed. If you purchase multiple CVM
instances at a time, the custom data text will be executed on all CVM instances during their first launch.
This document describes how to transfer a shell script when a CVM instance for Linux is started for the first time.

Notes
Linux operating systems that support custom data include:
64-bit OSs: CentOS 6.8 and later, Ubuntu Server 14.04.1 LTS and later, and openSUSE 42.3 x86
32-bit OSs: CentOS 6.8 and later
A command can be executed by passing text only when a CVM instance is launched for the first time.
The text to be transferred must be Base64-encoded. Perform encoding in a Linux environment to avoid format
incompatibility.
Execute the user input as root . Therefore, the sudo command is not required in the script. The root user
can access all the files you created. If you need to grant other users with the access permission, modify the permission
in the script.
During launch, executing specified tasks in custom data will increase the amount of time it takes to launch the CVM.
We recommend that you wait for a few minutes, and after the tasks are completed, test whether the tasks have beensuccessfully executed.
In this sample, the shell script must start with #! and the path directing to the interpreter of the script to be read(generally starting with /bin/bash ).

Directions
Writing a shell script
1. Run the following command to create a shell script named "script_text.sh".

©2013-2022 Tencent Cloud. All rights reserved.

Page 104 of 242

Cloud Virtual Machinevi script_text.sh
2. Press i to switch to the editing mode, refer to the following content, write it into the file, and save the "script_text.sh"script.

©2013-2022 Tencent Cloud. All rights reserved.

Page 105 of 242

Cloud Virtual Machine#!/bin/bash
echo "Hello Tencent Cloud."Note:
The shell script must start with #! and the path directing to the interpreter of the script to be read (generally startingwith /bin/bash ). For more information on the shell script, see BASH Programming - Introduction HOW-TO.

Base64-encoding the script file
1. Run the following command to Base64-encode the "script_text.sh" script.

©2013-2022 Tencent Cloud. All rights reserved.

Page 106 of 242

Cloud Virtual Machine# Base64-encode the script
base64 script_text.sh
The following information is returned:©2013-2022 Tencent Cloud. All rights reserved.

Page 107 of 242

Cloud Virtual Machine# Result returned after the encoding
IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gVGVuY2VudCBDbG91ZC4iCg==
2. Run the following command to verify the result returned after the script is Base64-encoded.

©2013-2022 Tencent Cloud. All rights reserved.

Page 108 of 242

Cloud Virtual Machine# Base64-decode the returned result to verify the commandecho "IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gVGVuY2VudCBDbG91ZC4iCg==" | base64 -d

Passing text
We provide multiple methods to launch an instance, and here we introduce two of them. Choose a method according
to your requirements:
Using the official website or the console
Using API©2013-2022 Tencent Cloud. All rights reserved.

Page 109 of 242

Cloud Virtual Machine

1. Purchase an instance as instructed in Creating Instances via CVM Purchase Page and click Advanced Settingsin "2. Complete configuration".

2. In the text box in Advanced Settings, enter the encoded result returned in the Base64-encoded script.
For example, the encoded result of the script_text script with Base64 is
IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gVGVuY2VudCBDbG91ZC4iCg== .

©2013-2022 Tencent Cloud. All rights reserved.

Page 110 of 242

Cloud Virtual Machine

3. Follow the prompts on the interface to complete CVM creation.
Note:
CVM will run the script through the open-source software cloud-init. For more information on cloud-init, visit the cloudinit website.
When creating a CVM instance through APIs, you can pass the text by assigning the value of the encoded result
returned in the Base64-encoded script to the UserData parameter of the RunInstances API.
The following is an sample CVM creation request with UserData:©2013-2022 Tencent Cloud. All rights reserved.

Page 111 of 242

Cloud Virtual Machinehttps://cvm.tencentcloudapi.com/?Action=RunInstances&Version=2017-03-12&Placement.Zone=ap-guangzhou-2&ImageId=img-pmqg1cw7&UserData=IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8gVGVuY2VudCBDbG91ZC4iCg==&<Common Request Parameters>

Viewing execution logs
After the CVM instance is created successfully, you can run the following command to view the script execution log:

©2013-2022 Tencent Cloud. All rights reserved.

Page 112 of 242

Cloud Virtual Machinecat /var/log/cloud-init-output.log©2013-2022 Tencent Cloud. All rights reserved.

Page 113 of 242

Cloud Virtual Machine

Setting Custom Data (Windows CVM)：

Last updated 2024-01-06 17:38:11

Overview
When creating a CVM, you can configure an instance by specifying custom data. During the first launch of theCVM, the custom data will be passed into the CVM in text format and be executed. If you purchase multiple CVMs at atime, the custom data text will be executed on all CVMs during their first launch.
This document describes an example in which a PowerShell script is passed during the first launch of a Windows
CVM.

Notes
Windows operating systems that support custom data include:
Windows Server 2019 IDC 64-bit English version
Windows Server 2016 IDC 64-bit English version
Windows Server 2012 R2 IDC 64-bit English version
A command can be executed by passing text only when a CVM is launched for the first time.
Before Base64 encoding, the size of the custom data cannot exceed 16 KB.
Custom data is Base64 encoded and then passed. If you directly copy a non-Base64 script file, do not select “Theentry is Base64-encoded text”.
During launch, executing specified tasks in custom data will increase the amount of time it takes to launch the CVM.
We recommend that you wait for a few minutes, and after the tasks are completed, test whether the tasks have beensuccessfully executed.
In this example, specify the Windows PowerShell script by using the PowerShell label, for example, the <powershell></powershell> label.

Directions
Preparing text
Prepare text based on your actual requirements:
PowerShell script©2013-2022 Tencent Cloud. All rights reserved.

Page 114 of 242

Cloud Virtual Machine

Use the PowerShell label to prepare a PowerShell script.
For example, if you need to create a “tencentcloud.txt” file with the content of “Hello Tencent Cloud.” in the C drive(C:), use the PowerShell label to prepare the following content:<powershell>"Hello Tencent Cloud." | Out-File</powershell>

C:\\tencentcloud.txt

Base64 encoded script
1. Run the following command to create a PowerShell script named “script_text.ps1”.

©2013-2022 Tencent Cloud. All rights reserved.

Page 115 of 242

Cloud Virtual Machinevi script_text.ps1
2. Press i to switch to the editing mode, refer to the following content, write it into the file, and save the“script_text.ps1” script.

©2013-2022 Tencent Cloud. All rights reserved.

Page 116 of 242

Cloud Virtual Machine<powershell>"Hello Tencent Cloud." | Out-File</powershell>

C:\\tencentcloud.txt

3. Run the following command to perform the Base64 encoding operation on the “script_text.ps1” script.

©2013-2022 Tencent Cloud. All rights reserved.

Page 117 of 242

Cloud Virtual Machine

base64 script_text.ps1
The following information is returned:©2013-2022 Tencent Cloud. All rights reserved.

Page 118 of 242

Cloud Virtual Machine

PHBvd2Vyc2hlbGw+CiJIZWxsbyBUZW5jZW50IENsb3VkLiIgfCBPdXQtRmlsZSAgQzpcdGVuY2VudGNsb3V

Passing text
We provide multiple methods to launch an instance, and here we introduce two of them. Choose a method according
to your requirements:
ConsoleAPI©2013-2022 Tencent Cloud. All rights reserved.

Page 119 of 242

Cloud Virtual Machine

1. Purchase an instance (see Creating an Instance), and click Advanced settings under Other settings in 2.
Configure network and host.

2. In Advanced settings, enter the text content you have prepared in the Custom data text box.
PowerShell script: Type in PowerShell script.
Base64 encoded script: Select “The above input is encoded with base64”, and then type in Base64 encoded text.

©2013-2022 Tencent Cloud. All rights reserved.

Page 120 of 242

Cloud Virtual Machine

3. Follow the instruction to complete CVM creation.
When creating a CVM by using API, you can pass the text by assigning the value of the encoded result returned in
Base64 encoded script to the UserData parameter of the RunInstances API.
The following is an sample CVM creation request with UserData:©2013-2022 Tencent Cloud. All rights reserved.

Page 121 of 242

Cloud Virtual Machinehttps://cvm.tencentcloudapi.com/?Action=RunInstances&Version=2017-03-12&Placement.Zone=ap-guangzhou-2&ImageId=img-pmqg1cw7&UserData=PHBvd2Vyc2hlbGw+CiJIZWxsbyBUZW5jZW50IENsb3VkLiIgfCBPdXQtRmlsZSAuXHRlbmNlb&<Common Request Parameters>

Verifying custom data configuration
1. Log in to your CVM.

©2013-2022 Tencent Cloud. All rights reserved.

Page 122 of 242

Cloud Virtual Machine

2. On the operating system interface, open the C drive (C:), and check whether the tencentcloud.txt text file
exists.
If the tencentcloud.txt text file exists, the configuration is successful, as shown in the following figure:Viewing execution logs
You can view the C:\\Program Files\\Cloudbase Solutions\\Cloudbase-Init\\log\\cloudbaseinit.log file to get the execution logs of the script.

©2013-2022 Tencent Cloud. All rights reserved.

Page 123 of 242

Cloud Virtual MachineWork with Operating Systems
System Activation
Activating Windows with slmgr Command：

Last updated 2024-01-06 17:38:11

Overview
This document describes how to activate the operating system in a Windows CVM instance.
Note:
This document is intended only for Windows Server public images provided by Tencent Cloud. It is not applicable forcustom images or images imported from external sources.

Directions
1. Log in to the Windows CVM instance. For more information, see Logging in Using Standard Method(Recommended).
2. Right-click in the lower left corner of the operating system's desktop,, and select Windows PowerShell (Admin) from the pop-up menu.
3. In the PowerShell window, run the following commands in sequence to activate the operating system.

©2013-2022 Tencent Cloud. All rights reserved.

Page 124 of 242

Cloud Virtual Machine

slmgr /upk

©2013-2022 Tencent Cloud. All rights reserved.

Page 125 of 242

Cloud Virtual Machine

slmgr /ipk <ProductKey>©2013-2022 Tencent Cloud. All rights reserved.

Page 126 of 242

Cloud Virtual Machine

slmgr /skms kms.tencentyun.com©2013-2022 Tencent Cloud. All rights reserved.

Page 127 of 242

Cloud Virtual Machine

slmgr /ato
<ProductKey> in the slmgr /ipk <ProductKey> command should be replaced as follows:
Windows Server 2008 R2 Enterprise: 489J6-VHDMP-X63PK-3K798-CPX3Y
Windows Server 2012 R2 Datacenter: W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9Windows Server 2016: CB7KF-BWN84-R7R2Y-793K2-8XDDGWindows Server 2019: WMDGN-G9PQG-XVVXX-R3X43-63DFG： WX4NM-KYWYW-QJJR4-XV3QB-6VM33

Windows Server 2022

For more information, see Key Management Services (KMS) client activation and product keys.

©2013-2022 Tencent Cloud. All rights reserved.

Page 128 of 242

Cloud Virtual Machine

4. Restart the CVM instance to make the settings take effect. For more information, see Restarting Instances.

FAQs
In some scenarios where the Windows operating system is not activated, the system memory of a high-end server will
be limited to 2 GB, and the rest of the memory will be restricted in the form of "hardware reserved memory". The
reason is that the HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\ProductOptions
registry key is damaged. You can run the following command to determine whether to reactivate the system.

©2013-2022 Tencent Cloud. All rights reserved.

Page 129 of 242

Cloud Virtual Machine(Get-ItemProperty HKLM:\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions\\).Prod
If the returned result is above 10,000, such as 56184, there is no need to reactivate the system.
If the returned result is "Unactivated value: 1960", refer to the following methods to solve the problem.
Method 1
Method 2
Method 3
1. Run the following command to activate the operating system.

slmgr.vbs /ipk <ProductKey>©2013-2022 Tencent Cloud. All rights reserved.

Page 130 of 242

Cloud Virtual Machine

Note:
Replace <ProductKey> according to the actual operating system version as detailed in ProductKey.
2. After the command is executed, run the Get-ItemProperty... command again for verification. The returned
value is 56184.
3. Restart the CVM instance to make the settings take effect. For more information, see Restarting Instances.
4. Run the following command to activate the operating system.

slmgr.vbs /ato

©2013-2022 Tencent Cloud. All rights reserved.

Page 131 of 242

Cloud Virtual Machine

1. Run the following command to fix it.

slmgr.vbs /rilc
2. After the command is executed, run the Get-ItemProperty... command again for verification, and thereturned value is still 1960.
3. Run the following command to activate the operating system and restarting CVM.

©2013-2022 Tencent Cloud. All rights reserved.

Page 132 of 242

Cloud Virtual Machine

slmgr.vbs /ato
1. Uninstall any MSI program.
2. Run the Get-ItemProperty... command again for verification, and the returned value may change.
However, after the system is restarted, the memory limit is still 2 GB.
3. Run the following command to activate the operating system and restarting CVM.

©2013-2022 Tencent Cloud. All rights reserved.

Page 133 of 242

Cloud Virtual Machine

slmgr.vbs /ato

©2013-2022 Tencent Cloud. All rights reserved.

Page 134 of 242

Cloud Virtual Machine

Windows Server System Activation：

Last updated 2024-01-06 17:38:11
CVMs use KMS to authorize Windows servers.
Note:
This document is intended only for Windows Server public images provided by Tencent Cloud. It is not applicable forcustom images or images imported from external sources.
Windows Server 2008 and Windows Server 2012 need to be authorized using this method. The default KMS address(kms.tencentyun.com:1668) configured for the public images of Windows Server 2016 and Windows Server 2019 iscorrect and does not need to be modified.

Notes
1. Only the SPP Notification Service in Windows Server 2008 is used for activation. Make sure it runs properly, as
shown in the following figure:

2. Some optimization software may disable modifying the execute permissions of service programs. For example,
modifying the execute permissions of sppsvc.exe might result in exceptions, as shown below:

Before you activate a Windows CVM, make sure that services and other features on the Windows CVM are normal.

©2013-2022 Tencent Cloud. All rights reserved.

Page 135 of 242

Cloud Virtual Machine

Automatic Activation
Tencent Cloud encapsulates a script for activating Windows servers, which simplifies automatic activation. To use theactivation script, follow the steps below:
1. Log in to the Windows CVM.
2. Download the script, and run it to complete automatic activation.

Manual Activation
Notes
An inaccurate system clock will trigger an error during manual activation for some systems. In that case, you need tosynchronize the system clock first by following the steps below:
Note:
If the system clock on the Windows CVM is normal, skip to Activation.
1. Log in to the Windows CVM.
2. On the desktop, choose Start > Run. Enter cmd.exe in the Run dialog box to open the console window.
3. In the console window, run the following commands in sequence to synchronize the system clock:©2013-2022 Tencent Cloud. All rights reserved.

Page 136 of 242

Cloud Virtual Machine

w32tm /config /syncfromflags:manual /manualpeerlist:"ntpupdate.tencentyun.com"
w32tm /resync

Activation directions
1. Log in to the Windows CVM.
2. On the desktop, choose Start > Run. Enter cmd.exe in the Run dialog box to open the console window.
3. In the console window, run the following commands in sequence to complete manual activation:©2013-2022 Tencent Cloud. All rights reserved.

Page 137 of 242

Cloud Virtual Machine

cscript /nologo %windir%/system32/slmgr.vbs -skms kms.tencentyun.com:1688
cscript /nologo %windir%/system32/slmgr.vbs -ato©2013-2022 Tencent Cloud. All rights reserved.

Page 138 of 242

Cloud Virtual Machine

System Updates：

Last updated 2024-01-06 17:38:11

Introduction
This article uses Windows Server 2012 as an example to illustrate how to update your Windows operating system.

Directions
Updating Windows using the public network
You can use the Windows Update service to update your operating system. The detailed steps are as follows:
1. Log in to the Windows CVM instance.
2. Click-> Control Panel -> Windows Update. The Windows Update window appears.
3. Click Check for updates, and wait until the check is finished.
4. After the check is finished, click N Important Updates Available or N Optional Updates Available in “Windows
Update”. The Choose the Update to Install window appears.
5. Select the updates you want to install, and click Install.
If you are prompted to restart your system after the update is completed, do so.
Note:
If you log in using VNC after the instance is rebooted and the message "Updating...Do not turn off the power" or"Configuration has not been completed" appears, do not perform a force-shutdown. That may damage your CVM
instance.

Updating Windows using the private network
If your CVM instance does not have public network access, you can use the Tencent Cloud private Windows Update
server to update your operating system. The Tencent Cloud Windows Update server has most of the updates, butdoes not have hardware driver packages and some uncommon updates. Therefore, uncommon services may not get
updates using the Tencent Cloud Windows Update server.
Follow these steps to use the Tencent Cloud Windows Update server:
1. Log in to the Windows CVM instance.
2. Use Internet Explorer to download the Tencent Cloud private network configuration file wusin.bat from the following
address:©2013-2022 Tencent Cloud. All rights reserved.

Page 139 of 242

Cloud Virtual Machine

http://mirrors.tencentyun.com/install/windows/wusin.bat
3. Run wusin.bat in Command Prompt with administrator privilege, as shown below:
Note:
If you open wusin.bat using Internet Explorer after it finishes downloading, the console window will automatically closeand you cannot observe the output.
You can save wusin.bat to your hard drive, such as C:, and open a Command Prompt window with administrator
privilege to run it.
If you no longer wish to use the Tencent Cloud Windows Update server, you can download wusout.bat clean it up.
Follow these steps to do so:
1. Log in to the Windows CVM instance.
2. Use Internet Explorer to download the Tencent Cloud private network configuration file wusout.bat from thefollowing address:
http://mirrors.tencentyun.com/install/windows/wusout.bat
3. Run wusout.bat in Command Prompt with administrator privilege, as shown below:
Note:
If you open wusout.bat using Internet Explorer after it finishes downloading, the console window will automaticallyclose and you cannot observe the output information.
You can save wusout.bat to your hard drive, such as C:, and open a Command Prompt window with administrator
privilege to run it.

©2013-2022 Tencent Cloud. All rights reserved.

Page 140 of 242

Cloud Virtual Machine

System Shutdown：

Last updated 2024-01-06 17:38:11

CVM Shutdown Process Analysis
Shutdown process
Note:
See Shutdown Instances for related operations.
The shutdown process of a Tencent Cloud Windows instance is as follows:
1. The host sends the shutdown command via libvirt on the QMP protocol to the qemu component.
2. The qemu component transfers the shutdown command to the CVM by interrupting ACPI (for more information,
see technical documents on VMCS).
3. After receiving the shutdown signal, the Windows instance exits the applications and the service processes.
4. Close the core service process.
5. Turn off the power.
Note:
The sequence of closing the applications and the services in step 3-4 may vary by the system settings.
Windows is a closed-source system. It provides APIs that allow kernel-mode and user-mode programs to intervene in
the shutdown process. Some running Windows services will also affect the shutdown process, increase the shutdown
time, and cause shutdown failure.

Forced shutdown
In a virtualization scenario, in addition to shutdown methods such as the soft shutdown initialized by the system signal
and message notification, you can also force the CVM to shut down via forced shutdown.
The forced shutdown may affect Windows and the user experience in the following two aspects:
1. A forced shutdown interrupts some services and applications and causes abnormal operations such as unsaved
documents and unfinished WindowsUpdate processes.
2. During the shutdown process, the NTFS system (or the earlier FAT32 system) of Windows writes key data to the
disk. A forced shutdown may result in write failure and cause Windows to believe the NTFS file system is damaged.
Therefore, we recommend that you first use soft shutdown on a Windows instance.

Shutdown Failure Scenarios
The Windows system may have issues that affect the shutdown process and cause shutdown failure, including but notlimited to:©2013-2022 Tencent Cloud. All rights reserved.

Page 141 of 242

Cloud Virtual Machine

1. A WindowsUpdate process may prolong the shutdown time. The Windows system may perform patch operations
during the shutdown process and prompt a message like "Please do not power off or unplug your computer".
2. If the Windows system has the "Shutdown Event Tracker" mechanism enabled and needs to shutdown due to any
system service or driver error, the system will require the user to submit an error description based on theconfiguration. The system will wait for you to complete these operations before shutdown.
3. Windows supports no shutdown without login. Under this configuration, the soft shutdown command sent from thevirtual host will be discarded by Windows, so Windows will not shut down.
4. Before the shutdown, Windows will broadcast a message to every service and application. If the applications fail togive affirmative responses, Windows will not initiate the shutdown. In this case, you can configure Windows to ignore
this response process.
5. If you configure the power management on Windows to ignore or do nothing When I press the power button,
Windows will ignore the shutdown event received from the virtual host.
6. Based on the power management settings, Windows will go into the Sleep mode and ignore the shutdown event.
7. If the Windows system itself is damaged due to malicious software or infections with Trojans or other viruses,
Windows may prevent shutdown.
Tencent Cloud has solved most of the shutdown failures when releasing the Windows public image to ensure soft
shutdown. However, if your Windows is infected with viruses or Trojans, the system is damaged, or the Windows
settings are adjusted again, the soft shutdown may fail.
Forced shutdown involves risks. Therefore, we recommend that you use it only when you really have to.

©2013-2022 Tencent Cloud. All rights reserved.

Page 142 of 242

Cloud Virtual Machine

Configuring High-performance PowerManagement：

Last updated 2024-01-06 17:38:11

Overview
High-performance power management is required for the Windows Server operating system (OS) to support the soft
shutdown of CVM instances. Otherwise, you can only forcibly shut down CVM instances on the CVM console. This
document uses Windows Server 2012 as an example to describe how to configure power management.

Notes
To modify power management, you do not need to restart your computer.

Directions
1. Log in to a Windows instance using either the RDP file (recommended) or the remote desktop.
2. Open Internet Explorer in the Windows CVM, access the Tencent Cloud private network, and download theTencent Cloud power modification and configuration tool.
The download address is http://mirrors.tencentyun.com/install/windows/power-set-win.bat .
For example, download the Tencent Cloud power modification and configuration tool (power-set-win.bat) to the C:
drive.
3. Use the command line tool (CMD) as the administrator to open power-set-win.bat.

4. Run the following command to view the current power management plan:©2013-2022 Tencent Cloud. All rights reserved.

Page 143 of 242

Cloud Virtual Machine

powercfg -L
The returned result is as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 144 of 242

Cloud Virtual Machine

5. On the desktop of the operating system, click> Control Panel > System and Security > Power Options.
6. In the Power Options window, click Change plan settings.

7. In the Edit Plan Settings window, modify the idle turn-off times of the monitor and disk.

©2013-2022 Tencent Cloud. All rights reserved.

Page 145 of 242

Cloud Virtual Machine©2013-2022 Tencent Cloud. All rights reserved.

Page 146 of 242

Cloud Virtual Machine

Windows Recovery Mode：

Last updated 2024-01-06 17:38:11

Windows Recovery Mode
Windows Recovery is an auto-recovery feature of Windows. When Windows detects certain system problems andbelieves that continuous running will cause system damage, this automatic repair feature will prevent Windows fromstarting up and provide System Recovery Options to users to repair, back up or restore the system.
System Recovery Options includes Startup Repair, System Restore, and Windows Memory Diagnostic,
which can help users fix problems, back up data, and restore the system.
If you cannot remotely log in to a CVM, and see the following figure when logging in to the CVM via the console, itmeans that the Windows CVM has entered the recovery mode.

Reasons
In the following situations, the system may enter the recovery mode.
The power was cut off while Windows was running or shutting down. The Windows system was forcibly shut
down via the console. Both scenarios may cause loss of critical data.
The power was cut off while Windows was updating. This may cause loss of critical update data.
The system was damaged by Trojans or viruses.
There were bugs in Windows core services. Windows detected a risk.
The system lost critical data or was damaged. The system files were corrupted due to misoperation.

©2013-2022 Tencent Cloud. All rights reserved.

Page 147 of 242

Cloud Virtual Machine

Precautions
Recommended precautions are as follows:
Log in to the console to monitor the shutdown process of a Windows system. Tencent Cloud supports the soft
shutdown that comes with a timeout mechanism. If the shutdown process has not been completed within the given
period, a failure message will be returned. If the shutdown process is slow or Windows Update starts, do not force a
shutdown; instead, just wait for the shutdown to complete. For more information, please see Shutdown Failure
Scenarios.
Check whether there are abnormal programs or processes in the system, such as Trojans or viruses.
Check whether the system management and anti-virus software are running properly.
Install Windows updates in time, especially important updates and security updates.
Check the system event logs regularly to fix bug in core services.

Solutions
If Windows enters the recovery mode, perform the following steps to continue starting up or allow Windows to
automatically repair minor problems.
1. Log in to the CVM via the CVM console.
2. In the recovery mode page that appears, click Next.

3. In the System Recovery Options window, click Next to use the default solution, as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 148 of 242

Cloud Virtual Machine

4. Click Restart, and quickly press F8.

5. Choose Start Windows Normally.

©2013-2022 Tencent Cloud. All rights reserved.

Page 149 of 242

Cloud Virtual Machine

If the startup fails, reinstall the system via the console. For more information, see Reinstalling the system via theconsole.

©2013-2022 Tencent Cloud. All rights reserved.

Page 150 of 242

Cloud Virtual Machine

Updating the Virtio ENI Driver：

Last updated 2024-01-06 17:38:11

Overview
For Tencent Cloud CVMs that using Windows Server 2008 R2, Windows Server 2012 R2, Windows Server 2016, andWindows Server 2019, Virtio ENI drivers are installed to optimize the network performance of virtualization hardware.
This document describes how to update the Virtio ENI driver and check the driver version.

Prerequisites
You have logged in to a Windows CVM.

Directions
Viewing system version information
Perform the following steps to view the system version.
1. Log in to the CVM, right-click, and select Run in the pop-up menu.
2. Enter cmd in the pop-up window and press Enter.
3. In the pop-up window, run the systeminfo command to view the system information.
This document uses Windows Server 2016 Datacenter Edition 64-bit as an example.

Updating the Virtio ENI driver©2013-2022 Tencent Cloud. All rights reserved.

Page 151 of 242

Cloud Virtual Machine

Caution:
The CVM will be disconnected briefly during the update. Please make sure that this will not affect your service before
continuing. The CVM needs to be restarted after the update.
1. Download the Virtio ENI driver installation file for the operating system version by using the browser in the CVM.
Choose the download address based on the network environment:
Public network download address:
http://mirrors.tencent.com/install/windows/virtio_64_1.0.9.exe
Private network download address:
http://mirrors.tencentyun.com/install/windows/virtio_64_1.0.9.exe
2. After the download is completed, double-click the installer and click Next.
3. Keep "VirtioDrivers" checked by default and click Next, as shown below:

4. Select the installation location and click Install, as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 152 of 242

Cloud Virtual Machine

5. In the Windows Security pop-up window, check Always trust the software from Tencent Technology(Shenzhen) Company Limited and click Install.
During the installation process, choose Install this driver software anyway when prompted.
6. Follow the prompt to restart the computer to complete the update.

Checking the driver version
1. Right-click

and select Run in the pop-up menu.
2. In the Run window, enter ncpa.cpl and press Enter.
3. In the Network Connection window, right-click the "Ethernet" icon and choose Properties.
4. In the Ethernet Properties window, click Configure.
5. In the Tencent Virtio Ethernet Adapter Properties window, select the Driver tab to see the current driver
version.

©2013-2022 Tencent Cloud. All rights reserved.

Page 153 of 242

Cloud Virtual Machine

Modifying SID：

Last updated 2024-01-06 17:38:11

Overview
Windows operating system uses a security identifier (SID) to identify computers and users. CVM instances createdwith the same image will have the same SID and might experience domain log-in issues. If you need to build a
Windows domain environment, you will need to modify the SID.
This document takes the CVM with Windows Server 2012 operating system as an example to describe how to modify
the SID using sysprep and sidchg tools of the system.

Must-knows
Instruction in this document is only applicable to Windows Server 2008 R2/2012/2016.
To modify the SIDs of multiple CVMs at the same time, you can create a custom image (select "run sysprep to create
the image").
Modify the SID may cause data loss or system damage. We recommend you create a system disk snapshot or image
in advance.

Directions
Using sysprep to modify the SID
Note:
After using sysprep to modify the SID, you need to manually reset some system parameters, including IP configuration
information.
When you use sysprep to modify the SID, C:\\Users\\ Administrator will be reset and some data on the system disk will
be erased. Please back up data.
1. Log in to the Linux CVM via VNC.
2. In the operating system interface, right-click> Run, enter cmd, and press Enter to open the admin command line.
3. ﻿In the admin command line, run the following command to save the current network configuration.

©2013-2022 Tencent Cloud. All rights reserved.

Page 154 of 242

Cloud Virtual Machine

ipconfig /all
4. In the admin command line, run the following command to open the sysprep tool.

©2013-2022 Tencent Cloud. All rights reserved.

Page 155 of 242

Cloud Virtual Machine

C:\\Windows\\System32\\Sysprep\\sysprep.exe
5. In the System Preparation Tool 3.14 window that pops up, make the following configurations.
Set System Cleanup Action to Enter System Out-of-Box Experience (OOBE) and check General.
Set Shutdown Options to Reboot.
6. Click OK, and the system restarts automatically.
7. After the startup is complete, follow the wizard to complete the configuration (select language, reset password, etc.).
8. In the operating system interface, right-click©2013-2022 Tencent Cloud. All rights reserved.

Page 156 of 242

Cloud Virtual Machine> Run, enter cmd, and press Enter to open the admin command line.
9. Run the following command to verify whether the SID has been modified.

whoami /user
If a message similar to the following is returned, the SID is modified.

©2013-2022 Tencent Cloud. All rights reserved.

Page 157 of 242

Cloud Virtual Machine

10. Reset ENI information (such as IP address, gateway address, DNS, etc.) based on the network configuration
information saved in Step 3.

Using sidchg to modify the SID
1. Log in to your CVM.
2. Access and download the sidchg tool through IE browser.
The download address of sidchg tool: http://www.stratesave.com/html/sidchg.html
3. Using the admin command line to run the following command and open the sidchg tool.
In this example, the sidchg tool is saved on C: drive and named as “sidchg64-2.0p.exe”.

﻿/R means automatic restart after modification, and/S means shutdown after modification. For details, pleasesee SIDCHG Official Instructions.
4. Enter license key or trial key as prompted by the page, and press Enter.
5. Enter Y as prompted by the page, and press Enter.

©2013-2022 Tencent Cloud. All rights reserved.

Page 158 of 242

Cloud Virtual Machine

6. In the prompt box for modifying the SID, click OK to reset the SID.
The system restarts during the reset.

7. After the startup is completed, right-click> Run, enter cmd, and press Enter to open the admin command line.
8. Run the following command to verify whether the SID is modified.

©2013-2022 Tencent Cloud. All rights reserved.

Page 159 of 242

Cloud Virtual Machine

whoami /user
If a message similar to the following is returned, the SID is modified.

©2013-2022 Tencent Cloud. All rights reserved.

Page 160 of 242

Cloud Virtual Machine©2013-2022 Tencent Cloud. All rights reserved.

Page 161 of 242

Cloud Virtual Machine

Modifying VNC Resolution：

Last updated 2024-01-06 17:38:11

Overview
This document introduces how to adjust the resolution of the instance login via VNC through the CVM console.
If Windows system images have very low VNC resolutions, some applications may fail to be properly displayed or
opened. To avoid these issues, you need to modify the resolutions of Windows system images.
Some Linux system images have lower VNC display resolutions by default. For example, the VNC resolution for
CentOS is only 720 * 400. You can set the VNC resolution to 1024 * 768 by modifying the parameter grub .
Note:More recent Linux images such as CentOS 7, CentOS 8, Ubuntu, and Debian 9.0 adopt a default VNC resolution of1024 * 768, which can be used without any modifications.

Prerequisites
You have logged in to the instance via VNC. For details, see the following documents:
Logging into Windows Instances via VNC.
Logging into Linux Instances via VNC.

Directions
Windows instances
Linux instances
Note:
The steps below describe how to modify the VNC resolution of a Windows instance on the Windows Server 2012
operating system.
1. Right-click on the desktop and select Screen resolution, as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 162 of 242

Cloud Virtual Machine

2. In the “Screen Resolution” window, set Resolution to your desired value and click Apply, as shown below:

3. In the pop-up window, click Keep changes.
4. Click OK to close the “Screen Resolution” window.
The steps below describe how to modify the VNC resolution of a Linux instance on the CentOS 6 and Debian 7.8
operating systems.

©2013-2022 Tencent Cloud. All rights reserved.

Page 163 of 242

Cloud Virtual Machine

CentOS 6
A CentOS 6 image has a VNC resolution of 720 * 400 by default. To set its resolution to 1024 * 768, modify the launchparameter grub as follows:
1. Run the following command to open the /etc/grub.conf file.

vi /etc/grub.conf
2. Press i to switch to the editing mode, and add vga=792 to the parameter grub , as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 164 of 242

Cloud Virtual Machine

3. Click Esc and enter :wq to save and close the file.
4. Run the following command to restart the CVM.

©2013-2022 Tencent Cloud. All rights reserved.

Page 165 of 242

Cloud Virtual Machine

rebootDebian 7.8
Both Debian 7.8 and Debian 8.2 images have VNC resolutions of 720 * 400 by default. To set their resolutions to 1024
* 768, modify the launch parameter grub as follows:
1. Run the following command to open the grub file.

©2013-2022 Tencent Cloud. All rights reserved.

Page 166 of 242

Cloud Virtual Machine

vim /etc/default/grub
2. Press i to switch to the editing mode and add vga=792 to the end of the parameter value
GRUB_CMDLINE_LINUX_DEFAULT , as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 167 of 242

Cloud Virtual Machine

3. Click Esc and enter :wq to save and close the file.
4. Run the following command to update the grub.cfg file.

grub-mkconfig -o /boot/grub/grub.cfg©2013-2022 Tencent Cloud. All rights reserved.

Page 168 of 242

Cloud Virtual Machine

5. Run the following command to reboot the CVM.

rebootAppendix
The VGA parameter values corresponding to different Linux instance resolutions are listed below:©2013-2022 Tencent Cloud. All rights reserved.

Page 169 of 242

Cloud Virtual Machine

Resolution

640 * 480

800 * 600

1024 * 768

VGA

786

789

792

©2013-2022 Tencent Cloud. All rights reserved.

Page 170 of 242

Cloud Virtual Machine

Ensuring Unique SIDs for CVMs Using
Sysprep：

Last updated 2024-01-06 17:38:11

Overview
To join an instance to a domain and log in to Windows CVM with the domain account, you need to run Sysprep before
creating a custom image to ensure the SID will be unique. Otherwise, the instance cannot be joined to the domain
because the CVM created with the custom image and the original instance contains identical information, such as
duplicate SIDs. Skip this operation if you have no need to join your Windows CVM to a domain.
This document describes how to run Sysprep on the Windows Server 2012 R2 64-bit operating system to ensure that
the Windows CVMs in the domain have unique SIDs.
For more information about Sysprep, see https://technet.microsoft.com/zhcn/library/cc721940(v=ws.10).aspx .

Notes
Windows CVM must be an active genuine Windows operating system.
If your Windows CVM is created with a non-public image, you must always run the Sysprep version provided in theoriginal image under directory %WINDIR%\\system32\\sysprep .
The remaining Windows reset counts must be greater than 1, otherwise Sysprep cannot be encapsulated.
To check the remaining Windows reset counts, execute the command slmgr.vbs /dlv .
The Cloudbase-Init account takes care of the initialization actions when a CVM instance is launched. If youchange/delete this account or uninstall Cloudbase-Init, you might lose custom information when you provision a new
CVM from a custom image. Thus, we do not recommend modifying or deleting the Cloudbase-init account.

Prerequisites
Log in to Windows CVM as Administrator.
Install Cloudbase-Init on Windows CVM.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 171 of 242

Cloud Virtual Machine

1. On the desktop, click

to open a Windows PowerShell window.
2. Execute the following command in the Windows PowerShell window to go to the installation directory of the
Cloudbase-init tool.
Note:
Assume that Cloudbase-init is installed under C:\\Program Files\\Cloudbase Solutions\\ .

cd 'C:\\Program Files\\Cloudbase Solutions\\Cloudbase-Init\\conf'©2013-2022 Tencent Cloud. All rights reserved.

Page 172 of 242

Cloud Virtual Machine

3. Execute the following command to encapsulate the Windows system.
Note:
Include /unattend:Unattend.xml in the following command, otherwise your current username, password andother configurations of the CVM will be reset. If you choose Follow image for the login, you will need to manually
reset the username and account after launch.
After the following command is executed, CVM automatically shuts down. To ensure that the CVMs created from thisimage has unique SIDs, do not launch the CVM instance before creating a custom image, or this action will only beeffective for the current CVM.
After you execute the following command on the Windows Server 2012 or Windows Server 2012 R2 operating
system, the account Administrator and its password of the CVM will be deleted. Reset your account and password
after restarting the CVM as detailed in Reset Instance Password.

©2013-2022 Tencent Cloud. All rights reserved.

Page 173 of 242

Cloud Virtual Machine

C:\\Windows\\System32\\sysprep\\sysprep.exe /generalize /oobe /unattend:Unattend.xm
4. Create a custom image from the CVM instance on which Sysprep has been executed, and start new CVM instanceswith the image. See Creating Custom Images.
And now, each new CVM instance will have a unique SID when joining a domain.
Note:
To check CVM SID, execute the command whoami /user .

©2013-2022 Tencent Cloud. All rights reserved.

Page 174 of 242

Cloud Virtual Machine

Use of the atop Monitoring Tools by Linux
Instances：

Last updated 2024-01-06 17:38:11

Overview
Atop is a tool for monitoring Linux system resources and processes. It records the system operation status at a certain
frequency, collects the data of system resources (CPU, memory, disk and network) usage and process running status,and stores these information in the disk in the format of log files. You can obtain the corresponding atop log file toanalyze an instance issue.
This document introduces how to use the atop monitoring tool with an example of CVM using CentOS 7.9 operating
system.

Directions
Installing Atop
1. Log in to a Linux instance using WebShell.
2. Run the following command to install atop.

©2013-2022 Tencent Cloud. All rights reserved.

Page 175 of 242

Cloud Virtual Machine

yum install atop -y
The prompt message Complete! indicates that atop has been successfully installed.

Configuring and launching atop
Configure the atop monitoring period and log retention time as described below:
1. Execute the following command to open the atop configuration file with VIM editor.

©2013-2022 Tencent Cloud. All rights reserved.

Page 176 of 242

Cloud Virtual Machine

vim /etc/sysconfig/docker
2. Press i to enter the edit mode and modify the configuration below:
Modify LOGINTERVAL=600 to

LOGINTERVAL=30 . This means to modify the monitoring period of 600s by

default to a recommended value-30s. You can modify it to other values as needed.
Modify LOGGENERATIONS=28 to LOGGENERATIONS=7 . This means to modify the log retention time of 28 days
by default to 7 days. To prevent overmuch disk storage space from being occupied due to the long-term running of
atop, it’s recommended to modify it to 7 days. You can modify it to other values as needed.
The result should be as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 177 of 242

Cloud Virtual Machine

3. Press Esc and enter :wq to save the modification and exit VIM editor.
4. Launch atop with the following commands executed in CentOS 7 and other upgraded systems.

systemctl restart atop

©2013-2022 Tencent Cloud. All rights reserved.

Page 178 of 242

Cloud Virtual Machine

Analyzing atop
The launched atop records the collected data in the log file under the /var/log/atop directory. Please check therequired log file name, execute the following command to view the log file, and analyze the data with reference to atop
Common Commands and System Resource Monitoring Field Description.

atop -r /var/log/atop/atop_2021xxxx

atop Common Commands
You can use the following commands to filter the required data after opening the log file:©2013-2022 Tencent Cloud. All rights reserved.

Page 179 of 242

Cloud Virtual Machinec: Filter by CPU utilization of Linux processes in descending order.
m: Filter by memory usage of Linux processes in descending order.
d: Filter by disk usage of Linux processes in descending order.
a: Filter by resource usage of Linux processes in descending ordern: Filter by network usage of Linux processes in descending order (This command is not supported by default. To use
it, you need to install additional kernel modules).
t: Redirect to the next monitoring data collection spot.
T: Redirect to the previous monitoring data collection spot.
b: Specify point in time, in the format YYYYMMDDhhmm.
Description of system resource monitoring fields
Some monitoring fields and values are shown below. These values obtained according to the sampling period are only
for reference.

The main parameters are as follows:
ATOP: CVM name, information sampling date and point in time.
PRC: Overall operation status of the process.
sys and user: The ratios between CPU service time and the sampling period in Linux process kernel mode and user
mode.
#proc: Total Linux processes.

©2013-2022 Tencent Cloud. All rights reserved.

Page 180 of 242

Cloud Virtual Machine#zombie: Zombie processes.
#exit: Processes exited during the atop sampling period.
CPU line: Usage of overall CPU configuration (Deem multi-core CPUs as a complete CPU resource). All values of the
fields on the CPU line are added up to N00%, and N is equal to the number of CPU cores.
sys and user: The ratios between CPU service time and the sampling period in process kernel mode and user mode.
irq: The ratio between the time the CPU is used to process interrupts and the sampling period.
idle: The ratio between the CPU idle time and the sampling period.
wait: The ratio between the time the CPU is in the "idle state caused by the process waiting for the disk Input/Output"
and the sampling period.
CPL line: CPU loading conditions.

、：avg1 avg5 and avg15 Average number of processes in the running queue in the past 1 minute, 5 minutes and 15
minutes.
csw: Number of context switches.
intr: Number of interruptions.
MEM line: Memory usage.
tot: Total physical memory.
cache: Memory used for page cache.
buff: Memory used for file buffer.
slab: Memory used by system kernel.
SWP line: Usage of swap space.
tot: Total swap area.
free: Idle swap space.
PAG: Paging of virtual memoryswin and swout: Number of memory pages swapped in and out.
DSK: Disk usage. A line of information shows the usage of each disk device. Add a line of DSK information if there issdb device.
sda: Disk device identifier.
busy: Disk busy time percentage.
read and write: Number of reading and writing requests.
NET line: The multiple NET lines show the network conditions, including the information of transport layer (TCP and
UDP), IP layer and active network interfaces.
xxxxxi: Number of packages received at each layer or active network interface.
xxxxxo: Number of packages sent at each layer or active network interface.

Stop atop
It is not recommended to run atop for a long time in application environment. You can stop atop after troubleshooting.
In CentOS 7 and other upgraded systems, you can execute the following command to stop the atop.

©2013-2022 Tencent Cloud. All rights reserved.

Page 181 of 242

Cloud Virtual Machine

systemctl stop atop

©2013-2022 Tencent Cloud. All rights reserved.

Page 182 of 242

Cloud Virtual Machine

Introduction to Linux Kernel Parameters：

Last updated 2024-01-06 17:38:11
Tencent Cloud provides the Linux public images with default configurations, but we recommend you separately
configure sysctl to adapt to your specific business. This document describes the default and optimal
configurations of Tencent Cloud Linux public images and helps you manually tune them as needed.
Note:
The parameters expressed as “-” under Initial Configuration use the official image’s default configurations.
The sysctl -w command only makes the configurations take effect temporarily, while parameters wrote to/etc/sysctl.conf take effect permanently.

Network-related
Parameter

Description

Initial Configuration

This parameter isused to quickly
recycle the
TIME_WAIT
connection. If
enabled, kernel will
check the packet
timestamp.We do
net.ipv4.tcp_tw_recycle

not recommend
enabling thisparameter, because0

packet loss may
occur when thetimestamp is not
monotonicallyincreasing. Thisparameter isdisused in later
kernel versions.
net.core.somaxconn©2013-2022 Tencent Cloud. All rights reserved.

This parameter isused to define the
ESTABLISH stateat the end of thethree-wayhandshake when
there is no ACCEPT
queue. A longer

128

Page 183 of 242

Cloud Virtual Machine

ACCEPT queue
indicates low
processing rate of
the client, or a burstof new connections
in a short time.
Setting
net.core.somaxconn
too low may cause
packet loss
because the new
SYN connection will
be discarded when
the server receives
SYN packet and thesomaxconn table isfull. Setting it toohigh is only
necessary for highconcurrence
service, but thelatency may
increase.
This parameter
specifies the
maximal number ofconnections in
SYN_RECV queue,
which was once
net.ipv4.tcp_max_syn_backlog

used to defend thecommon synflood-

attacks. However, if
tcp_syncookies=1,
connections in
SYN_RECV queue
will exceed theupper limit.
net.ipv4.tcp_syncookies

This parameter is1

used to enable SYN
Cookies, which
prevents some SYN
attacks. If enabled,
the connections canstill be established©2013-2022 Tencent Cloud. All rights reserved.

Page 184 of 242

Cloud Virtual Machine

when the SYN
queue isoverflowed.
However, SHA1 will
be used to verify
Cookies, which
theoreticallyincreases the CPU
utilization.
net.core.rmem_default

These parametersnet.core.rmem_max

are used toconfigure the cache
size of received

net.ipv4.tcp_memnet.ipv4.tcp_rmem

rmem_default=655360rme

data. Setting thistoo high may waste
memory resources,
while setting it too
low may cause
packet loss. You
can tune themaccording to the
concurrence andthroughput of yourbusiness.
rmem_default: thetheoretically optimal
configuration isequal to the value of
bandwidth divided
by RTT, which will
overwrite theconfigurations of
tcp_rmem and
tcp_rmemrmem_max:
approximately fivetimes ofrmem_default
tcp_mem: total TCP
memory consumed,which isautomatically set to
to 3/32, 1/8 or 3/16of the CVM’s©2013-2022 Tencent Cloud. All rights reserved.

Page 185 of 242

Cloud Virtual Machine

available memory.
The parameters
tcp_mem andrmem_default also
determine themaximum numberof concurrent
connections.
These parameters
are used toconfigure the datanet.core.wmem_default
net.core.wmem_max
net.ipv4.tcp_wmem

transmission cache.
Data sending on
Tencent Cloud
usually does nothave bottlenecks,-

so these
configurations are
optional.
These parameters
are relevant to TCP
Keepalive, which
default to
75/9/7200. The
default settings
mean that thenet.ipv4.tcp_keepalive_intvl
net.ipv4.tcp_keepalive_probes
net.ipv4.tcp_keepalive_time

kernel will initiate
detection when a
TCP connection isidle for 7,200
seconds, and will
send RST after 9-

failed detections(each for 75
seconds). These
values are too highfor a server. You
can adjust them to
30/3/1800 as
needed.
net.ipv4.ip_local_port_range

This parameter isused to configure-

the available port

©2013-2022 Tencent Cloud. All rights reserved.

Page 186 of 242

Cloud Virtual Machinerange, which can be
adjusted asneeded.
This parameter isused to reuse asocket in TIMEWAIT state for new
TCP connections.
This help you
quickly restart links
tcp_tw_reusethat use fixed ports,
but may involverisks in the NATbased network.
Later kernel-

versions support
values 0, 1, and 2
and configure it to 2.
This parameter is

net.ipv4.ip_forward
net.ipv6.conf.all.forwardingused to specify the
IP forwarding. You
can configure it to 1
in the Docker’sroute forwarding
scenario.

0This parameter isused to specify thereverse pathvalidation rule ofnet.ipv4.conf.default.rp_filter

ENI on received
data packets. Validvalues include 0, 1
(recommended by
RFC3704), and 2.
The recommended-

configuration is astrict mode that can
prevent DDoS
attacks and IP
spoofing acts.
net.ipv4.conf.default.accept_source_route©2013-2022 Tencent Cloud. All rights reserved.

This parameter isused to specify

0Page 187 of 242

Cloud Virtual Machine

whether to accept
IP packets
containing source
routes, which is notallowed by default,
as recommended
on the CentOS
website.

net.ipv4.conf.all.promote_secondaries
net.ipv4.conf.default.promote_secondaries

This parameter isused to specify
whether asecondary IP
address will
become a primary1

IP after the original
primary IP address
is deleted.
This parameter is

net.ipv6.neigh.default.gc_thresh3
net.ipv4.neigh.default.gc_thresh3

used to define themaximum records
stored in the ARP
cache. The garbage
collector
immediately starts

4096

once the stored
records exceed theset value.

Memory-related
Parameter

Description

Initial Configuration

vm.vfs_cache_pressureThis controls the250

tendency of thekernel to reclaim thememory. At thedefault value of 100,
the kernel willattempt to reclaim
dentries back tomemory. The curlbased services
usually accumulate©2013-2022 Tencent Cloud. All rights reserved.

Page 188 of 242

Cloud Virtual Machine

dentries, which may
use up all the freememory and cause
OOM or kernel bug.
We configure it to
250 to balance thereclaiming
frequency andperformance, which
is tunable.
This parameter isused to force theLinux MEM to keepa minimum numberof kilobytes freememory for use bykernel threads. The
value isautomaticallycalculated
according to thefree physicalmemory (MEM) at
vm.min_free_kbytes

startup by: 4*sqrt(MEM). When the-server receives
microbursts ofpackets, yourserver may become
subtly broken andcause OOM. On ahigh-configuration
server, werecommend
configuring
vm.min_free_kbytes
at about 1% of thetotal memory bydefault.
kernel.printk

This specifies the5417

level for kernel’s
printk printing
function. The©2013-2022 Tencent Cloud. All rights reserved.

Page 189 of 242

Cloud Virtual Machinedefault configuration
is five or above.
This indicates that
kernel can
automatically moveprocesses to thecorresponding
kernel.numa_balancing

NUMA node, but it
is actually0ineffective andaffects
performance. You
can try to enable itin the Redis use
cases.
shmmax: defines
the maximum sizeof a single sharedmemory segment(in bytes) a Linuxkernel.shmallkernel.shmmax

process canallocate.

kernel.shmmax=68719476736kernel.shmall=42

shmall: defines
system-wide total
amount of sharedmemory pages.

Process-related
Parameter

Description

Initial Configuration

fs.file-maxfs.nr_open

They denote the maximum
number of file-handles that theulimit n=100001fs.nr_open=1048576

Linux kernel or a process canallocate, respectively.
file-max: automatically configures
to approximate 100,000/GB when
OS starts.
nr_open: sets to the fixed value of1048576, which limits the
maximum open file handles in auser-mode environment.
Generally, keep this value©2013-2022 Tencent Cloud. All rights reserved.

Page 190 of 242

Cloud Virtual Machine

unchanged. To modify the
maximum open file handles,
configure the ulimit -n parameterin the /etc/security/limits.conf
configuration file.
This specifies maximum
kernel.pid_max

processes in a system. The
official image uses the default-

value of 32768, which can be
adjusted as needed.
This determines whether the
kernel.core_uses_pid

generated coredump filename will1

contain .PID.
kernel.sysrq

This enables you to operate on/proc/sysrq-trigger later.

1

They defines the maximum size inbytes of a single message queue
kernel.msgmnbkernel.msgmax

and the maximum allowable size
in bytes of any single message in65536

a message queue, respectively
This controls whether the kernel
will panic when a soft lockup iskernel.softlockup_panic

detected. If enabled, a vmcore
will be generated based on the-

kdump configuration, which canbe used to analyze the cause ofsoft lockup.

IO-related
Parameter

Description

vm.dirty_background_bytes
vm.dirty_background_ratio

These parameters are mainly used to configure
the policy for IO being written back to the disk.

vm.dirty_bytes

dirty_background_bytes/dirty_bytes andvm.dirty_expire_centisecs

dirty_background_ratio/dirty_ratio refer to theamount and percentage of system memory thatvm.dirty_ratiovm.dirty_writeback_centisecs©2013-2022 Tencent Cloud. All rights reserved.

InitialConfiguration-

can be filled with “dirty” pages, respectively. In
general, the ratio will be specified.

Page 191 of 242

Cloud Virtual Machine

dirty_background_ratio: refers to a percentage
of dirty pages in the system memory (10% by
default) at which the background kernel flushprocesses will start writing back to the disk.
dirty_ratio: refers to the absolute maximum
amount of system memory that can be filled withdirty pages before everything must get
committed to disk. When the system gets to thispoint, all new I/O blocks until dirty pages havebeen written to disk, causing long I/O pauses.
The system will first get to the`vm.dirty_background_ratio` condition at which
the flush processes will start asynchronous
writeback, and applications continue writing.
When the system gets to the specified value of `vm.dirty_ratio`, OS will handle dirty pages
synchronously, blocking applications.
vm.dirty_expire_centisecs: specifies how long
dirty page can be in cache before it needs to be
written. It is expressed in 100'ths of a second.
Data which has been dirty in-memory for longer
than this interval will be written out next time aflush process wakes up.
vm.dirty_writeback_centisecs: specifies how
often kernel flush processes wake up. It is
expressed in 100'ths of a second.

©2013-2022 Tencent Cloud. All rights reserved.

Page 192 of 242

Cloud Virtual Machine

OthersBooting into Linux Single User Mode：

Last updated 2024-01-06 17:38:11

Overview
For operations like password management, SSHD fixing and maintenance before disk mounting, Linux users need toenter the single user mode. This document describes how to boot into this mode in mainstream Linux distributions.

Directions
1. On the CVM console, choose VNC to log in to a CVM. For detailed directions, see Logging into Linux Instances via
VNC.
2. In the VNC login window, select Send CtrlAltDel in the upper-left corner, press Ctrl-Alt-Delete, and click OK in
the prompt box.
3. When a connection failure message appears, press Up or Down arrow to refresh the page and hovers the cursor
over the grub menu, as shown below.

4. Press e to enter the grub rescue mode.
5. Perform the steps that suit your operating system version.
CentOS 6.x
CentOS 7.x©2013-2022 Tencent Cloud. All rights reserved.

Page 193 of 242

Cloud Virtual Machine

CentOS 8.0
Ubuntu or Debian
SUSE
tlinux
1. Select a kernel in the grub mode, as shown below.

2. Press e to enter the kernel edit page, choose the kernel line using Up or Down arrow, and press e again, as shown
below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 194 of 242

Cloud Virtual Machine

3. Enter single at the end of line, as shown below.

4. Press Enter, and then press b to boot the selected command line and enter single user mode, as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 195 of 242

Cloud Virtual Machine

The following figure indicates that the system boots into single user mode.

Note:
You can run the exec /sbin/init command to exit the single user mode.

1. Select a kernel in the grub mode, as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 196 of 242

Cloud Virtual Machine

2. Press e to enter the kernel edit page. Locate the line started with “linux16” using Up or Down arrow and replacero with rw init=/bin/bash or /usr/bin/bash , as shown below.

3. Press Ctrl+X to boot into the single user mode, as shown below:
The following figure indicates that the system boots into the single user mode.

©2013-2022 Tencent Cloud. All rights reserved.

Page 197 of 242

Cloud Virtual Machine

Note:
You can run the exec /sbin/init command to exit the single user mode.

1. Select a kernel in the grub mode, as shown below.

2. Press e to enter the kernel edit page. Locate the line started with “linux” using Up or Down arrow and replace rowith rw init=/sysroot/bin/bash , as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 198 of 242

Cloud Virtual Machine

3. Press Ctrl+X to boot into the single user mode, as shown below:
The following figure indicates that the system boots into the single user mode.

1. Select a kernel in the grub mode, as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 199 of 242

Cloud Virtual Machine

2. Press e to enter the kernel edit page. Locate the line started with “linux” using Up or Down arrow and append
quiet splash rw init=/bin/bash to the end of the line, as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 200 of 242

Cloud Virtual Machine

3. Press Ctrl+X to boot into the single user mode, as shown below:
The following figure indicates that the system boots into single user mode.

1. Select a kernel in the grub mode, as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 201 of 242

Cloud Virtual Machine

2. Press e to enter the kernel edit page. Locate the line started with “linux” using Up or Down arrow, add rw to thebeginning and 1 to the end of the splash parameter, as shown below.

3. Press Ctrl+X to boot into the single user mode, as shown below:
1. Select a kernel in the grub mode, as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 202 of 242

Cloud Virtual Machine

2. Press e to enter the kernel edit page, choose the kernel line using Up or Down arrow, and press e again, as shown
below.

3. Add a space and 1 to the end of the line (namely after 256M), as shown below.

©2013-2022 Tencent Cloud. All rights reserved.

Page 203 of 242

Cloud Virtual Machine

4. Press Enter to enter the single user mode.

©2013-2022 Tencent Cloud. All rights reserved.

Page 204 of 242

Cloud Virtual Machine

Using Rescue Mode：

Last updated 2024-01-06 17:38:11

Overview
This document describes how to use the rescue mode in the CVM console. If the server GRUB bootloader files, key
system files, or .lib dynamic library files are corrupted or missing when you use the CVM operating system, theoperating system may be unable to enter the single user mode and be repaired. In this case, you need to use the CVM
rescue mode to repair the system.

Directions
Entering rescue mode
Note:
Before you enter the rescue mode, we strongly recommend you back up the instance to avoid the impact ofmaloperations. You can create snapshots to back up cloud disks and create custom images to back up local systemdisks.
1. Log in to the CVM console.
2. On the instance management page, proceed according to the used view mode:
List mode
Tab mode
Select More > OPS and Check > Enter Rescue Mode on the right of the row of the target instance as shown
below:©2013-2022 Tencent Cloud. All rights reserved.

Page 205 of 242

Cloud Virtual Machine

Click the tab of the target instance and select More Actions > OPS and Check > Enter Rescue Mode in the topright corner as shown below:

3. ﻿
In the Enter Rescue Mode pop-up window, set the instance login password for the rescue mod
e as shown below:
Note:
Currently, the rescue mode supports only Linux instances but not Windows instances. If you enter the rescue mode ina Windows instance, you will enter the Linux rescue mode (on CentOS 7.5 64-bit) by default.
The instance username is root by default in the rescue mode.
You can enter the rescue mode only when the instance is shut down. Forced shutdown may cause data loss or filesystem corruption. We recommend you shut down the instance as instructed in Shutting Down Instance before
entering the rescue mode.

©2013-2022 Tencent Cloud. All rights reserved.

Page 206 of 242

Cloud Virtual Machine

4. Click Enter Rescue Mode.
At this point, you can see that the instance is entering the rescue mode. If the instance status is as shown below, theinstance has entered the rescue mode successfully. Proceed to the next step to repair the instance as soon as
possible.

©2013-2022 Tencent Cloud. All rights reserved.

Page 207 of 242

Cloud Virtual Machine

Using rescue mode to repair system
1. Use the root account and the password set in step 3 to log in to the instance as follows:
If the instance has an EIP, you can log in as instructed in Logging into Linux Instance via SSH Key.
If the instance has no EIPs, you can log in as instructed in Logging into Linux Instances via VNC.
2. After successful login, run the following commands in sequence to mount the root system disk partition:
In rescue mode, the device name of the instance system disk is vda , and its root partition is vda1 , which isunmounted by default.

©2013-2022 Tencent Cloud. All rights reserved.

Page 208 of 242

Cloud Virtual Machine

mkdir -p /mnt/vm1©2013-2022 Tencent Cloud. All rights reserved.

Page 209 of 242

Cloud Virtual Machine

mount /dev/vda1 /mnt/vm1
After successful mounting, you can manipulate the data in the root partition. You can also use the mount -obind command to mount some sub-directories in the original file system and use the chroot command to run
commands in the specified root directory. Below are the specific commands:©2013-2022 Tencent Cloud. All rights reserved.

Page 210 of 242

Cloud Virtual Machine

mount -o bind /dev /mnt/vm1/dev
mount -o bind /dev/pts /mnt/vm1/dev/pts
mount -o bind /proc /mnt/vm1/proc
mount -o bind /run /mnt/vm1/run
mount -o bind /sys /mnt/vm1/sys
chroot /mnt/vm1 /bin/bash

Exiting rescue mode
1. After repairing the instance, exit the rescue mode in the following steps according to the used view mode:©2013-2022 Tencent Cloud. All rights reserved.

Page 211 of 242

Cloud Virtual Machine

List mode
Tab mode
Select More > OPS and Check > Exit Rescue Mode on the right of the row of the target instance as shown below:

Click the tab of the target instance and select More Actions > OPS and Check > Exit Rescue Mode in the topright corner as shown below:

2. After the instance exits the rescue mode, it is still shut down. Start it up as instructed in Starting Up Instances toresume instance operations.

©2013-2022 Tencent Cloud. All rights reserved.

Page 212 of 242

Cloud Virtual Machine

Setting Up Windows CVM for Multi-user
Remote Login：

Last updated 2024-01-06 17:38:11

Overview
This document shows you how to configure a multi-user remote login to Windows CVM, taking a CVM with Windows
Server 2016 R2 as the operating system as an example.
Note:
The trial period of the multi-user remote login feature provided by Microsoft is 120 days. If you haven't purchased
multi-user login licenses (RDS CALs), after the trial ends, you can log in to CVM only through the mstsc /admin
command but not Remote Desktop. Windows Server allows two users to log in at the same time by default, whichmeets most needs. Evaluate your needs based on your actual business scenarios, and if you strongly need toconfigure multi-user remote login, proceed as instructed in this document.

Directions
Adding remote desktop service
1. Log in to the Windows CVM.
2. On the desktop, click

and selectin the pop-up window to open Server Manager as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 213 of 242

Cloud Virtual Machine

3. Click Add roles and features, and the Add Roles and Features Wizard will pop up.
4. In the Add Roles and Features Wizard window, keep the default parameters for the first three steps (click Next
three times in a row).
5. On the Select server roles page, select Remote Desktop Services and click Next as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 214 of 242

Cloud Virtual Machine

6. Keep the default parameters and click Next twice in a row.
7. On the Select role services page, select Remote Desktop Session Host as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 215 of 242

Cloud Virtual Machine

8. In the Add features that are required for Remote Desktop Session Host? pop-up window, click Add
Features as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 216 of 242

Cloud Virtual Machine

9. On the Select role services page, select Remote Desktop Licensing as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 217 of 242

Cloud Virtual Machine

10. In the Add features that are required for Remote Desktop Licensing? pop-up window, click Add Features
as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 218 of 242

Cloud Virtual Machine

11. Click Next.
12. Select Restart the destination server automatically if required and click Yes in the pop-up window as shown
below:©2013-2022 Tencent Cloud. All rights reserved.

Page 219 of 242

Cloud Virtual Machine

13. Click Install and wait for the Remote Desktop service installation to complete.

Applying for multi-user login license
1. On the desktop, click

and selectin the pop-up window to open Server Manager.
2. In the Server Manager window, select Tools > Remote Desktop Services > Remote Desktop Licensing
Manager in the top-right corner.
3. In the Remote Desktop Licensing Manager pop-up window, right-click the row of the target server and selectActivate Server.

©2013-2022 Tencent Cloud. All rights reserved.

Page 220 of 242

Cloud Virtual Machine

4. In the Activate Server Wizard pop-up window, click Next.
5. Select Web Browser for Connection method and click Next.
You can also select other connection methods based on your actual conditions.
6. I
n License Server Activation, record the product ID
and visit the Remote Desktop Licensing website.
7. At the Remote Desktop Licensing website, select Activate a license server and click Next.
8. Enter the product ID obtained in step 6, enter the company information based on your actual conditions, and click
Next.
9. After confirming that everything is correct, click Next.
10. ﻿
Record the license server ID
and click Yes.
11. Enter the license server ID obtained in the previous step, select the licensing information as needed, enter thecompany information, and click Next .
Here, Enterprise agreement is selected as the licensing information as an example.
12. Select the product type and enter the product quantity and licensing information.
Note:
You can go to the Microsoft official website and contact the customer service to purchase RDS CALs.
13. After confirming that everything is correct, click Next.
14. ﻿
Get and record the key pack ID.
15. Click Finish.

Activating Remote Desktop license server
1. On the desktop, click

and selectin the pop-up window to open Server Manager.
2. In the Server Manager window, select Tools > Remote Desktop Services > Remote Desktop Licensing
Manager in the top-right corner.
3. In the Remote Desktop Licensing Manager pop-up window, right-click the row of the target server and selectActivate Server.
4. In the Activate Server Wizard pop-up window, click Next.

©2013-2022 Tencent Cloud. All rights reserved.

Page 221 of 242

Cloud Virtual Machine

5. Select Web Browser for Connection method and click Next.
You can also select other connection methods based on your actual conditions.
6. In License Server Activation, enter the license server ID obtained in step 10 and click Next.
7. When the Activate Server Wizard prompts You have completed the Activate Server Wizard, click Next toinstall the license.

Installing RDS client access license
1. In the Install Licenses Wizard window, confirm the license server information and click Next.
2. In Obtain Client License Key Pack, enter the license server ID obtained in step 14 and click Next.
3. When the Install Licenses Wizard prompts You have completed the Install Licenses Wizard as shown
below, you have installed the license successfully.

Configuring Remote Desktop Session Host license server
1. On the desktop, click

and selectin the pop-up window to open Server Manager.
2. In the Server Manager window, select Tools > Remote Desktop Services > Remote Desktop Licensing
Diagnoser and view the current server status.
3. On the desktop, right-click

and select Run in the pop-up window.
4. In the Run window, enter gpedit.msc and press Enter to open Local Group Policy Editor.
5. On the left sidebar, select Computer Configuration > Administrative Templates > Windows Components >Remote Desktop Services > Remote Desktop Session Host > Licensing and double-click Use the specified
Remote Desktop license servers.
6. In the Use the specified Remote Desktop license servers pop-up window, select Enabled, enter a CVM
instance public IP or host name for License Servers to use, and click OK.
7. Double-Click Set the Remote Desktop licensing mode.
8. In the Set the Remote Desktop licensing mode pop-up window, select Enabled, set the licensing mode for the
Remote Desktop Session Host server to By user, and click OK.
9. Restart the CVM instance.
At this point, you have completed the configuration of multi-user remote login.

©2013-2022 Tencent Cloud. All rights reserved.

Page 222 of 242

Cloud Virtual Machine

References
License your RDS deployment with client access licenses (CALs)
Activate the Remote Desktop Services license server
Install RDS client access licenses on the Remote Desktop license server©2013-2022 Tencent Cloud. All rights reserved.

Page 223 of 242

Cloud Virtual Machine

Modifying the Default Remote Port of CVM：

Last updated 2024-01-06 17:38:11

Scenario
The default port of the CVM is susceptible to scanning and attack by malicious software. Therefore, you need tochange the default remote port of the CVM to a less common port to prevent the inability to remotely access the CVM
due to such attacks. This ensures the security of the CVM.
Modifications to the port will be valid only if they are made in the security group rules and the CVM simultaneously.
You can modify the default remote port of the CVM as described below. The modification method varies based on theoperating system of the CVM.
Modifying the default remote port of a Windows CVM
Modifying the default remote port of a Linux CVM

Directions
Modifying the default remote port of a Windows CVM
Note:
The following operations use Windows Server 2012 as an example. The procedure might vary slightly depending on
the operating system and language.
1. Log in to the Windows instance by using VNC.
2. In the operating system, click

to open the “Windows PowerShell” window.
3. In the “Windows PowerShell” window, enter regedit and press Enter to open the “Registry Editor” window.
4. In the left-side registry navigation pane, expand the following hierarchies in sequence: HKEY_LOCAL_MACHINE> SYSTEM > CurrentControlSet > Control > Terminal Server > Wds > rdpwd > Tds > tcp.
5. ﻿
Find PortNumber in tcp. Then, change the value of PortNumber from 3389 to an unoccupied port number within the range of 0 to 65535, asshown in the following figure.

©2013-2022 Tencent Cloud. All rights reserved.

Page 224 of 242

Cloud Virtual Machine

6. In the left-side registry navigation pane, expand the following hierarchies in sequence: HKEY_LOCAL_MACHINE> SYSTEM > CurrentControlSet > Control > Terminal Server > WinStations > RDP-Tcp.
7. Find and change PortNumber in RDP-Tcp to be the same as that in tcp.

©2013-2022 Tencent Cloud. All rights reserved.

Page 225 of 242

Cloud Virtual Machine

8. (Optional) If a firewall is enabled for your CVM, be sure to add the new port to the allowlist of the firewall and set toallow connection.
8.1 In the “Windows PowerShell” window, enter wf.msc and press Enter to open the “Windows Firewall with
Advanced Security” window.
8.2 In the “Windows Firewall with Advanced Security” window, select Inbound Rules and click New rule, as shownin the following figure.

8.3 On the “Rule Type” page in the “New Inbound Rule Wizard” window, select Port and click Next.

©2013-2022 Tencent Cloud. All rights reserved.

Page 226 of 242

Cloud Virtual Machine

8.4 On the “Protocol and Ports” page in the New Inbound Rule Wizard window, select TCP and enter the port
number set in Step 5 in Specific Port. Then, click Next, as shown in the following figure.

8.5 On the Action page in the “New Inbound Rule Wizard” window, select Allow connections and click Next.
8.6 On the “Profile” page in the “New Inbound Rule Wizard” window, apply the default profile and click Next.
8.7 On the “Name” page in the “New Inbound Rule Wizard” window, enter the rule name and click Finish.
8.8 In the “Windows PowerShell” window, enter services.msc and press Enter to go to the “Services” window.
8.9 Find and right-click Remote Desktop Services in the “Services” window. Then, select Restart to restart the
remote login service.
8.10 Refer to Modifying Security Group Rules to modify the security group rule with the protocol port “TCP:3389” bychanging the port number to that set in Step 5.

©2013-2022 Tencent Cloud. All rights reserved.

Page 227 of 242

Cloud Virtual Machine

Modifying the default remote port of a Linux CVM
Note:
Before you modify the default remote port, we recommend that you add the SSH port number and test whether the
port is successfully connected to the CVM. Then, delete the default port 22. Ensure that the default port 22 cannot be
connected to the CVM when the new port fails to connect to the CVM.
The following operations use CentOS 7.3 as an example. The specific operations vary slightly according to the version
and language of the operating system.
1. Log in to a Linux instance by using VNC.
2. Run the following command to modify the configuration file:©2013-2022 Tencent Cloud. All rights reserved.

Page 228 of 242

Cloud Virtual Machine

vim /etc/ssh/sshd_config
3. ﻿
Press i to switch to the editingmode and add a new port. Add Port x (where x is the port number of the new port) in a new row below #Port
22 , and delete # to comment off Port 22 , as shown in the following figure.
For example, add Port 23456 in the row.

©2013-2022 Tencent Cloud. All rights reserved.

Page 229 of 242

Cloud Virtual Machine

4. Press Esc, enter :wq, and save the change.
5. Run the following command so that the new configuration takes effect:©2013-2022 Tencent Cloud. All rights reserved.

Page 230 of 242

Cloud Virtual Machine

systemctl restart sshd.service
6. (Optional)Configure the firewall.
By default, the iptables service is used as the firewall for Linux CVMs with CentOS earlier than CentOS 7. Configure
the firewall as follows if iptables rules have been configured for the CVM.
6.1.1 Run the following command to configure the firewall:

iptables -A INPUT -p tcp --dport <New port number> -j ACCEPTFor example, if the new port number is 23456, run the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 231 of 242

Cloud Virtual Machine

iptables -A INPUT -p tcp --dport 23456 -j ACCEPT
6.1.2 Run the following command to restart the firewall:©2013-2022 Tencent Cloud. All rights reserved.

Page 232 of 242

Cloud Virtual Machineservice iptables restart
The Firewalld service is used as the firewall for Linux CVMs with CentOS 7 or later. Configure the firewall as follows if
the Firewalld service has been enabled on the CVM.
Run the following command to allow access by the port number added in Step 3:©2013-2022 Tencent Cloud. All rights reserved.

Page 233 of 242

Cloud Virtual Machine

firewall-cmd --add-port=<New port number>/tcp --permanent
For example, if the new port number is 23456, run the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 234 of 242

Cloud Virtual Machine

firewall-cmd --add-port=23456/tcp --permanent
If success is returned, the port was successfully configured.
7. Refer to Modifying Security Group Rules to modify the security group rule with the protocol port “TCP:22” bychanging the port number to that set in Step 3.

©2013-2022 Tencent Cloud. All rights reserved.

Page 235 of 242

Cloud Virtual Machine

Verification
Windows CVMs
1. Assume that the Windows operating system is installed on the local computer. Open the “Remote Desktop
Connection” dialog box.
2. Enter the Internet IP of Windows server: port number after modification after Computerand click Connect, as shown in the following figure.

3. Enter the admin account and password as prompted and click OK.
If the operating system interface of the Windows CVM appears, the connection is established.
Note:
If you log in to the Windows CVM by using an RDP file, modify the full address:s parameter in the RDP file.﻿﻿Linux CVMs
1. Assume that PuTTY is used for remote login. Start the PuTTY client.

©2013-2022 Tencent Cloud. All rights reserved.

Page 236 of 242

Cloud Virtual Machine

2. In the “PuTTY Configuration” window, enter the public IP address of the Linux CVM, set Port to the new port
number, and click Open, as shown in the following figure.

3. Enter the username and password of the Linux CVM as prompted and press Enter.
If the following output appears, the connection is established.

4. After using the new port to successfully establish a connection to the Linux CVM, run the following command:©2013-2022 Tencent Cloud. All rights reserved.

Page 237 of 242

Cloud Virtual Machine

vim /etc/ssh/sshd_config
5. Press i to switch to the editing mode, and add # in front of Port 22 to comment off the port.
6. Press Esc, enter :wq, and save the change.
7. Run the following command so that the new configuration takes effect. Ensure that you use the new port for the next
remote login to the Linux CVM.

©2013-2022 Tencent Cloud. All rights reserved.

Page 238 of 242

Cloud Virtual Machine

systemctl restart sshd.service©2013-2022 Tencent Cloud. All rights reserved.

Page 239 of 242

Cloud Virtual Machine

Getting Instance Login Logs：

Last updated 2024-01-06 17:38:11

Overview
This document describes how to obtain user login records of a CVM instance.

Directions
Linux instances
Windows instances
Note:
This document uses a Linux instance on TencentOS Server 3.1 (TK4) as an example. As the steps may vary by
operating system, proceed based on the actual conditions.
1. Log in to the Linux instance by using Web Shell.
2. You can view the following user login information as needed:
Note:
User login logs are usually stored in the /var/run/utmp , /var/log/wtmp , /var/log/btmp , and/var/log/lastlog files.
Run the who command to view the information of the currently logged-in user in the /var/run/utmp file. The
returned result is as follows:

Run the w command to view the username of the currently logged-in user and display the currently executed tasksof the user in the /var/run/utmp file. The returned result is as follows:

Run the users command to view the username of the currently logged-in user in the /var/run/utmp file. The
returned result is as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 240 of 242

Cloud Virtual Machine

Run the last command to view the information of the currently and historically logged-in users in the/var/log/wtmp file. The returned result is as follows:

Run the lastb command to view the information of all the users who failed to log in to the system in the/var/log/btmp file. The returned result is as follows:

Run the lastlog command to view the last user login information in the /var/log/lastlog file. The
returned result is as follows:

Run the cat /var/log/secure command to view the login information. The returned result is as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 241 of 242

Cloud Virtual Machine

Note:
This document uses a Windows instance on Windows Server 2012 R2 English as an example. As the steps may varyby operating system, proceed based on the actual conditions.
1. Log in to the Windows instance by using WebRDP.
2. On the desktop, click

to open Server Manager.
3. In the Server Manager window, select Tools > Event Viewer in the top-right corner.
4. In the Event Viewer pop-up window, select Windows Logs > Security on the left and click Filter Current Log
on the right.
5. In the Filter Current Log pop-up window, enter 4648 in <All Event IDs> and click OK.
6. In the Event Viewer window, double-click the logs that meet the filters.
7. In the Event Property pop-up window, click Details to view the client name and address as well as event
recording time.

©2013-2022 Tencent Cloud. All rights reserved.

Page 242 of 242