1. Instance Stop

- Instances 메뉴를 선택하여 실행 중인 Instance 를 중지한다. 필수는 아니다.

 

2. Volume의 Snapshot 생성

- Instance에서 사용하던 Volume를 백업하기 위해 Snapshot을 생성한다.

- 오래 걸린다. 커피한잔 먹고 오자.

 

3. Detach Volume

- Instance에서 사용하던 Volume를 분리하자.

- 분리전에 Tag 정보를 메모하자.

 

4. Snapshot을 이용하여 Create Voume

- Snapshot을 이용하여 Volume를 생성하며 이때 변경하고자하는 Volume Size를 설정한다.

- IOPS 옵션도 설정한다.

 

5. Instance에 생성한 Volmue Attach

 

6. Start Instance

 

반응형
블로그 이미지

조이풀 라이프

Lift is short, enjoy the life

,

Docker 설치 및 기본 사용 방법

간단한 설치 방법 및 기본 사용 방법에 대해 설명하도록 하겠습니다.

 

Amazon Web Services(AWS) EC2(Ubuntu)를 생성

(기본으로 AWS의 EC2에서는 docker 패키지를 사용 가능)


docker 설치

$ sudo apt-get install docker.io


서비스 등록

$ sudo update-rc.d docker.io defaults


Docker Engine 정보 확인

$ sudo docker.io info

Containers: 0

Images: 0

Storage Driver: devicemapper

 Pool Name: docker-202:1-18845-pool

 Data file: /var/lib/docker/devicemapper/devicemapper/data

 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata

 Data Space Used: 291.5 Mb

 Data Space Total: 102400.0 Mb

 Metadata Space Used: 0.7 Mb

 Metadata Space Total: 2048.0 Mb

Execution Driver: native-0.1

Kernel Version: 3.13.0-24-generic

WARNING: No swap limit support



docker 명령어로 사용하기 위한 심볼릭 링크 생성

$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker


docker 명령어에 대한 권한 부여 (ubuntu도 사용할 수 있도록)

$ sudo usermod -G docker ubuntu


ubuntu 사용자로 logout->login하고 docker info 명령어 실행

$ docker info

Containers: 0

Images: 0

Storage Driver: devicemapper

 Pool Name: docker-202:1-18845-pool

 Data file: /var/lib/docker/devicemapper/devicemapper/data

 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata

 Data Space Used: 291.5 Mb

 Data Space Total: 102400.0 Mb

 Metadata Space Used: 0.7 Mb

 Metadata Space Total: 2048.0 Mb

Execution Driver: native-0.1

Kernel Version: 3.13.0-24-generic

WARNING: No swap limit support



Dicker 클라이언트 / 서버 확인

$ docker version

Client version: 0.9.1

Go version (client): go1.2.1

Git commit (client): 3600720

Server version: 0.9.1

Git commit (server): 3600720

Go version (server): go1.2.1

Last stable version: 1.0.0, please update docker




ubuntu 이미지 Docker Hub Regstry에서 다운로드

$ docker pull ubuntu:latest

Pulling repository ubuntu

ad892dd21d60: Download complete

511136ea3c5a: Download complete

e465fff03bce: Download complete

23f361102fae: Download complete

9db365ecbcbb: Download complete 



다운로드 이미지 확인

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

ubuntu              latest              ad892dd21d60        7 days ago          275.4 MB 



Docker Container 생성 및 실행

$ docker run [옵션] [--name {컨테이너명}] {이미지명}[:{태그명}] [컨테이너로 실행할 명령어] [변수]


중요 옵션

-d : 백그라우드 실행. 

-i : 컨터이너의 표준 입력. /bin/bash등으로 컨테이너를 조작할 때 지정.

-t : tty(단말 디바이스)를 확보. /bin/bash등으로 컨테이너를 조작할 때 지정.

-p {호스트 포트번호} : {컨테이너 포트번호}  : Docker서버의 호스트와 포트 맵핑을 구성



ubuntu이미지에서 ubuntu1 컨테이너를 생성

$ docker run -it --name ubuntu1 ubuntu /bin/bash

root@b5c2f7a3f4de:/# 



nginx 설치 및 확인

root@b5c2f7a3f4de:/# apt-get update

root@b5c2f7a3f4de:/# apt-get install -y nginx


root@b5c2f7a3f4de:/# dpkg -l nginx

Desired=Unknown/Install/Remove/Purge/Hold

| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend

|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)

||/ Name                                                 Version                         Architecture                    Description

+++-====================================================-===============================-===============================-==============================================================================================================


ii  nginx                                                1.4.6-1ubuntu3                  all                             small, powerful, scalable web/proxy server

root@b5c2f7a3f4de:/# 


[Ctrl]+[d]로 bash 종료

- 종료하면 컨테이너 ubuntu1은 정지 상태가 된다.



Docker 컨테이너 리스트 확인

$ docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

b5c2f7a3f4de        ubuntu:latest       /bin/bash           12 minutes ago      Exit 0                                ubuntu1  


STATUS 항목 - 실행중 = UP {실행시간} / 정지 = Exit {종료코드}



Docker 이미지 생성

$ docker commit {컨테이너명}|{컨테이너 ID} [{사용자명}/]{이미지명}


$ docker commit ubuntu1 park/nginx

948a317510591c8af2ca49e205cc0558141ce5e18acc98c0e834cc8e93cf86cd



생성된 이미지 확인

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

park/nginx          latest              948a31751059        2 minutes ago       295.9 MB

ubuntu              latest              ad892dd21d60        7 days ago          275.4 MB



Docker 컨테이너를 백그라운드에서 실행

$ docker run -d -p 80:80 --name nginx1 park/nginx /usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf

06f09849c046f5a949e7d82f52b140cfecd85b2d5f813a12c0adb431a5ea7a52




컨테이너 실행 상태 확인

$ docker ps

CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                NAMES

06f09849c046        park/nginx:latest   /usr/sbin/nginx -g d   27 seconds ago      Up 25 seconds       0.0.0.0:80->80/tcp   nginx1




웹 서비스 기동 상태 확인

$ curl localhost:80



Docker 컨테이너 정지

$ docker stop {컨테이너명}|{컨테이너 ID}


$ docker stop nginx1

nginx1


$ docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES



Docker 컨테이너 삭제 및 이미지 삭제

$ docker rm {컨테이너명}|{컨테이너 ID} => 컨테이너 삭제

$ docker rmi {이미지명}|{이미지ID} => 이미지 삭


$ docker ps -a

CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES

06f09849c046        park/nginx:latest   /usr/sbin/nginx -g d   17 minutes ago      Exit 0                                  nginx1

b5c2f7a3f4de        ubuntu:latest       /bin/bash              40 minutes ago      Exit 0                                  ubuntu1



컨테이너 삭제

$ docker rm nginx1

nginx1


$ docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

b5c2f7a3f4de        ubuntu:latest       /bin/bash           40 minutes ago      Exit 0                                  ubuntu1


$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

park/nginx          latest              948a31751059        25 minutes ago      295.9 MB

ubuntu              latest              ad892dd21d60        7 days ago          275.4 MB



이미지 삭제

$ docker rmi park/nginx

Untagged: park/nginx:latest

Deleted: 948a317510591c8af2ca49e205cc0558141ce5e18acc98c0e834cc8e93cf86cd



$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

ubuntu              latest              ad892dd21d60        7 days ago          275.4 MB



Docker 컨테이너 실행

$ docker start [-i] {컨테이너명}|{컨테이너 ID}

$ docker start -i ubuntu1

ubuntu1

       root@b5c2f7a3f4de:/#


반응형
블로그 이미지

조이풀 라이프

Lift is short, enjoy the life

,

아마존 AWS 시작하기

IT/AWS 2016. 5. 10. 11:11

페이스북에서 AWS를 처음 사용하는 사용자를 위한 좋은 자료를 링크하여 공유합ㄴ디ㅏ.

 

[AWS EC2 인스턴스 생성하기]
http://wildpup.cafe24.com/archives/696

[AWS EC2에서 IAM Role 사용하기]
http://wildpup.cafe24.com/archives/673

[EC2 Security Group]
http://wildpup.cafe24.com/archives/720

[AWS RDS와 인스턴스 생성]
http://wildpup.cafe24.com/archives/734

[AWS RDS 스냅샷 이용하기]
http://wildpup.cafe24.com/archives/754

[AWS RDS의 자동 백업 기능 사용하기]
http://wildpup.cafe24.com/archives/767

[AWS RDS의 Read Replica 생성]
http://wildpup.cafe24.com/archives/775

[AWS S3의 소개와 간단한 사용]
http://wildpup.cafe24.com/archives/785

[S3 버킷과 객체의 권한을 설정하여 웹에 공개하기]
http://wildpup.cafe24.com/archives/804

[AWS S3의 버저닝(Versioning) 기능 사용하기]
http://wildpup.cafe24.com/archives/821

[AWS S3와 CloudFront 사용하기]
http://wildpup.cafe24.com/archives/830

[AWS CloudWatch와 Alarm 생성]
http://wildpup.cafe24.com/archives/847

[AWS ELB를 이용한 요청분배]
http://wildpup.cafe24.com/archives/867

[AWS Auto Scaling을 이용하여 EC2 인스턴스를 자동으로 확장하기]
http://wildpup.cafe24.com/archives/890

[AWS Access Key와 Secret Key를 만들고 CLI 사용해보기]
http://wildpup.cafe24.com/archives/929

[AWS SQS 간단히 사용해 보기]
http://wildpup.cafe24.com/archives/945

[AWS CloudFormation을 이용하여 서버 구성하기]
http://wildpup.cafe24.com/archives/971

[AWS SES의 소개와 간단한 사용법]
http://wildpup.cafe24.com/archives/1003

[AWS ElastiCache의 소개와 간단한 사용(Memcached)]
반응형
블로그 이미지

조이풀 라이프

Lift is short, enjoy the life

,

AWS EC2 인스턴스 다른 Region 에 복제/이전

이전 처리 개념


  1. 원본 Region
    1. 실행중인 EC2 instance를 복제
    2. 복제한 instance가 실행되면 중지상태로
    3. 해당 instance의 Volume의 Snapshot 생성
    4. Snapshot 복사메뉴에서 region 선택

  2. 이전받을 Region
    1. 원본에서 복제되어온 Snapshot 으로부터 Volume 생성
    2. 원본 EC2 Instance와 같은 사양으로 Instance 생성 후 중지상태로
    3. Volume 떼어내고 1.의 Volume 붙이기
    4. Instance Start
    5. Instance Running 되면 Public DNS 주소로 접속하여 검증
반응형
블로그 이미지

조이풀 라이프

Lift is short, enjoy the life

,

아마존( Amazon ) AWS 윈도우( Window )에서 접속 - Putty , pem ppk 변환

아마존 서버 생성시 다운받은 pem 파일을 이용하여 ssh/sftp 접속하는 방법

1. putty 를 다운받습니다.

 http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

 여기에서 putty<version>-installer.exe 를 받으세요.
 혹은, putty.exe, psftp.exe, puttygen.exe, pageant.exe 를 따로 설치하셔도 됩니다.
  puttygen.exe 는 pem 파일을 putty에서 사용가능하게 변경하며
  pageant.exe 는 pem 파일을 통해 putty, psftp 가 서버에 접속 가능하게 해줍니다.

2. pem 파일 변환

 1) puttygen.exe 를 실행하면 아래와 같은 화면이 뜹니다. 상단의 Conversions / Import Key 를 선택합니다.


 2) 해당 서버에 접속하기 위한 pem파일을 선택합니다.



 3) 아래와 같이 정상적으로 로드가 된것을 확인할 수 있습니다.
     이제 하단 우측에 있는 Save private key 를 선택하고 Yes 를 선택합니다.



 4) 원하는 위치에 파일명을 설정하여 ppk 파일을 저장합니다. ppk 파일 생성 완료!!




2. Pageant.exe 를 실행하면 아래와 같이 윈도우 우측 하단에 트레이로 추가된것을 확인할 수 있습니다. 이녀석은 항상 저곳에 있어야만 합니다.


 1) 위 트레이를 더블클릭 하여 아래의 화면에서 Add Key 를 선택합니다. 혹은, 트레이 아이콘에서 오른쪽 버튼으로 Add Key 를 선택합니다.



 2) 위에서 저장한 ppk 파일을 선택해줍니다.



 3) 아래와 같이 정상적으로 추가된것을 확인할수 있습니다. 이제 해당 창을 닫습니다.



3. Putty.exe 를 실행합니다. 

 1) Host Name 에 아마존의 Public DNS ( 혹은 Elastic IP ) 를 입력하고 Open 을 합니다. ( 물론, 트레이에는 Pageant 가 떠있어야 합니다. )



 2) 최초 접속시 해당 얼럿이 뜰겁니다. Yes 를 누릅니다.




  


 3) 계정으로 root 를 입력합니다. 정상접속이 되었습니다. !!



4. Psftp.exe 를 실행합니다. ( 당연히 이놈도 Pageant 가 실행되어있어야 겠죠? )


 역시 계정에 root 를 입력하여 정상 접속되는 것을 확인할 수 있습니다.

 기념으로 이미지하나는 드래그하여 put 해봅니다.
반응형
블로그 이미지

조이풀 라이프

Lift is short, enjoy the life

,

 

AWS를 이용하기 위해서 AWS Instance를 생성하시고 SSH로 접속하여 아래 스크립트를 따라서 설치하면 됩니다.

[AWS 인스턴스 만들기]

http://yfkwon.tistory.com/5


[윈도우에서 Putty를 이용한 SSH 접속하기]

http://yfkwon.tistory.com/3


[TensorFlow 설치하기]

http://erikbern.com/2015/11/12/installing-tensorflow-on-aws/

install-tensorflow.sh                       

  # Note – this is not a bash script (some of the steps require reboot)
  # I named it .sh just so Github does correct syntax highlighting.
  #
  # This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
  #
  # The CUDA part is mostly based on this excellent blog post:
  # http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
   
  # Install various packages
  sudo apt-get update
  sudo apt-get upgrade -y # choose “install package maintainers version”
  sudo apt-get install -y build-essential python-pip python-dev git python-numpy swig python-dev default-jdk zip zlib1g-dev
   
  # Blacklist Noveau which has some kind of conflict with the nvidia driver
  echo -e "blacklist nouveau\nblacklist lbm-nouveau\noptions nouveau modeset=0\nalias nouveau off\nalias lbm-nouveau off\n" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
  echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
  sudo update-initramfs -u
  sudo reboot # Reboot (annoying you have to do this in 2015!)
   
  # Some other annoying thing we have to do
  sudo apt-get install -y linux-image-extra-virtual
  sudo reboot # Not sure why this is needed
   
  # Install latest Linux headers
  sudo apt-get install -y linux-source linux-headers-`uname -r`
   
  # Install CUDA 7.0 (note – don't use any other version)
  wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
  chmod +x cuda_7.0.28_linux.run
  ./cuda_7.0.28_linux.run -extract=`pwd`/nvidia_installers
  cd nvidia_installers
  sudo ./NVIDIA-Linux-x86_64-346.46.run
  sudo modprobe nvidia
  sudo ./cuda-linux64-rel-7.0.28-19326674.run
  cd
   
  # Install CUDNN 6.5 (note – don't use any other version)
  # YOU NEED TO SCP THIS ONE FROM SOMEWHERE ELSE – it's not available online.
  # You need to register and get approved to get a download link. Very annoying.
  tar -xzf cudnn-6.5-linux-x64-v2.tgz
  sudo cp cudnn-6.5-linux-x64-v2/libcudnn* /usr/local/cuda/lib64
  sudo cp cudnn-6.5-linux-x64-v2/cudnn.h /usr/local/cuda/include/
   
  # At this point the root mount is getting a bit full
  # I had a lot of issues where the disk would fill up and then Bazel would end up in this weird state complaining about random things
  # Make sure you don't run out of disk space when building Tensorflow!
  sudo mkdir /mnt/tmp
  sudo chmod 777 /mnt/tmp
  sudo rm -rf /tmp
  sudo ln -s /mnt/tmp /tmp
  # Note that /mnt is not saved when building an AMI, so don't put anything crucial on it
   
  # Install Bazel
  cd /mnt/tmp
  git clone https://github.com/bazelbuild/bazel.git
  cd bazel
  git checkout tags/0.1.0
  ./compile.sh
  sudo cp output/bazel /usr/bin
   
  # Install TensorFlow
  cd /mnt/tmp
  export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
  export CUDA_HOME=/usr/local/cuda
  git clone --recurse-submodules https://github.com/tensorflow/tensorflow
  cd tensorflow
  # Patch to support older K520 devices on AWS
  # wget "https://gist.githubusercontent.com/infojunkie/cb6d1a4e8bf674c6e38e/raw/5e01e5b2b1f7afd3def83810f8373fbcf6e47e02/cuda_30.patch"
  # git apply cuda_30.patch
  # According to https://github.com/tensorflow/tensorflow/issues/25#issuecomment-156234658 this patch is no longer needed
  # Instead, you need to run ./configure like below (not tested yet)
  TF_UNOFFICIAL_SETTING=1 ./configure
  bazel build -c opt --config=cuda //tensorflow/cc:tutorials_example_trainer
   
  # Build Python package
  # Note: you have to specify --config=cuda here - this is not mentioned in the official docs
  # https://github.com/tensorflow/tensorflow/issues/25#issuecomment-156173717
  bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
  bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
  sudo pip install /tmp/tensorflow_pkg/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
   
  # Test it!
  cd tensorflow/models/image/cifar10/
  python cifar10_multi_gpu_train.py
   
  # On a g2.2xlarge: step 100, loss = 4.50 (325.2 examples/sec; 0.394 sec/batch)
  # On a g2.8xlarge: step 100, loss = 4.49 (337.9 examples/sec; 0.379 sec/batch)
  # doesn't seem like it is able to use the 4 GPU cards unfortunately :(
반응형
블로그 이미지

조이풀 라이프

Lift is short, enjoy the life

,