Basic management and disk expansion of Alibaba Cloud ECS server (5)

Basic management and disk expansion of Alibaba Cloud ECS server

1. Set the password of the ECS server

Click More -> Password/Key -> Reset Instance Password

1642045151361Fill in the instance password and click Submit.

1642045236975

After resetting the password, we will be asked to restart the server.

1642045264124

2. Remotely connect to the ECS server through the Alibaba Cloud console

Click Remote Connection to connect to the server remotely using WorkBench.

1642045384030

Select the ECS instance to be remoted, and enter the server account and password to log in remotely.

1642045490926

At this point, the terminal is connected to the ECS, and the corresponding commands can be executed.

1642045727984

3. Bind the public IP to ECS and connect to the cloud server through Xshell

3.1. Create an elastic public IP

1) Search for the elastic public IP in the console, and enter the product management page.

1642046511884

2) Click to create an elastic public IP

1642046569556

3) Configure elastic public IP

If the product type is billed by volume, the region and region must select the region and region where the ECS is located. The bandwidth peak is directly full, and the traffic type is billed by usage.

1642046707212

4) Confirm the order information and click Activate Now

1642050822177

After the purchase is successful, you can see it in the elastic public network IP of the console.

1642050932347

3.2. Bind the public IP to the ESC instance

Click More -> Network and Security Group -> Bind Elastic IP

1642051022140

Select the purchased elastic public IP.

1642051086903

After the elastic IP binding is completed, you can see that an elastic address has been added to the IP address of the ECS, and the status of the elastic public IP is already allocated.

1642051182705

3.3. Use xshell to connect to the ECS cloud host

1642051324897

4. Connect to the server via VNC

VNC is equivalent to the operation interface in our VM virtual machine, which is used to debug the server. When the server has a problem, it can be operated here.

1) First, set the VNC password

1642130254422

2) Restart the ECS instance

The restart of ECS is very slow, about 10-15 minutes. You can also enter reboot in the terminal to restart.

1642130294267

3) Connect ECS via VNC

Select VNC login as the remote connection method.

1642130344441

Enter the VNC password.

1642130366957

successfully entered.

1642130400006

5. Prohibit ping of public IP

Find the ECS management page -> Security Group -> Find the list of security groups corresponding to ECS

1642053090930

Click Manual Add, the authorization policy is Deny, the priority is set, the protocol type is all ICMP, the setting range is -1/-1, and the authorization object is 0.0.0.0/0, which means that all hosts are prohibited from using the ICMP protocol to request hosts.

1642053204507

Protocol added successfully.

1642053334508

It is no longer possible to ping the public network address to protect the security of the intranet.

1642053421836

5. ECS cloud server disk expansion

In practice, the ECS cloud service requires a system disk and a data disk. The ECS server we just purchased does not have a data disk. We can purchase a cloud disk and mount it to the ECS server. When the data disk space of the ECS server is available When it is not enough, the disk capacity can also be flexibly expanded.

5.1. Purchase a cloud disk

1) Find the cloud disk on the ECS management interface -> create a cloud disk

1642055546971

2) Set the basic information and storage space of the cloud disk

Whether to mount, choose not to mount, and manually mount to the corresponding ECS ​​server later.

The region and availability zone of the cloud disk must be consistent with ECS.

The payment method of cloud disk is set to pay-as-you-go.

Choose an efficient cloud disk for storage, with a space of 20GB.

Check the ECS Terms of Service for the cloud server.

1642055798092

3) Set the name information of the cloud disk

When we have many ECS instances and many cloud disks, in order to easily distinguish which ECS the cloud disk belongs to, we need to give the cloud disk a meaningful name.

The name is Web-01-data cloud disk, and the description information is the data disk of the Web-01 instance.

Put the cloud disk and ECS in the same resource group, and click Confirm Order.

1642055941692

4) Confirm the creation

1642056253932

5.2. Mount the cloud disk to ECS

1) Find the purchased cloud disk, click More -> Mount.

1642056577243

2) Select the corresponding ECS ​​instance and execute the mount.

1642056629750

3) Successfully mounted to ECS.

1642056725345

5.3. Initialize a new cloud disk and mount it

The cloud disks in Alibaba Cloud are all vdx mounted to virtual machines, and all physical machines are sdx.

1.先将磁盘进行分区
[root@iZ2ze7rto8oqydzzemi1enZ ~]# fdisk /dev/vdb
Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048): 
Command (m for help): w

[root@iZ2ze7rto8oqydzzemi1enZ ~]# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  40G  0 disk 
└─vda1 253:1    0  40G  0 part /
vdb    253:16   0  20G  0 disk 
└─vdb1 253:17   0  20G  0 part

2.格式化分区
[root@iZ2ze7rto8oqydzzemi1enZ ~]# mkfs.xfs /dev/vdb1

3.将分区挂载到/data目录
[root@iZ2ze7rto8oqydzzemi1enZ ~]# mkdir /data
[root@iZ2ze7rto8oqydzzemi1enZ ~]# mount /dev/vdb1 /data

4.将分区与目录写入到开机自动挂载的文件中
[root@iZ2ze7rto8oqydzzemi1enZ ~]# vim /etc/fstab 
/dev/vdb1       /data   xfs     defaults        0 0

5.4. Expansion of the existing cloud disk

1) Click More -> Cloud Disk Expansion.

1642057155244

2) Check online expansion, set the expanded capacity to 30GB, and finally check the expansion instructions, and confirm the expansion.

1642057266925

3) You can see that the cloud disk and the expansion are successful, and the capacity of the cloud disk mounted on the ECS is already the space after the expansion, but the partition has not changed.

1642057395813

5.5. Refresh the expanded cloud disk capacity in ECS

Steps: First unmount the cloud disk, then delete the partition of the existing cloud disk, re-partition the cloud disk, and finally refresh the disk.

Deleting a partition will not clear the data in the disk, the data is stored in the track, not the partition.

1.在/data目录生成数据,测试扩容前后数据是否会丢失
[root@iZ2ze7rto8oqydzzemi1enZ ~]# mkdir /data/{123.txt,456.txt}

2.查看磁盘的大小是否是扩容后的容量
[root@iZ2ze7rto8oqydzzemi1enZ ~]# fdisk -l /dev/vdb
Disk /dev/vdb: 32.2 GB, 32212254720 bytes, 62914560 sectors
#可以看到容量已经是扩容后的容量了,只是分区没有变。

3.将分区取消挂载
[root@iZ2ze7rto8oqydzzemi1enZ ~]# umount /data/

4.重新将/dev/vdb1进行分区,获取磁盘全部容量
[root@iZ2ze7rto8oqydzzemi1enZ ~]# fdisk /dev/vdb
Command (m for help): d
Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-62914559, default 2048): 
Command (m for help): w

5.查看分区容量是否发生变化
[root@iZ2ze7rto8oqydzzemi1enZ ~]# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  40G  0 disk 
└─vda1 253:1    0  40G  0 part /
vdb    253:16   0  30G  0 disk 
└─vdb1 253:17   0  30G  0 part 

6.挂载分区
[root@iZ2ze7rto8oqydzzemi1enZ ~]# mount -a

7.刷新分区空间
[root@iZ2ze7rto8oqydzzemi1enZ ~]# xfs_growfs /data/

8.验证数据是否丢失
[root@iZ2ze7rto8oqydzzemi1enZ ~]# ll /data/
total 0
drwxr-xr-x 2 root root 6 Jan 13 15:04 123.txt
drwxr-xr-x 2 root root 6 Jan 13 15:04 456.txt

Guess you like

Origin blog.csdn.net/weixin_44953658/article/details/124139912