'AWS'에 해당되는 글 22건

  1. 2021.01.28 [AWS] RBAC for Application 을 위한 참고 문서
  2. 2020.08.31 [Elastic] IaC 기반의 Cluster 관리
  3. 2020.07.20 [AWS] Java SDK 2.x 사용 - build.gradle
  4. 2020.07.13 [AWS] DescribeInstanceTypes from Java
  5. 2020.03.31 [Docker] Amazon Linux 에 Docker & Compose 설치 하기.
  6. 2020.03.26 [AWS] Spring Cloud Config S3 Backend 사용하기
  7. 2020.03.23 [AWS] IGW vs NAT GW
  8. 2020.03.19 [Docker] gitlab, redmine, jenkins 설치 하기
  9. 2020.03.16 [AWS] EC2 인스턴스 백업 하기
  10. 2020.03.13 [AWS] aws cli 사용 시 --query 알아보기

[AWS] RBAC for Application 을 위한 참고 문서

Cloud&Container/AWS 2021. 1. 28. 11:29

https://musma.github.io/2019/11/05/about-aws-iam-policy.html
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/ec2-iam-roles.html
https://docs.aws.amazon.com/ko_kr/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html

 

위 문서를 보고 IAM 을 이해 하고 AWS Resources 에 RBAC 적용 하는 방법에 대해서 익히면 됩니다.

 

:

[Elastic] IaC 기반의 Cluster 관리

Elastic 2020. 8. 31. 12:40

Elastic Stack 은 서비스나 데이터를 다루는 모든 기업에서 사용을 하고 있는 매우 훌륭한 오픈소스 입니다.

 

기본적으로 

  • Elasticsearch
  • Kibana
  • Logstash
  • Beats

이 4가지 Stack 을 이야기 하고 있으며,

잘 활용 하실 경우 현존 하는 많은 상용 도구들을 모두 재낄 수 있습니다.

 

단, 기술 내재화와 역량을 확보 하겠다는 의지가 있을 경우에 한해서 입니다.

 

제가 지금까지 다니던 회사는 주로 서비스 회사 였기 때문에,

특정 도메인에 필요로 하는 기능 개발과 스타트업 특성에 따른 빠른 개발을 할 수 밖에 없었습니다.

올해 회사를 옮기면서 그 동안 만나 봤던 분들의 어려움을 해결 할 수 있는 방법은 없을까 하고 고민 하다,

Elastic Stack 에 대한 설치 자동화 프로그램을 만들어 보기로 했습니다.

 

그 결과로 우선 1차 버전을 이야기 해볼까 합니다.

 

Elasticsearch 는 누구나 쉽게 사용이 가능 합니다.

검색 (IR) 에 대한 지식이나 전문성이 없어도 Elasticsearch 를 도구적으로 설치 하고 사용 하는 데는 별 문제가 없습니다.

그래서 빠른 PoC 작업을 할 수도 있는 것 같습니다.

 

하지만 클러스터를 구성 하고 이를 운영 하면서 인프라 관점으로 접근 하다 보면 어려움이 생기게 됩니다.

  • 사용하고자 하는 부서는 많고,
  • 그렇다고 단일 클러스터로 구성해서 사용하라고 제공해 줄 수도 없고,
  • 인프라 생성 요청도 해야 하고,
  • 설정 및 설치도 해야 하고,
  • 문제가 생기면 위 과정을 다시 반복 해야 하고,
  • 클러스터 최적화는 또 어떻게 해야 하고,

등등....

 

요청자와 생성자의 편의를 제공 할 수 있으면 어떨까 싶었습니다.

 

제가 만들어 본 Application 은 아래 Stack 을 이용해서 개발이 되었습니다.

  • Spring Framework
  • Terraform
  • Ansible
  • Docker
  • AWS (EC2, S3)
  • Elasticsearch

AWS 기반으로 먼저 개발을 진행을 했고 추후 Azure 나 GCP 로도 확장을 할 예정입니다.

 

기본 동작 방식은 아래와 같습니다.

1.  Application Container

  - 인프라 구성을 위한 정보를 설정 하고 설치 파일을 생성 합니다.

    - Terraform 관련 파일을 생성 합니다. (setup.tf)

  - 생성 될 인스턴스에 설치 할 정보를 설정하고 설치 파일을 생성 합니다. 

    - Ansible 관련 파일을 생성 합니다. (playbook, inventories, roles)

  - 클러스터 구성을 위한 정보를 설정 하고 설치 파일을 생성 합니다.

    - Docker Compose 관련 파일을 생성 합니다. (docker-compose.yml)

2. Terraform Backend - S3

  - Terraform 을 이용해서 생성한 인스턴스의 정보는 s3 backend 에 저장이 됩니다.

3. Bastion

  - 설치 시 보안 관리를 위해 bastion 서버로 ssh tunneling 하여 설치 합니다.

 

화면 구성은 아래와 같습니다.

 

그림 1) Terraform 설정 정보와 Elasticsearch Cluster Node Topology 설정 및 실행 화면

그림 2) Ansible 을 이용한 Node 환경 구성 설정 및 실행 화면

그림 3) Elasticsearch Cluster 실행 화면

그림 4) 생성 된 Cluster 에 대한 목록 및 관리 화면

그림 5) 개별 클러스터의 Node 에 대한 관리 화면

 

만들어진 Application 은 도커 기반으로 개발이 되어 있기 때문에 어떤 환경에서든 실행이 가능 합니다.
가장 기초적인 부분에서 부터 출발한 것으로 

  • 클러스터 구성 및 설치는 어떻게 해야 하는가?
  • 클러스터 구성 시 최적화는 되어 있는가?
  • 클러스터를 쉽게 생성 하고 삭제 할 수 있는가?
  • 이미 생성된 클러스터에 노드 추가는 어떻게 해야 하는가?
  • 개별 노드들에 대한 시작과 중지를 할 수 있는가?

등등...

 

보시는 바와 같이 클러스터의 생성에서 부터 시작과 중지에 대한 기초 부터 접근을 했습니다.

 

Elasticsearch 는 크게 3 가지 유형으로 사용을 하게 됩니다.

  • 검색
  • 저장(색인)
  • 분석

 

위 3 가지 유형을 가지고 Business Domain 별 사용을 하게 되는 것입니다.

  • e-Commerce 상품 검색
  • SIEM
  • Log 및 Data 분석 시스템

등등 ...

 

이걸 좀 더 고도화 한다고 하면 아래와 같은 서비스들을 쉽게 만들수도 있습니다.

  • AWS Elasticsearch Service
  • Elastic Cloud - Elasticsearch

회사에서 어떤 전략으로 접근 할 지 아직은 잘 모르겠습니다.

이미 IaC 기반으로 잘 제공 되고 있는 MSP (Elastic, AWS) 가 있는데, 우리가 이것 까지 해야 할까?

 

이 문제는 뒤로 하고,

Elasticsearch 를 사용하거나 사용하고자 하는 스타트업이 있다면,

누구라도 쉽게 최적화된 클러스터를 생성하고 인프라를 관리 할 수 있도록 제공하면 좋겠다는게 지금 저의 생각 입니다.

 

오픈소스로 공개를 해도 되고, 컨테이너 이미지를 docker registry 에 등록을 해도 되고 몇 가지 방법이 있겠지만,

정말 이런게 필요한지 부터 고민을 더 해봐야 할 것 같습니다.

 

아무도 필요로 하지 않는데 계속 투자를 해야 할지도 고민이라서요. ^^;

 

ECOS(Elastic Cloud Open Stack) Installer 의 기능을 간략하게 요약해 드리면,

  1. Elasticsearch Cluster 구성을 위한 GUI 환경을 제공 합니다.
  2. Terraform 기반의 리소스 생성을 제공 합니다.
  3. Ansible 기반의 설치 및 운영 환경을 제공 합니다.
  4. Docker 기반의 Cluster 환경 구성 및 관리 기능을 제공 합니다.
  5. Elasticsearch 설정을 잘 몰라도 됩니다. (이왕이면 알면 좋습니다.)
  6. Cluster 환경을 최적화 해서 구성해 줍니다.
  7. Terraform, Ansible, Docker 등에 대해서 잘 몰라도 됩니다. (이왕이면 알면 좋습니다.)
  8. 리소스를 쉽게 제공하고 회수 할 수 있습니다.
  9. Cluster 내 Node 추가 기능을 제공 합니다.

ECOS Installer 는 우선

  • MZC( Megazone Cloud) 고객사 중
  • 기술 내재화를 고민 하고 계신 고객사

를 찾아서 설치 및 기술 이전을 해보려 합니다.

 

피드백을 받아 가면서 업그레이드를 해보도록 하겠습니다.

 

감사합니다.

:

[AWS] Java SDK 2.x 사용 - build.gradle

Cloud&Container/AWS 2020. 7. 20. 08:58

1.x 와는 많이 바뀌었습니다.

확인 하고 변경 하세요.

 

implementation platform('software.amazon.awssdk:bom:2.13.55')
// aws sdk
compile 'software.amazon.awssdk:sdk-core'
compile 'software.amazon.awssdk:ec2'
compile 'software.amazon.awssdk:s3'
compile 'software.amazon.awssdk:sqs'

:

[AWS] DescribeInstanceTypes from Java

Cloud&Container/AWS 2020. 7. 13. 18:06

본 API 가 삭제 되었기 때문에 그냥 아래와 같이 단순하게 구성해 보았습니다.

 

@Service
@Log4j2
@RequiredArgsConstructor
public class Ec2Service {

  public ResponseEntity<String> describeInstanceTypes() {
    ProcessBuilder builder = new ProcessBuilder();
    String instances = "{}";

    try {
      builder.command("bash", "-c", "aws ec2 describe-instance-types");
      Process process = builder.start();

      instances = new BufferedReader(
        new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)).lines()
        .collect(Collectors.joining("\n"));

      int exitCode = process.waitFor();

      JSONObject jsonObject = new JSONObject(instances);
      JSONArray jsonArray = jsonObject.getJSONArray("InstanceTypes");
      JSONArray sortedJsonArray = new JSONArray();
      List list = new ArrayList();

      for(int i = 0; i < jsonArray.length(); i++) {
        list.add(jsonArray.getJSONObject(i));
      }

      Collections.sort(list, new Comparator<JSONObject>() {

        @Override
        public int compare(JSONObject a, JSONObject b) {
          String source = new String();
          String target = new String();

          try {
            source = (String)a.get("InstanceType");
            target = (String)b.get("InstanceType");
          } catch(Exception e) {
          }

          return source.compareTo(target);
        }
      });

      for(int i = 0; i < jsonArray.length(); i++) {
        sortedJsonArray.put(list.get(i));
      }

      instances = "{\"InstanceTypes\": " +sortedJsonArray.toString()+ "}";
    } catch(Exception e) {
      e.printStackTrace();
    }

    return ResponseEntity.ok(instances);
  }
}

 

코드 자체는 AWS CLI 를 ProcessBuilder 를 이용해서 외부 파일을 실행 시켜 데이터를 받아와서 처리 하는 내용입니다.

AWS CLI 로 데이터를 가져 오게 되면 정렬이 안된 상태로 데이터가 넘어 와서 별도 sort 기능 구현이 필요 합니다.

그냥 CLI 에서도 JSON Sort 옵션 하나 넣어 주면 좋았을 걸 아쉽더라고요.

 

근데 왜 이 API 를 없앴는지 차암....

 

1.x 에서 삭제 되어서 2.x 로 변경해서 사용 하시면 됩니다.

    Ec2Client ec2Client = Ec2Client.builder().build();
    DescribeInstanceTypesRequest request = DescribeInstanceTypesRequest.builder()
      .maxResults(100)
      .build();

    DescribeInstanceTypesResponse response = ec2Client.describeInstanceTypes(request);
    log.debug("{}", response.instanceTypes());

한번에 100개 씩 밖에 못 가져 오기 때문에 nextToken 으로 끝까지 요청 하셔야 합니다.

:

[Docker] Amazon Linux 에 Docker & Compose 설치 하기.

Cloud&Container/IaC 2020. 3. 31. 14:06

Amazon linux docker & docker-compose 설치)

$ sudo yum update
$ sudo yum install docker
$ docker version
...중략...
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
$ sudo service docker start
$ docker version
Got permission denied while trying to connect to the Docker daemon socket at 
unix:///var/run/docker.sock: 
Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix /var/run/docker.sock: 
connect: permission denied
$ sudo docker version
$ sudo usermod -a -G docker ec2-user

# https://github.com/docker/compose 에서 latest version 을 확인 합니다.
$ sudo curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

$ docker-compose up
Couldn't connect to Docker daemon at http+docker://localhost - is it running?

$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ newgrp docker 

$ docker-compose up
:

[AWS] Spring Cloud Config S3 Backend 사용하기

Cloud&Container/AWS 2020. 3. 26. 10:57

Spring Cloud Config Server 설정)

 

[S3 설정]
- S3 버킷 생성
- 접근권한 부여

[ConfigApplication.java]

@SpringBootApplication
@EnableConfigServer
public class ConfigApplication {
  public static void main(String[] args) {
	SpringApplication.run(ConfigApplication.class, args);
  }
}


[build.gradle]

compile 'com.amazonaws:aws-java-sdk-s3'


[application.yml]

server:
port: 8888

spring:
  profiles:
    active: awss3
  cloud:
    config:
      server:
        awss3:
          region: ap-northeast-2
          bucket: s3config


[Config Server 접근 URL]

http://localhost:8888/${S3-FILE-NAME}/${PROFILE-NAME}

- 생성한 버킷 하위로 설정 파일 목록이 존재 해야 합니다.
- ${S3-FILE-NAME} 는 생성한 Bucket 아래 만든 설정 파일명 입니다.
- backoffice
- ${PROFILE-NAME} 은 설정 파일에 대한 프로필명 입니다.
- app1, app2

예제)
Config Server URL : 
http://localhost:8888/backoffice/app1

S3 :
megatoidiscons3config/backoffice-app1.yml
or
megatoidiscons3config/backoffice-app1.properties


[backoffice-app1.yml]

project.app1="backoffice-app1"


[backoffice-app2.yml]

project.app2="backoffice-app2"

 

Spring Cloud Config Client 설정)

[application.yml]

spring:
  cloud:
    config:
      name: backoffice
      uri: http://localhost:8888
      profile: app1,app2


[HelloController.java]

@RestController
public class HelloController {

  @Value ("${project.app1}")
  String projectApp1;

  @Value ("${project.app2}")
  String projectApp2;

  @RequestMapping("/app1")
  public String helloApp1() {
    return projectApp1;
  }

  @RequestMapping("/app2")
  public String helloApp2() {
    return projectApp2;
  }
}

 

git 사용 하는 건 문서들이 많이 나와 있어서 s3 로 정리해 봤습니다.

:

[AWS] IGW vs NAT GW

Cloud&Container/AWS 2020. 3. 23. 10:43

VPC 를 구성 하면서 외부 통신을 위해서는 IGW 가 꼭 필요 합니다.

만약 외부 통신이 필요 하지 않은 VPC 라면 IGW 를 구성 하지 않아도 되겠죠.

 

NAT GW 는 VPC 구성 후 Private Subnet 에 있는 리소스가 외부와 Internet 통신을 하기 위해 필요한 서비스 입니다.

이 과정에서 Elastic IP 가 필요 합니다.

 

이 두 GW 의 차이점이 더 궁금하신 분은 아래 문서 참고 하세요.

 

https://medium.com/awesome-cloud/aws-vpc-difference-between-internet-gateway-and-nat-gateway-c9177e710af6

Internet Gateway

An Internet Gateway (IGW) is a logical connection between an Amazon VPC and the Internet. It is not a physical device. Only one can be associated with each VPC. It does not limit the bandwidth of Internet connectivity. (The only limitation on bandwidth is the size of the Amazon EC2 instance, and it applies to all traffic — internal to the VPC and out to the Internet.)

If a VPC does not have an Internet Gateway, then the resources in the VPC cannot be accessed from the Internet (unless the traffic flows via a corporate network and VPN/Direct Connect).

An Internet Gateway allows resources within your VPC to access the internet, and vice versa. In order for this to happen, there needs to be a routing table entry allowing a subnet to access the IGW.

That is to say — an IGW allows resources within your public subnet to access the internet, and the internet to access said resources.

A subnet is deemed to be a Public Subnet if it has a Route Table that directs traffic to the Internet Gateway.


NAT Gateway

A NAT Gateway does something similar, but with two main differences:

  1. It allows resources in a private subnet to access the internet (think yum updates, external database connections, wget calls, OS patch, etc)
  2. It only works one way. The internet at large cannot get through your NAT to your private resources unless you explicitly allow it.

AWS introduced a NAT Gateway Service that can take the place of a NAT Instance. The benefits of using a NAT Gateway service are:

  • It is a fully-managed service — just create it and it works automatically, including fail-over
  • It can burst up to 10 Gbps (a NAT Instance is limited to the bandwidth associated with the EC2 instance type)

However:

  • Security Groups cannot be associated with a NAT Gateway
  • You’ll need one in each AZ since they only operate in a single AZ
:

[Docker] gitlab, redmine, jenkins 설치 하기

Cloud&Container/IaC 2020. 3. 19. 11:48

 

환경)

- AWS

- Ubuntu 18.04 LTS

- Python 3.8.2

- Pip 3

 

Step 1) docker 를 설치 합니다.

$ sudo apt update
$ sudo apt upgrade
$ sudo apt-get install curl apt-transport-https ca-certificates software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt update
$ sudo apt install docker-ce
$ sudo systemctl status docker
$ sudo docker run hello-world

$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/create?fromImage=gitlab%2Fgitlab-ee&tag=latest: dial unix /var/run/docker.sock: connect: permission denied

$ sudo usermod -a -G docker ubuntu
또는
$ sudo chmod 666 /var/run/docker.sock
$ sudo service docker restart

 

Step 2) docker compose 를 설치 합니다.

https://docs.docker.com/compose/compose-file/compose-versioning/#version-3

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
$ docker-compose --version

# uninstall
$ sudo rm /usr/local/bin/docker-compose

 

# 도커 허브를 통해서 개별 컨테이너에 대한 정보를 확인해서 docker-compose.yml 파일을 만들면 됩니다.

https://hub.docker.com/

 

Step 3) gitlab 을 설치 합니다.

$ mkdir -p docker/gitlab
$ cd docker/gitlab
$ vi docker-compose.yml
version: '3.1'

services:
  web:
    image: 'gitlab/gitlab-ee:12.8.1-ee.0'
    restart: always
    hostname: 'xxxxx.compute.amazonaws.com'
    environment:
      TZ: "Asia/Seoul"
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://xxxxx.compute.amazonaws.com'
        letsencrypt['enable'] = false
        nginx['redirect_http_to_https'] = false
        nginx['listen_https'] = false
        nginx['listen_port'] = 8929
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    ports:
      - '8929:8929'
      - '2224:22'
    volumes:
      - '/home/ubuntu/docker/gitlab/config:/etc/gitlab'
      - '/home/ubuntu/docker/gitlab/logs:/var/log/gitlab'
      - '/home/ubuntu/docker/gitlab/data:/var/opt/gitlab'

$ docker-compse up -d

- port 정보는 환경에 맞게 수정 하면 됩니다.

- docker compose 의 version 에 따라 yml syntax 가 다를 수 있으니 아래 문서에서 확인 하시면 됩니다.

https://docs.docker.com/compose/compose-file/ 

 

Step 4) redmine 을 설치 합니다.

$ mkdir -p docker/redmine
$ cd docker/redmine
$ vi docker-compose.yml
version: '3.3'

services:
  redmine:
    depends_on:
      - mysql
    image: redmine:4.1.0
    restart: always
    container_name: redmine
    ports:
      - 9292:3000
    environment:
      TZ: "Asia/Seoul"
      REDMINE_DB_MYSQL: mysql
      REDMINE_DB_USERNAME: root
      REDMINE_DB_PASSWORD: ROOT-PASSWORD
      REDMINE_DB_DATABASE: redmine_default
      REDMINE_DB_ENCODING: utf8
      #REDMINE_NO_DB_MIGRATE: true
    volumes:
      - ./data:/usr/src/redmine/files
      - ./plugins:/usr/src/redmine/plugins
      - ./themes:/usr/src/redmine/public/themes
  mysql:
    image: mysql:5.7.29
    container_name: mysql
    ports:
      - 3306:3306
    command:
      - --default-authentication-plugin=mysql_native_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
    restart: always
    environment:
      TZ: "Asia/Seoul"
      MYSQL_ROOT_PASSWORD: 'ROOT-PASSWORD'
      MYSQL_DATABASE: 'redmine_default'
    volumes:
      - ./data:/var/lib/mysql

# redmine 에서 사용할 DB 계정 정보는 mysql 을 먼저 구성 한 후 등록 하고 redmine 을 실행 시켜 줘야 정상적으로 동작 합니다.
# 이와 같이 하지 않을 경우 connection 이 안되거나 redmine 용 database 가 없다고 오류를 발생 시킵니다.

- redmine 설치 이전에 mysql 이 먼저 구성이 되어야 합니다.

- redmine 의 mysql 사용자를 별도로 만들어 주는 것이 좋기 때문에 필요 하다면 아래와 같이 수정 하면 됩니다.

services:
    mysql:
        image: mysql
...중략...
		volumes:
            - ./sql/init-redmine.sql:/docker-entrypoint-initdb.d/init-redmine.sql
...중략...


# init-redmine.sql
INSERT INTO `user` (`Host`, `User`, `Select_priv`, `Insert_priv`, `Update_priv`, 
`Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, 
`Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, 
`Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, 
`Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, 
`Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, 
`Create_user_priv`, `Event_priv`, `Trigger_priv`, `Create_tablespace_priv`, 
`ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, 
`max_updates`, `max_connections`, `max_user_connections`, `plugin`, 
`authentication_string`, `password_expired`, `password_last_changed`, 
`password_lifetime`, `account_locked`) 
VALUES ('%','redmine','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',
0,0,0,0,'mysql_native_password',password('redmine'),'N',NOW(),NULL,'N')

FLUSH PRIVILEGES;

또는

CREATE USER 'redmine'@'%' IDENTIFIED BY 'redmine';
GRANT ALL PRIVILIEGS ON redmine_default.* TO 'redmine'@'%'

FLUSH PRIVILEGES;

- MySQL 문법 가볍게 한번 보고 넘어 가겠습니다.

CREATE USER '유저아이디'@'접속호스트' IDENTIFIED BY '유저암호';

# 로컬 호스트에서 접속을 허용
CREATE USER '유저아이디'@'localhost' IDENTIFIED BY '유저암호';

# 모든 호스트에서 접속을 허용
CREATE USER '유저아이디'@'%' IDENTIFIED BY '유저암호';

GRANT ALL ON 데이터베이스명.테이블명 TO '유저아이디'@'접속호스트';

# 모든 데이터베이스의 모든 테이블에 대해 로컬호스트로 접속한 유저에게 허용
GRANT ALL ON *.* TO '유저아이디'@'localhost';

# 모든 데이터베이스의 모든 테이블에 대해 모든 호스트로 접속한 유저에게 허용
GRANT ALL ON *.* TO '유저아이디'@'%';

 

Step 5) jenkins 를 설치 합니다.

# python 3.8 최신 버전을 설치 합니다.
# source 로 설치 하는 내용입니다.
$ sudo apt-get install build-essential checkinstall
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
    libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
 
$ cd /opt
$ sudo wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
$ sudo tar xzf Python-3.8.2.tgz

$ cd Python-3.8.2
$ sudo ./configure --enable-optimizations
$ sudo make altinstall
$ sudo apt-get install python3-pip 

# 패키지로 설치 하는 내용입니다.
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8

# 기본에 3.6.9 와 같이 다른 python3.x 가 설치 되어 있는 경우 설치 하지 않습니다.
$ sudo apt-get install python3.8-dev
$ sudo apt-get install python3.8-distutils

$ sudo apt-get install python3-pip

# virtualenv 가 필요 하다면,
$ pip3 install virtualenv virtualenvwrapper

# Jenkins 설치
$ mkdir -p docker/jenkins
$ cd docker/jenkins
$ vi docker-compose.yml
version: '2'

services:
  jenkins:
    image: 'jenkins/jenkins:lts'
    container_name: 'jenkins'
    restart: always
    ports:
      - '8080:8080'
    volumes:
      - './jenkins_home:/var/jenkins_home'
      - '/home/ubuntu/.ssh:/var/jenkins_home/.ssh'
      - '/home/ubuntu/.aws:/var/jenkins_home/.aws'
    environment:
      TZ: "Asia/Seoul"

$ docker-compose up -d

# 에러 발생
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied

$ sudo chown -R 1000:1000 jenkins_home

# Jenkins 에서 awscli 와 boto3 를 사용하기 위한 설치
$ sudo apt install awscli
$ pip3 install boto3

# Jenkins 에서 aws sdk 사용 하기 위한 설정
# host 에 aws configure 설정을 하고 mount 시킵니다.
$ aws configure
$ sudo chmod 666 .aws/config
$ sudo chmod 666 .aws/credentials
$ docker restart jenkins

이제 기본적인 설치는 끝났습니다.

응용은 이제 각자 알아서 해보시기 바랍니다.

:

[AWS] EC2 인스턴스 백업 하기

Cloud&Container/AWS 2020. 3. 16. 17:03

내부에서 사용하는 EC2 인스턴스의 경우 HA 구성까지는 너무 오버라고 생각될 때 최소한의 Backup 정책 정도는 만들어 놓는게 좋습니다.

 

Case 1) 임의 수동 Snapshot 생성

Backup 하고자 하는 Instance 에서 우클릭 후 Snapshot 생성 을 선택 하시면 됩니다.

Selected Instance -> Right Click -> Image -> Create Image

이와 같이 하면 IMAGES 매뉴에서 AMIs  에 생성된 이미지를 보실 수 있습니다.

 

Case 2) 주기적인 자동 Snapshot 생성 (EBS)

EC2 화면에서 수명 주기 관리자(Lifecycle Manager)

Create Snapshot Lifecycle Policy 를 선택해서 필요한 Scheduler 를 만듭니다.

자세한 내용이 궁금한 분들은 공홈 문서를 보시면 좋을 것 같습니다.

https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/ec2-instance-lifecycle.html

https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/ebs-creating-snapshot.html

:

[AWS] aws cli 사용 시 --query 알아보기

Cloud&Container/AWS 2020. 3. 13. 21:46

알아 보기라고 하기에는 그냥 약간의 예제와 학습 해야 하는 문서 링크 입니다.

 

https://jmespath.org/specification.html#filter-expressions

$ aws iot list-thing-types --query 'thingTypes[].[thingTypeName, thingTypeName==`1584075120782`]'
$ aws iot list-thing-types --query "thingTypes[].[thingTypeName, starts_with(thingTypeName, '15840')]"

 

JMES 가 이거 만든 사람 이름의 약어 인것 같은데, 맞는지 모르겠네요.

© Copyright 2014-2015, James Saryerwinnie.

 

그리고 이 분 AWS 직원인 것 같습니다. :)

: