
LAB. Kafka Server setting
워크플로우
1. 권한 확인
2. VPC 생성
3. 보안 그룹 생성
4. 인스턴스 생성
5. 서버 접속

# old version 삭제
[ec2-user@ip-10-0-0-120 ~]$ sudo yum remove awscli
# new version 파일 다운로드
[ec2-user@ip-10-0-0-120 ~]$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
# zip 파일 압축 해제
[ec2-user@ip-10-0-0-120 ~]$ unzip awscliv2.zip
# 설치 파일 실행
[ec2-user@ip-10-0-0-120 ~]$ sudo ./aws/install
# aws 명령어 동작 확인
[ec2-user@ip-10-0-0-120 ~]$ aws --version
aws-cli/2.17.36 Python/3.11.9 Linux/6.8.0-1012-aws exe/x86_64.ubuntu.24
# 위에 명령어가 실행되지 않는 경우 path를 변경해주어야함
[ec2-user@ip-10-0-0-120 ~]$ /usr/local/bin/aws --version
aws-cli/2.17.60 Python/3.12.6 Linux/6.1.109-118.189.amzn2023.x86_64 exe/x86_64.amzn.2023
[ec2-user@ip-10-0-0-120 ~]$ sudo mv /usr/local/bin/aws /usr/bin/
# AWS CLI에서 AWS 서비스에 접근할 수 있는 자격 증명 등록
[ec2-user@ip-10-0-0-87 ~]$ aws configure
AWS Access Key ID [None]: AKIA4MT**********
AWS Secret Access Key [None]: U6/kl2L7Zni******
Default region name [None]: ap-northeast-2
Default output format [None]: json
# 등록된 자격 증명 불러오기
[ec2-user@ip-10-0-0-87 ~]$ aws sts get-caller-identity
{
"UserId": "AROA4MTWIGBMCGPCTKB4H:i-0c3ea16fa09b2404b",
"Account": "851725267032",
"Arn": "arn:aws:sts::851725267032:assumed-role/manage-role/i-0c3ea16fa09b2404b"
}
# aws 명령어 동작 확인
[ec2-user@ip-10-0-0-87 ~]$ aws s3 ls
# git 설치
[ec2-user@ip-10-0-0-87 fc-storydata]$ sudo yum install -y git
# git 데이터 복제
[ec2-user@ip-10-0-0-87 ~]$ git clone -b main --single-branch https://github.com/njkwon/fc-storydata/
# 다운받은 데이터 디렉토리로 이동
[ec2-user@ip-10-0-0-87 ~]$ cd fc-storydata/
# 데이터 목록 확인
[ec2-user@ip-10-0-0-87 fc-storydata]$ ls -al
total 52
drwxr-xr-x. 8 ec2-user ec2-user 101 Oct 7 03:08 .
drwx------. 6 ec2-user ec2-user 153 Oct 7 03:05 ..
drwxr-xr-x. 8 ec2-user ec2-user 163 Oct 7 03:08 .git
-rw-r--r--. 1 ec2-user ec2-user 1626 Oct 7 03:07 README.md
drwxr-xr-x. 2 ec2-user ec2-user 16384 Oct 7 03:08 logs
drwxr-xr-x. 2 ec2-user ec2-user 16384 Oct 7 03:08 notebook
drwxr-xr-x. 3 ec2-user ec2-user 55 Oct 7 03:08 ods
drwxr-xr-x. 2 ec2-user ec2-user 16384 Oct 7 03:08 script
drwxr-xr-x. 2 ec2-user ec2-user 82 Oct 7 03:08 shell
# s3 버킷 변수 생성 : 버킷은 유니크한 네임으로 생성
[ec2-user@ip-10-0-0-87 fc-storydata]$ bucketname=es-kafka-test-bucket
# 버킷 변수 생성 확인
[ec2-user@ip-10-0-0-87 fc-storydata]$ echo $bucketname
es-kafka-test-bucket
# CLI 로 버킷 생성하는 명령어
[ec2-user@ip-10-0-0-87 fc-storydata]$ aws s3 mb s3://$bucketname --region ap-northeast-2
make_bucket: es-kafka-test-bucket
[ec2-user@ip-10-0-0-87 fc-storydata]$ aws s3 ls
2024-10-07 03:36:49 es-kafka-test-bucket
# fc-storydata 디렉토리 확인
[ec2-user@ip-10-0-0-87 fc-storydata]$ ls
README.md logs notebook ods script shell
# fc-storydata 디렉토리에 있는 모든 데이터(README.md logs notebook ods script shell) 버킷과 동기화(sync)
[ec2-user@ip-10-0-0-87 fc-storydata]$ aws s3 sync . s3://$bucketname --exclude '.git/*'
pload: ./README.md to s3://smlee-datatory/README.md
upload: logs/part-00002.gz to s3://es-kafka-test-bucket/logs/part-00002.gz
upload: logs/part-00003.gz to s3://es-kafka-test-bucket/logs/part-00003.gz
...