Creating an AWS EC2 EC2 Instance (Amazon Linux AMI) 2

Introduction

This time, I will try to build a Linux server using AWS EC2. The AWS screen has changed since I created it. Since the UI of Internet services always changes suddenly, even if it is described in Qiita as know-how, it means that it is not immediately obsolete. So I'll try again. This is a reprint of the article I wrote before this article.

Contents to be implemented this time

Use AWS EC2 to build a Linux server with Amazon Linux AMI2.

構成.jpg

reference

Tutorial: Getting started with Amazon EC2 Linux instances This is a description of creating an instance of Amazon's EC2 Linux. We will carry out according to this.

"Amazon EC2 Instance Types" A description of the instance type.

the term

What is AWS EC2?

AWS description

According to Amazon's EC2 page, the following is stated first:

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable computing performance in the cloud. It is designed to make web-scale cloud computing easy for developers. Amazon EC2's simple web services interface allows you to get and configure the features you need without hassle. It provides powerful control over your computing resources and can run on Amazon's proven infrastructure.

I'm not sure what it is, but I think it's a virtual server.

AWS EC2 pricing

There is an explanation on the AWS page about the charges, but it's difficult to understand. There is a lot of information on the net, but I still don't understand. So, I think the AWS EC2 charges for * on-demand * are roughly as follows.

--Instance startup time --DL data transfer amount

If you use an Elastic IP address,

--Elastic IP address usage time (only when Instance is not started)

Instance startup time is initially charged for 1 minute and then takes time or seconds. The DL data transfer fee is about * 1.088 USD / hour * for * c6g.8xlarge *. If the region is Tokyo. DL data transfer is free up to 1GB and costs $ 0.114 / month up to 9.999TB thereafter. After that, it will be a little cheaper, but it is set.

The Elastic IP address is for fixing the IP address. If you do not use it, stopping Instance will release the IP address, and when you start it, it will change to another IP address. It is 0.005 USD / hour.

It is a fee system that is difficult to understand. Launch Instance for one day: 0.0136 USD x 24 = 0.3264 USD 1 month (31 days): 0.3264 USD x 31 = 10.1184 USD It's difficult because the amount of data transferred depends on how much you use. Since the Elastic IP address is taken when the Instance is stopped, it does not take if it is kept running as described above. It costs $ 0.0136 to start and $ 0.005 to stop, so it's definitely cheaper to stop if you can.

AWS EC2 overview

Creating an AWS EC2 Instance

Then, [Tutorial: Getting started with Amazon EC2 Linux instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html?trk=em_a131L000005jw1jQAA&trkCampaign=pac_EC2_docs_GettingStarted_GlobalEM&sc_channel=em_GlobalEM&sc_channel=em_GlobalEM&sc_channel=em_GlobalEM&sc_channel=em_GlobalEM&sc_channel=em NAMER & sc_country = mult according & sc_content = AWS_Webpage & mkt_tok = eyJpIjoiTVdJeFlXRTVNelJsTWpOaCIsInQiOiJKY0tIN1NYckFZeXNobUUyWmpuSjVlMEJuZmV1ZGh2ZkFLK2dQRHljTUd0Qlgrd1ZpV3VaM08zNTE0KzQ3NHlwMGdlYnl5MURlU0tQeFVna2hFdWpvdnBjS3RqTUFPYUNyUVwva0tDME04Vk9rTnhqc1poOG1XdnlJUU1sMTlqdTBsbVh5NjZQNElSNmhNWFdQcjBIKzl3PT0ifQ% 3D% 3D), will in turn make the creation of the Instance.

1. Go to AWS EC2 screen

First, log in to AWS. Then choose EC2 for your service. This is the basics, so I won't explain it. If you press "Instance" on the left menu on the EC2 screen, the following screen will appear. Here, press the "Start Instance" button. インスタンスの起動.jpg

2. Select Amazon AMI

Next is the selection of Amazon AMI (Amazon Machine Image). It seems that about 40 AMIs are prepared. In short, I think it's what kind of OS to choose, but like last time, select "Amazon Linux AMI 2". The CPU uses 64-bit (Arm). Looking at the information on the net, it is natural, but there seems to be a difference in performance between X86 and Arm, so I thought that choosing the instance type depending on which CPU you want to use is one way.

3. Instance type selection

インスタンスの選択.jpg

This time, select "c6g.8xlarge". For instance types, "C6g.8xlarge" is Type: c6g Size: 8xlarge The type "c" indicates the classification, "6" is the 6th generation, and "g" is the AWS Graviton2 processor. It seems that this processor is faster and cheaper. According to "Amazon EC2 Instance Types", there seem to be various types.

The group of instances is broadly divided into "general purpose", "computer optimization", "memory optimization", "fast computing", and "storage optimization".

Well, there are various explanations, but at this point I already don't know which one to choose.

group Explanation
General purpose CPU、メモリなどバランスがとれており、General purpose的に使えるもので、特にないならこれを選ぶのがいいかと思います。
Computer optimization It means that the CPU performance is high. It is applied even though there is a lot of processing.
Memory optimization The memory is optimized, but I wasn't sure.
High speed computing There is a separate coprocessor. GPU etc. will be added separately. It still depends on the application.
Storage optimization There seems to be NVMe SSD and HDD.

Do you choose a group first? If you don't understand it, it will be general purpose. This seems to be difficult to choose. Even if a company chooses it, it is necessary to clarify the purpose, but first of all, I do not know which one, and even if it is said, I think that all are included. I wondered if it would be a safe general purpose.

Once the classification is decided, I think I will choose the type and then the size.

If you select with, the key pair will be selected next. If this is your first time, generate a key as "Create a new key pair". This key is very important because you will use it to access your Instance in the future, so you need to save it.

キーペア.jpg

If you select it with this, the rest will be initialized and an Instance will be generated. It was easier than I expected. After this, Instance will stop stopping for the time being. Otherwise, it will be in the start state and you will be charged.

After that, I think that all you have to do is start Instance and make an SSH connection. In my case, I connect with Tera Term. The IP address will be displayed when you start Instance, so connect to it. The initial value is "ec2user" as the user name and no password. Since it is necessary to set the key, you can set the key DL above.

in conclusion

It is a rehash.

Recommended Posts

Creating an AWS EC2 EC2 Instance (Amazon Linux AMI) 2
AWS EC2 2nd SSH connection to EC2 Instance (Amazon Linux2)
Create an AWS Cloud9 development environment on your Amazon EC2 instance
Create Amazon Linux with AWS EC2 and log in
[AWS EC2] How to install Maven on Amazon Linux 2
[AWS EC2] Settings you want to do on Amazon Linux 2
Launch NEM Symbol testnet node on AWS EC2 (Amazon Linux2)
Install pyenv on EC2 (Amazon Linux)
Introducing Amplify to Amazon Linux 2 AMI
Seamlessly join a Linux EC2 instance to AWS Managed Microsoft AD
Change AWS EC2 instance from t2 to t3
I'll install Ruby on EC2 (Amazon Linux2) 2020
AWS EC2 instance launch and ssh connection
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
EC2 (Amazon Linux) certbot-auto renew error /pkg_resources.DistributionNotFound: The'virtualenv == 15.1.0'
Create an AWS GPU instance to train StyleNet
Security settings required after launching an EC2 instance
Jupyter Notebook Settings-How to use (EC2 Amazon Linux 2)
How to terminate an AWS EC2 instance (remove security G and delete key pair)
List AWS ami
[AWS EC2] How to install only MySQL client on Amazon Linux 2 and connect to RDS
code-server online environment (3) Launch an EC2 instance with Boto3
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Deployment procedure on AWS (2) Server (EC2 instance) environment settings
Copy files directly from Amazon EC2 (Amazon linux) to S3
I tried to get an AMI using AWS Lambda
Create an environment for MkDocs on Amazon Linux (attempted)
[AWS] How to expand disk space on Amazon linux