노력과 삽질 퇴적물

AWS: EC2 인스턴스 서버 기본세팅 본문

프로그래밍note/서버 및 통신

AWS: EC2 인스턴스 서버 기본세팅

MTG 2015. 1. 22. 12:34






0. 필요한 파일


파일명

예시 경로

 apache-tomcat-7.0.56.tar.gz

[#다운로드]

 (wget으로 다운로드 및 설치)

 MySQL

 (wget으로 다운로드 및 설치)

 JDK 1.7 for Linux
 [#다운로드]

 (wget으로 다운로드 및 설치)

 putty.exe [#다운로드]

 (특이사항 없음)

 puttygen.exe [#다운로드]

 (특이사항 없음)


* 기존에 아마존 계정이 있는 경우 좀더 간편해집니다.

AWS 계정 활성에는 VISA카드등 해외결제가 지원되는 체크/신용카드가 필요합니다.

[# 아마존 클라우드 (Amazon EC2) 서버 무료로 사용하기]






1. EC2 인스턴스 생성


1) 인스턴스

0123456


해당 pem파일은 다음에 설명드릴 '터미널 연결'에 필수입니다.



2) Elastic IP

좌측 메뉴 패널중, NETWORK & SECURITY>Elastic IPs로 들어갑니다.

Allocate New Address로 새로운 고정 IP를 만들고,

Associate Address를 통해 원하는 인스턴스에 적용시킵니다.

putty등으로 접속시, 적용된 고정IP로 이용이 가능해집니다.






2. 터미널 연결


1) *.pem -> *.ppk

puttygen 실행후, Conversions>Import Key 메뉴

012



2)ppk연결






3. 개발도구 설치


1) root계정 및 wget설치

-> 접속시 기본경로: /home/ec2-user

1
2
3
4
5
6
7
8
9
10
login as: ec2-user
[ec2-user] $ sudo passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[ec2-user] $ su
Password:
[root] # yum -y update
[root] # yum -y install wget



2) yum, 개발도구 다운로드와 설정

-> 아파치 톰캣

-> MySQL

-> JDK

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
[root] # cd /usr/local
[root] # wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.56/bin/apache-tomcat-7.0.56.tar.gz
[root] # tar -xvf apache-tomcat-7.0.56.tar.gz
[root] # ln -s apache-tomcat-7.0.56 tomcat
[root] # vi tomcat/conf/server.xml
(vi EDITOR)
... ... ...
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
... ... ...
[root] # cd tomcat/bin/
[root] # ./startup.sh
 
[root] # wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root] # rpm -ivh mysql-community-release-el7-5.noarch.rpm
 
            (OR)   yum install -y mysql-community-release-el7-5.noarch.rpm
[root] # yum install -y mysql
[root] # yum install -y mysql-server
[root] # yum install -y mysql-devel
[root] # chgrp -R mysql /var/lib/mysql
[root] # chmod -R 770 /var/lib/mysql
[root] # service mysqld start
[root] # mysqladmin -u root password
New password:
Confirm new password:
[root] # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-x64.tar.gz"
[root] # tar -xvf jdk-7u71-linux-x64.tar.gz
[root] # ln -s jdk1.7.0_55/ jdk
[root] # vi /etc/profile
(vi EDITOR)
... ... ...
if [ $USER = "mysql" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384
fi
fi
 
export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:$JAVA_HOME/bin
 
[root] # source /etc/profile
[root] # java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)






4. 용량 추가


1) 용량 인식이 안 될때

Expanding a Linux Partition - Amazon Elastic Compute Cloud [BradG42nst의 답변]



2) 볼륨추가로 용량확장

ELASTIC BLOCK STORE>Volumes에서 새 볼륨을 생성합니다.

Availability Zone: 용량을 붙이려는 인스턴스의 Availability Zone

Attach Volume으로 새볼륨을 인스턴스에 붙이는데
/dev/XXX에서 sdf~sdp로 추천되고 있습니다. (출처유실)


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
$ su
Password:
# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
 
Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 sectors
... ... ...
 
#         Start          End       Size          Type            Name
 1         2048           4095      1M  BIOS boot parti
 2         4096     12587007      6G  Microsoft basic
 
Disk /dev/xvdp: 21.5 GB, 21474836480 bytes, 41943040 sectors
... ... ...
# cat /proc/partitions
major minor  #blocks  name
 
 202         0   10485760 xvda
 202         1         1024 xvda1
 202         2     6291456 xvda2
 202      240   20971520 xvdp
# mke2fs -F -t ext4 /dev/xvdp
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
... ... ...
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
# mkdir /data   (/data가 non exist일 경우.)
# mount /dev/xvdp /data
# vi /etc/fstab
...(vi 에디터)...
/dev/xvdp                               /data                   ext4    defaults        0 0






참고 자료


아마존 EC2 (Amazon EC2) 인스턴스.. : 네이버블로그

아마존 서버(AWS)를 이용해서 무료 클라우드(cloud) 서버(EC2)를 만들어 보자.

아마존 웹서비스 - 생활코딩


jmkook77: 아마존( Amazon ) AWS 윈도우( Window )에서 접속 - Putty , pem ppk 변환
개발이 하고 싶어요 :: 아마존 웹 서비스(AWS) EC2 파일 전송 FileZilla
리눅스 MySQL 최신버전 설치 - Jmnote

Installing MySQL on an EC2 Micro Instance

install MySQL Server 5.6 on CentOS 7 / RHEL 7

Install Eclipse Classic 4.2.1 in RHEL/CentOS 6.3/5.6, Fedora 17-12

Download Oracle Java JRE & JDK using a script - Ivan-Site.com


Screencast: mounting EBS volume to an EC2 instance in Amazon AWS





기타. 변경이력


일자

변경이력

2015-01-22

 초안