顯示具有 AWS 標籤的文章。 顯示所有文章
顯示具有 AWS 標籤的文章。 顯示所有文章

2017年12月15日 星期五

Amazon EC2 定價

原想用免費的t2.micro做Lab, Hadoop 需要Resouce, 只好開始到t2.medium 被收費.
12/11-12/15 一週可以run


https://aws.amazon.com/tw/ec2/pricing/on-demand/

vCPUECU記憶體 (GiB)執行個體儲存體 (GB)Linux/UNIX 使用量
一般用途 – 最新一代
t2.nano1變數0.5僅 EBS$0.0076 每小時
t2.micro1變數1僅 EBS$0.0152 每小時
t2.small1變數2僅 EBS$0.0304 每小時
t2.medium2變數4僅 EBS$0.0608 每小時
t2.large2變數8僅 EBS$0.1216 每小時
t2.xlarge4變數16僅 EBS$0.2432 每小時




2017年12月5日 星期二

SSH Connect to AWS Linux Instance from MacOS


by MacOS Terminal Client

$ssh -i "**********AWSkeypair.pem" user@hostname.compute.amazonaws.com



by ssh client lite

1. Launch Preference -> Security
2. Import PEM file

3. Connection Setting
Name:
Host:
Port:
Select Private Key:


2017年12月4日 星期一

Create LXC Virtual Machine on AWS Ubuntu 16 Container



更新系統套件

ubuntu@ip-172-31-16-58:~$ sudo apt-get update
Hit:1 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:4 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main Sources [868 kB]
Get:5 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu xenial/restricted Sources [4,808 B]
:::

Get:38 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [1,336 B]
Fetched 24.5 MB in 4s (5,661 kB/s)
Reading package lists... Done

ubuntu@ip-172-31-16-58:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  curl dnsmasq-base dpkg klibc-utils libcurl3-gnutls libdb5.3 libklibc libpython3.5 libpython3.5-minimal
  libpython3.5-stdlib lxcfs python3.5 python3.5-minimal
13 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 9,338 kB of archives.
After this operation, 21.5 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y

安裝LXC core model

ubuntu@ip-172-31-16-58:~$ sudo apt-get install lxc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  bridge-utils cloud-image-utils debootstrap distro-info genisoimage libaio1 libboost-iostreams1.58.0
  libboost-random1.58.0 libboost-system1.58.0 libboost-thread1.58.0 libiscsi2 libnspr4 libnss3 libnss3-nssdb
  libpam-cgfs librados2 librbd1 lxc-templates lxc1 python3-lxc qemu-block-extra qemu-utils sharutils
Suggested packages:
  cloud-utils-euca shunit2 wodim cdrkit-doc qemu-user-static lxctl bsd-mailx | mailx
The following NEW packages will be installed:
  bridge-utils cloud-image-utils debootstrap distro-info genisoimage libaio1 libboost-iostreams1.58.0
  libboost-random1.58.0 libboost-system1.58.0 libboost-thread1.58.0 libiscsi2 libnspr4 libnss3 libnss3-nssdb
  libpam-cgfs librados2 librbd1 lxc lxc-templates lxc1 python3-lxc qemu-block-extra qemu-utils sharutils
0 upgraded, 24 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,843 kB of archives.
After this operation, 26.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Check LXC 虛擬主機範本有那些

ubuntu@ip-172-31-16-58:~$ ll /usr/share/lxc/templates
total 412
drwxr-xr-x 2 root root  4096 Dec  5 07:08 ./
drwxr-xr-x 6 root root  4096 Dec  5 07:08 ../
-rwxr-xr-x 1 root root 13042 Jun 14 20:15 lxc-alpine*
-rwxr-xr-x 1 root root 13737 Jun 14 20:15 lxc-altlinux*
-rwxr-xr-x 1 root root 11156 Jun 14 20:15 lxc-archlinux*
-rwxr-xr-x 1 root root 11649 Jun 14 20:15 lxc-busybox*
-rwxr-xr-x 1 root root 29725 Jun 14 20:15 lxc-centos*
-rwxr-xr-x 1 root root 10374 Jun 14 20:15 lxc-cirros*
-rwxr-xr-x 1 root root 20171 Jun 14 20:15 lxc-debian*
-rwxr-xr-x 1 root root 18197 Jun 14 20:15 lxc-download*
-rwxr-xr-x 1 root root 49693 Jun 14 20:15 lxc-fedora*
-rwxr-xr-x 1 root root 28259 Jun 14 20:15 lxc-gentoo*
-rwxr-xr-x 1 root root 13849 Jun 14 20:15 lxc-openmandriva*
-rwxr-xr-x 1 root root 15910 Jun 14 20:15 lxc-opensuse*
-rwxr-xr-x 1 root root 41596 Jun 14 20:15 lxc-oracle*
-rwxr-xr-x 1 root root 11463 Jun 14 20:15 lxc-plamo*
-rwxr-xr-x 1 root root 19096 Jun 14 20:15 lxc-slackware*
-rwxr-xr-x 1 root root 26667 Jun 14 20:15 lxc-sparclinux*
-rwxr-xr-x 1 root root  6822 Jun 14 20:15 lxc-sshd*
-rwxr-xr-x 1 root root 25703 Jun 14 20:15 lxc-ubuntu*
-rwxr-xr-x 1 root root 11734 Jun 14 20:15 lxc-ubuntu-cloud*

建立LXC Virtual Machine

ubuntu@ip-172-31-16-58:~$ sudo lxc-create -t ubuntu -n myBig1
:::
  en_US.UTF-8... done
Generation complete.
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:KYqB7UzN+QbBtdS0+MrWd0ei6Tl3ho0TppBVoQz+uuw root@ip-172-31-16-58 (RSA)
Creating SSH2 DSA key; this may take some time ...
1024 SHA256:241q0S+tE2CVTJ1el8UiZ3rkqAw9YIxdUaMOm8qTpOE root@ip-172-31-16-58 (DSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:LZ5vr5pi/8CNPFPW8IPGYmoH7tcJ7Ih7idF6bKfltUk root@ip-172-31-16-58 (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:cfF3FfPC2G4zI7Xz/d1wHntIVijYQcJdISrxiuGAyHs root@ip-172-31-16-58 (ED25519)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.

Current default time zone: 'Etc/UTC'
Local time is now:      Tue Dec  5 07:23:42 UTC 2017.
Universal Time is now:  Tue Dec  5 07:23:42 UTC 2017.


##
# The default user is 'ubuntu' with password 'ubuntu'!
# Use the 'sudo' command to run tasks as root in the container.
##

顯示VM的目錄內容

ubuntu@ip-172-31-16-58:~$ sudo tree -L 2 /var/lib/lxc
/var/lib/lxc
└── myBig1
    ├── config
    └── rootfs

Start and Stop Container VM

ubuntu@ip-172-31-16-58:~$ sudo lxc-start -n myBig1
lxc-start: tools/lxc_start.c: main: 301 Container is already running.
ubuntu@ip-172-31-16-58:~$ sudo lxc-stop -n myBig1

複製 LXC VM
ubuntu@ip-172-31-16-58:~$ sudo lxc-clone -o myBig1 -n myBig1_Backup
lxc-clone is deprecated in favor of lxc-copy.

Created container myBig1_Backup as copy of myBig1

ubuntu@ip-172-31-16-58:~$ sudo lxc-destroy -n myBig1_Backup (刪除 LXC VM)

ubuntu@ip-172-31-16-58:~$ sudo tree -L 2 /var/lib/lxc
/var/lib/lxc
├── myBig1
│   ├── config
│   └── rootfs
└── myBig1_Backup
    ├── config
    └── rootfs

4 directories, 2 files






2017年10月2日 星期一

AWS ALB/CLB/ELB

https://aws.amazon.com/elasticloadbalancing/classicloadbalancer/


An Application Load Balancer is a load balancing option for the Elastic Load Balancing service that operates at the application layer and allows you to define routing rules based on content across multiple services or containers running on one or more Amazon Elastic Compute Cloud (Amazon EC2) instances.

The Classic Load Balancer routes traffic based on application or network level information and is ideal for simple load balancing of traffic across multiple EC2 instances where high availability, automatic scaling, and robust security are required. For applications needing advanced routing capabilities, microservices, or container-based architectures, we recommend the Application load balancer.

Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances. It enables you to achieve fault tolerance in your applications, seamlessly providing the required amount of load balancing capacity needed to route application traffic.
Elastic Load Balancing offers two types of load balancers that both feature high availability, automatic scaling, and robust security. These include the Classic Load Balancer that routes traffic based on either application or network level information, and the Application Load Balancer that routes traffic based on advanced application level information that includes the content of the request. The Classic Load Balancer is ideal for simple load balancing of traffic across multiple EC2 instances, while the Application Load Balancer is ideal for applications needing advanced routing capabilities, microservices, and container-based architectures. Application Load Balancer offers ability to route traffic to multiple services or load balance across multiple ports on the same EC2 instance.

Docker Command

#1 pull images $docker pull chusiang/takaojs1607 #2 list images $docker images #3.1 run docker $docker run -it ### bash #3.2 run do...