AWS - Article 01 (Introduction to AWS and AWS EC2 instances and simple and practical)

1 Introduction

  • What is AWS?
    Insert image description here
    Okay, I'll just take this many screenshots, and search for more by yourself...

2. Create an AWS account

  • The official website address is as follows:
    https://aws.amazon.com/cn/ .
    Insert image description here
  • When registering, if you have a Google mailbox, it is best to use Google mailbox, as follows:
    Insert image description here
  • After successfully registering according to the prompts, you can log in to use it.
    Insert image description here
  • Just click around and seem to see something.
    Insert image description here
    Continue...

3. EC2

3.1 Start a new EC2 instance

3.1.1 Entrance

  • as follows:
    Insert image description here
    Insert image description here

3.1.2 Set Name + Select Service

  • as follows:
    Insert image description here

    Insert image description here

3.1.3 Create key pair

  • as follows:
    Insert image description here
    Insert image description here
  • Click Create Key Pair to download it directly to your computer, and select the newly created key pair by default.
    Insert image description here

3.1.4 Network Settings - Security Group

3.1.4.1 Initial setup

  • as follows:
    Insert image description here

3.1.4.2 Add security group rules (open new ports)

  • [Edit Inbound Rules]–>[Add Rule]–>[Save Rule], as follows:
    Insert image description here
    Insert image description here

3.1.5 Configuration storage

Insert image description here

3.1.6 Start an instance

  • as follows:
    Insert image description here
    Insert image description here
    Insert image description here

3.1.7 View instances

  • as follows:
    Insert image description here

    Insert image description here

3.2 Connect to EC2 instance

3.2.1 Method 1——Instance Connect

  • as follows:
    Insert image description here
    Insert image description here
    Insert image description here

3.2.2 Method 2 - SSH client

  • Just follow the prompts, as follows:
    Insert image description here
  • Mac computers should be able to connect using the terminal that comes with them, but there is no response after I command here. It seems that I can’t connect to the Internet. I have always had this problem when using ClashX locally, and it doesn’t work if I exit. But at least I can connect to the Internet without exiting ClashX. , what’s going on with this terminal, I don’t know why, forget it, let’s talk about this later.
    Insert image description here
    Insert image description here
  • Therefore, instead of SecureCRTconnecting, copy the key to another remote server, execute the installation steps, and you can connect, as follows:
    # 连接命令
    ssh -i "自己的密钥文件" ec2-user@公有IPv4DNS    # ec2-user 默认用户
    
    Insert image description here

3.3 Simple and practical

3.3.1 Simple commands

  • To view the version, use the following command to view the version of Amazon Linux
    cat /etc/system-release
    
    Insert image description here
  • Switch to root user
    sudo -ssudo su
    
    Insert image description here
  • Update software
    yum update -y
    
    Insert image description here

3.3.2 Install application

3.3.2.1 Install git

  • Install git as follows:
    yum install git -y
    
    git --version
    
    Insert image description here

3.3.2.2 Install jdk

  • Simply use the command to install it, as follows:
    yum install java-17-amazon-corretto-devel.x86_64
    
    Insert image description here
    Insert image description here

3.3.2.3 Install tomcat

  • Download tomcat as follows:
    • Go to the official website first:
      Official website address: https://tomcat.apache.org/download-10.cgi .
    • Copy download link
      https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.11/bin/apache-tomcat-10.1.11.tar.gz
      
      Insert image description here
    • Then, download with the command
      wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.11/bin/apache-tomcat-10.1.11.tar.gz
      
      Insert image description here
  • Unzip and install tomcat as follows:
    tar -zxvf apache-tomcat-10.1.11.tar.gz
    
  • Start as follows:
    ./startup.sh
    
  • Check operation status
    ps -ef | grep java
    
    lsof -i:8080
    
    netstat -na | grep 8080
    
    Insert image description here
  • Browser access
    • Before accessing, remember to open the port. For details, refer to: "3.1.4.2 Add security group rules (open new ports)
    http://公网IP:8080
    
    或者
    
    http://公有 IPv4 DNS:8080
    
    Insert image description here
    Insert image description here
    Insert image description here

3. Some configuration files

  • Configure user information, etc.
    cat /etc/cloud/cloud.cfg
    
    Insert image description here
    Insert image description here

4. About AMI

  • When viewing instance information, you can see the AMI, as follows
    Insert image description here

  • So try to launch the instance from the AMI as follows:
    Insert image description here
    Insert image description here

5. Attention

5.1 About amazon-linux-extras

  • What is amazon-linux-extras?
    • Amazon Linux Extras is a component of the Amazon Linux 2 distribution that allows users to install and manage additional software packages and services. Amazon Linux Extras allow users to easily obtain and install a variety of software packages that may not be included in the standard Amazon Linux 2 repositories.
    • Namely: Amazon Linux Extras provide an easy way to extend the functionality of Amazon Linux 2.
  • Depending on the version you are using, check whether this command is available, as follows
    Insert image description here
    • Check the Amazon Linux version as follows:
      cat /etc/system-release
      
      Insert image description here
      Insert image description here
  • View installable software
    amazon-linux-extras -v
    
    Insert image description here
  • Use amazon-linux-extrasthe command to install nginx, as follows:
    • Install
      sudo su
      amazon-linux-extras install -y nginx1
      nginx -version
      
      Insert image description here
      Insert image description here
    • Start nginx
       systemctl start nginx
      
      Insert image description here
    • Open port 80 and access nginx
      Insert image description here

Guess you like

Origin blog.csdn.net/suixinfeixiangfei/article/details/132009440