개념 설명
가격
가격 계산기
https://calculator.aws/#/addService
EC2 요금
https://aws.amazon.com/ko/ec2/pricing/on-demand/
EC2 세팅
EC2에서 RDS 서버에 접속하기
https://developer88.tistory.com/303
자바 설치하기
자바 설치하기
https://pompitzz.github.io/blog/Java/awsEc2InstallJDK11.html#jdk-%E1%84%89%E1%85%A5%E1%86%AF%E1%84%8E%E1%85%B5
자바 11 설치하기
https://needneo.tistory.com/187
자바 버전 변경하기
https://programmer-ririhan.tistory.com/118
java 와 javac 버전 차이 날 때
https://programmer-ririhan.tistory.com/118
메이븐 설치 및 사용하기
메이븐 빌드 및 패키징
https://cornswrold.tistory.com/50
EC2 메이븐 설치하기
http://jmlim.github.io/etc/2019/07/11/aws-linux-maven-install/
오류 해결
ssh 접속시 WARNING: UNPROTECTED PRIVATE KEY FILE! 에러
https://suyeoniii.tistory.com/73
강의 내용 터미널 기록 내용
EC2 실행문 : 버킷 관련
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
버킷 내 파일 보기
[ec2-user@ip-1-1-4-106 ~]$ aws s3 ls s3://ssac-2nd-parkjonghyuk-bucket
2023-02-14 02:06:25 476692 Rickenbacker_4003_Matte_Black_Bass_2022_4174.jpg
2023-02-14 02:06:20 5381 nlp 미니 2.rtf
[ec2-user@ip-1-1-4-106 ~]$ aws s3 sync s3://ssac-2nd-parkjonghyuk-bucket/Rickenbacker_4003_Matte_Black_Bass_2022_4174.jpg ./img.jpg
[ec2-user@ip-1-1-4-106 ~]$ ls
__pycache__ app.py img.jpg
자바17 설치 파일 다운로드
[ec2-user@ip-1-1-4-106 ~]$ wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
--2023-02-14 05:52:59-- https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
자바 17 설치
[ec2-user@ip-1-1-4-106 ~]$ sudo yum localinstall jdk-17_linux-x64_bin.rpm
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Examining jdk-17_linux-x64_bin.rpm: 2000:jdk-17-17.0.6-9.x86_64
Marking jdk-17_linux-x64_bin.rpm to be installed
Resolving Dependencies
설치된 사항 확인
[ec2-user@ip-1-1-4-106 ~]$ yum list installed
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
GeoIP.x86_64 1.5.0-11.amzn2.0.2 installed
PyYAML.x86_64 3.10-11.amzn2.0.2 installed
acl.x86_64 2.2.51-14.amzn2 installed
acpid.x86_64 2.0.19-9.amzn2.0.1 installed
amazon-linux-extras.noarch 2.0.1-1.amzn2 installed
amazon-linux-extras-yum-plugin.noarch 2.0.1-1.amzn2 installed
amazon-ssm-agent.x86_64 3.1.1732.0-1.amzn2 installed
...
git 설치
[ec2-user@ip-1-1-4-106 ~]$ yum install git
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
You need to be root to perform this command.
[ec2-user@ip-1-1-4-106 ~]$ sudo yum install git
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
메이븐 설치
[ec2-user@ip-1-1-4-106 ~]$ sudo yum install -y apache-maven
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00
No package apache-maven available.
메이븐 설치 2
[ec2-user@ip-1-1-4-106 ~]$ sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
--2023-02-14 06:04:41-- http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo
메이븐으로 패키징
[ec2-user@ip-1-1-4-106 aws-demo]$ mvn compile
[INFO] Scanning for projects...
마리아디비 설치
[ec2-user@ip-1-1-4-106 ~]$ sudo install mariadb-client
install: missing destination file operand after `mariadb-client'
Try 'install --help' for more information.
[ec2-user@ip-1-1-4-106 ~]$ ls
jar 파일 실행
[ec2-user@ip-1-1-4-106 aws-demo]$ mvn clean compile package DskipTests=true
[INFO] Scanning for projects...
vi 편집기로 파일 에디팅
[ec2-user@ip-1-1-4-106 main]$ vi application.properties
EC2 실행문 : 패키지 설치 및 jar 파일 실행
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Last login: Mon Feb 13 16:10:52 on ttys001
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
(base) MacBook-Air:Desktop jongya$ ssh -i "jonghyuk-ec2-key.pem" ec2-user@ec2-54-164-15-159.compute-1.amazonaws.com
Last login: Mon Feb 13 07:28:50 2023 from 112.172.128.1
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-2/
18 package(s) needed for security, out of 18 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-1-1-4-106 ~]$ python -v
2.7
[ec2-user@ip-1-1-4-106 ~]$ python3 -v
Python 3.7.16 (default, Dec 15 2022, 23:24:54)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-15)] on linux
[ec2-user@ip-1-1-4-106 ~]$ sudo yum install python3-pip
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00
Package python3-pip-20.2.2-1.amzn2.0.3.noarch already installed and latest version
[ec2-user@ip-1-1-4-106 ~]$ sudo yum install python-pip
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:20.2.2-1.amzn2.0.3 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
python2-pip noarch 20.2.2-1.amzn2.0.3 amzn2-core 2.0 M
Transaction Summary
================================================================================
[ec2-user@ip-1-1-4-106 ~]$ ls
__pycache__ aws-demo jdk-17_linux-x64_bin.rpm jdk11
app.py img.jpg jdk-17_linux-x64_bin.rpm.1 jdk11.rpm
[ec2-user@ip-1-1-4-106 ~]$ cd aws-demo
[ec2-user@ip-1-1-4-106 aws-demo]$ ls
pom.xml src target
[ec2-user@ip-1-1-4-106 aws-demo]$ cd target
[ec2-user@ip-1-1-4-106 target]$ ls
classes jisoo-0.0.1-SNAPSHOT.jar maven-status
generated-sources jisoo-0.0.1-SNAPSHOT.jar.original test-classes
generated-test-sources maven-archiver
[ec2-user@ip-1-1-4-106 target]$ java -jar jisoo-0.0.1-SNAPSHOT.jar
패키지 파일 실행됨
세션 상태 보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
세션 상태 보기
[ec2-user@ip-1-1-4-106 target]$ netstat -ntpl
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
새로 세션 열고(jar 파일 실행) 다시 세션 보면 하나가 늘어있다.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 :::8080 :::* LISTEN 18601/java
tcp6 0 0 :::22 :::* LISTEN -
[ec2-user@ip-1-1-4-106 target]$ 아 있다. 보면 8080 포트가 새로 열린 것을 볼 수 있다.
[ec2-user@ip-1-1-4-106 target]$ 지금 다른 터미널로 8080포트를 열었기 때문에 새로운 포트를 볼 수 있다.
[ec2-user@ip-1-1-4-106 target]$ 그리고 여기서 8080 서버를 또 열려고 하면
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8080 was already in use.
[ec2-user@ip-1-1-4-106 target]$ 위처럼 실패가 뜬다
[ec2-user@ip-1-1-4-106 target]$ 왜냐면 동일한 포트를 또 열 수 는 없기 때문이다.
[ec2-user@ip-1-1-4-106 target]$ 그러면 내가 원치 않는 '좀비' 서버를 없애려면?
[ec2-user@ip-1-1-4-106 target]$ 킬(kill)이라는 명령어를 사용하면 된다.