Alibaba Elastic Compute Service
The course is part of this learning path
This course explores Alibaba's Elastic Compute Service and the features it offers to manage your Alibaba instances. We'll look at the main applications of the ECS service before moving on to a couple of guided demos from the platform to show you how to use the ECS service.
- Get a foundational understanding of the main concepts of Alibaba ECS
- Learn about the different instances available in Alibaba Cloud, including their features and use cases
- Learn the capabilities and limitations of ECS storage
- Learn how to connect instances together through ECS networking, specifically through the use of VPCs
- Learn how to create an ECS instance and attach a data disk to it
This course is intended for anyone looking to use Alibaba ECS to manage their Alibaba Cloud workloads, as well as anyone studying for the ACP Cloud Computing certification exam.
To get the most out of this course, you should have a basic understanding of the Alibaba Cloud platform.
Let's actually continue using the ECS from our previous demo. This is our ECS instance from our previous demo, which as you'll remember is running a little website for us. And currently that instance has one disk. Let's try adding another disk to that instance. Remember, although cloud disks are a component of ECS, you can actually purchase and manage cloud disks separate from any one instance, and that's what I want to demonstrate to you now. I want to create a new data disk separate from this ECS and then attach it to the ECS afterwards.
So let's go to storage and snapshots, and I'll click on disks. And from here, I can actually create a disk independently of an ECS instance. So I'll do that. I'll click on create disk. That will take me over to the disk purchase page. And my instance is in zone B. Remember, your disk and instance have to be in the same zone to work together. So I want to create my disk in zone B where my instance is. Let's create a PL1 50,000 IOPS per second, and 100 gigabytes. I can choose to create it from a snapshot if I want, and I can turn disk encryption on as well if I want. I'll buy one and we'll name the disk. I'll call that data-disk-high-io because it's a PL1 so it's a higher performance disk. I can add a description and some tags if I want. I can add it to your resource group. And then once I check the terms of service, I should be able to go to the preview page. This will give me some information about the disk. Its name, its size, its type.
When I'm satisfied, I can go ahead and click create. And that will create my new data disk for me. Then I can go back to the ECS console. Specifically from the disks page, I can now see all of my disks, including the new one that I've just created. You can see that it's unattached. So at this point what I could do is attach it to an ECS instance. So see this more here, there's an option under more that says attach. If I click on that, I can choose to attach my disk to this instance here, web-sg-new. And then I can choose if I want to have this disk deleted when the instance itself is deleted. I'm going to leave that unchecked. I can also choose if I've made snapshots of this disk to have those be deleted when the disk is deleted.
Again, I'm going to leave that unchecked as well. I want to give myself some recovery room in case I make a mistake. So I don't want my disk to be automatically released with my ECS, and I also do not want my automatic snapshots to be released when I release the disk. You can turn these on if you want, I'm not going to. I'll then click attach. And that should go ahead and attach my disk to the instance. It could take a moment to attach. If I refresh, you can see that it's now listed as in use, meaning it's attached to my instance. If I go back to the instances list and click on the instance ID, I should be able to go over to disks and see that I now actually have two disks. So I can see both of my disks here.
So this is great, but there is a problem. The problem is that this data disk has been attached, but I haven't mounted it yet and I haven't given it a file system. So to do that, I actually need to log into my instance and get a look at my blocked devices. So let's go ahead and do that. So I'll go ahead and log in. Oops, I need to go get my IP address. Then we'll ssh into this instance and take a look at our blocked devices. Oop, you can see that now I'm getting a warning. Why is that? Well, in the previous demo, I actually detached my elastic IP from my old instance and attached it to a new machine, and that new machine has a different host identification than the old one does, so ssh thinks something bad is happening. It thinks maybe someone trying to trick me into logging into a Trojan horse of some kind, a machine that's different from the original.
So what I'm going to do is go ahead and remove the contents of my ssh known host file and try again. Great. And then type in my password. Oop, just one second. Typed it wrong. And then there we go, we are in the ECS instance. So maybe we can get a list of our blocked devices. You can see that there's one blocked device here, dev vda1. This is our 40 gigabyte system disk. I should have available for me as well an additional disk, the data disk, which you can see down here, dev vdb. Currently, this isn't partitioned or mounted or anything. I need to go ahead and do that now in order to use the disk.
So what we need to do is use a command like mkfs. So let's go ahead and do that. First, I actually need to go ahead and partition the disk. So let's do that. Oops. Oh, I typed sdb. Let's type in vdb. Okay. Let's get a list of help. So in fdisk, what we want to do here is... This doesn't need to be a bootable disk, so we won't toggle that, but I do want to create a new partition. So I can do that using n. Let's go ahead and add a new partition. It'll be a primary partition. It will be partition number one. Let's have it take up the entire disk. And now I have a Linux partition table on this disk, so I should be able to quit. So first I'll write the changes and then I'll quit. Now, if I go back to fdisk l, you can see there's a partition, a primary partition on my new disk.
So now we can go ahead and format this disk. So what I'm going to do is use one of the mkfs commands. We'll make a new ext4 partition on dev vdb1. And you can see that we're now creating a journal and that partition now has an ext4 file system on it, which means we can mount that partition and start doing stuff on this disk. So let's actually go ahead and do that. So let's see. I could choose to mount this disk anywhere. I'll just mount it in my home folder, data disk, and we'll do, again, let's list our disks. Okay, vdb1. And let's mount that on this new directory data disk.
So I'll say mount dev vdb1 on data disk . And if I now run the mount command, I can see I've mounted vdb1 on this folder, data disk. And let's put a file in there. Great. So now there's a file on my new disk. Let's unmount it. All right. Whoops. I mean, umount, sorry. It should be umount under Linux. Oh, great. It's now not mounted anymore. If I were to go into the data disk folder, it's empty because it's no longer serving as the mouth point for my data disk. So the next thing to do would be to actually try removing the disk from this instance now that it's unmounted and attaching it to another instance, just to show you that the file is still there and that I can in fact move disks around between instances.
So let's go ahead and create a new instance and attach the disk to that new instance. So before I do any of that, let's go back to storage and snapshots, go back to disks and let's try detaching our data disk. So I'll click on detach. I'll click okay. I have already unmounted the file system so it's safe to do this. Let's refresh. And you can see it takes a little bit longer to detach than it does to attach, but it should be done in just a second. We'll give it some time. Well, that's happening. We'll create a brand new instance. And this time I'll do things a little bit differently. Again, it has to be in zone B because my disk is in zone B. So I have to make sure the instance is in zone B, but this time I'm going to choose an entry-level instance, a burstable type because they're cheaper. So let's do that.
Choose zone B. Choose an entry-level instance. We'll choose one of the cheaper types. We'll choose a fifth generation T burstable instance with 512 megabytes of RAM and 1vCPU. This is our cheapest type. These are quite low cost instances. I'll go ahead and run Ubuntu on this instance. I can actually if I want, attach the data disk from here, but I won't, I'll wait until later. I'll go to networking. We'll skip a lot of the configuration details because we want to just do this quickly. I'll give him his own public IP, not an elastic IP. Put him in the same security group as my other instances, the same VPC and VSwitch. He'll be in zone B, system configuration.
I will again choose a password. So choose ourselves a password here. Oops. Then make sure I type it the same way both times. There we go. We'll call him disk test, disk test. Grouping, we won't change anything on the grouping page. Automatic release. Agree to the terms and then create. So now we have two instances. So we'll try taking our disk off of our other instance and mounting it on this new instance. So I can close that tab. And here we are back on the instances list and you can see that my new instance is starting up. So after waiting a moment, that new instance is running. Let's go ahead and log into it. So I'll take his public IP and plug that into the console. So let's log out of our original instance. Log in to the new one.
Okay, so I can type in my password, get all logged in here. And we're now on our new instance, which is the disk test instance. So let's go ahead and attach our disk to that new disk test instance. So I'll go back to the disks part of the console, we'll list out all our disks. You can see, I now have two system disks, one for my new image, excuse me, one for my new burstable instance that I just created, one for my general purpose instance that I was using before. And then the unattached data disk, which I just removed from my general purpose instance. So for that disk, I'll click on attach and I have to choose an instance, and I'll choose disk test, which is our new instance. Oops, but we can't attach because that instance does not support ESSDs. So that's a problem.
So our data disk is of a type that the generation five burstable instance doesn't support. That's no problem. It just means that we have to recreate a new pay as you go instance. And by the way, this is a good reason to use pay as you go instances. If you had just created a subscription instance, and then you discovered this problem, then that would be too bad because then you'd be stuck with the instance. So I'll fast forward through this creation process. Again, we'll make a generation six instance and then I'll pick up where we left off. We have now gone ahead and created a generation six instance, which should be able to mount our ESSD disk.
So some older instance classes don't support an SSD, so we had to delete our previous burstable instance and make a new gen six instance instead, which is now up and running here. So let's go ahead over to disks, and we'll go ahead and attach our data disk to that new instance. So I'll click attach. I'll choose my instance. Here it is, disk test. I'll uncheck both of these. I don't want to delete automatic snapshots. Now I'll click attach. And if we wait a moment, that data disk should attach itself to our new instance. And once we mount it, we should see that it contains that file we created earlier. So from the console SSH into my new instance, this one here.
Let's grab that IP address. Yes, we want to trust this instance. Type in my IP. And here I am in the console. This instance is also running Ubuntu. So if I run fdisk, I can now see that I have two disks, my system disk and a data disk, and it's the 100 gigabyte disk. Then we just mount it. I'll create a new directory in my home directory called test. And I'll mount dev vdb1 onto test. Let's see what happens. I go into test and I ls. Sure enough, there's my text file. And it looks correct. So you can unmount and remount disks freely moving them between ECS instances as long as those instances are in the same zone. And that's it for this demo. Thank you for joining me.
Alibaba Cloud, founded in 2009, is a global leader in cloud computing and artificial intelligence, providing services to thousands of enterprises, developers, and governments organizations in more than 200 countries and regions. Committed to the success of its customers, Alibaba Cloud provides reliable and secure cloud computing and data processing capabilities as a part of its online solutions.