인프라/linux
-
yum update와 OOM인프라/linux 2024. 4. 18. 20:49
RHEL 9.3 버전에서 snapd를 설치하는 중 만난 이슈를 해결하는 과정을 정리합니다. 1. 이슈 원인 파악 snapd를 설치하기 위해서 다음과 같은 명령어를 호출했습니다. $ sudo yum install install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm $ sudo yum update 보통은 조금 기다리면 설치가 진행이 되는데 killed가 되었다고 합니다. GPT에게 물어보니 메모리 부족은 아닐지 찾아보라고 합니다 OOM에 관련된 로그가 있는지 살펴보러 갑니다. $ sudo cat /var/log/messages 낮익은 로그들이 있습니다. OOM Killer에 의해 프로세스가 정리되었다고 하는군요. 2. ..
-
Swapfile은 무엇이길래 메모리 부족을 해결해주는가?인프라/linux 2024. 4. 18. 20:45
EC2 프리티어를 사용하다 보니 메모리 부족을 종종 만나게 됩니다. 사실은.. 이 상황을 만날 때마다 찾아보는 것에 지쳐서 적어두려고 합니다. [ 공식문서 ] 스왑파일 설정하는 김에 스왑파일이 무엇인지도 한번 짚어봅니다. 1. Swapfile은 무엇이길래 메모리 부족을 해결해주는가? 아주 간단하게 이야기하면 메모리에 빈 자리가 없을 때 안 쓰이는 대상을 잠깐 치워두는 공간 정도로 설명할 수 있을 것 같습니다. 아래에 제가 이해하고 있는 메모리와 swapfile의 사용을 간단하게 도식화 해두었습니다. 2. Swapfile 할당하기 스웹 파일은 전통적으로 메모리의 2배를 사용하는 것을 권장한다고 하는 듯 합니다. 실수로 4배를 할당한 김에, 잘못 할당된 것을 정리하고 다시 할당하는 과정을 해보겠습니다 ㅎㅎ ..
-
RHEL에서 port에 실행 중인 프로세스 확인하기인프라/linux 2024. 4. 12. 16:09
80포트에 도커 컨테이너를 띄우려고 하는데 자꾸 이미 80 포트에 프로세스가 있다고 이야기합니다. 아무리 생각해도 80에 띄워놓것이 없는데 이상하여 한번 찾아봅니다. $ lsof -i :80 맥에서는 기본으로 설치되어있어서 별 생각없이 사용했는데 RHEL에서는 yum으로 별도의 설치가 필요한 패키지인 것 같습니다. 그렇다면 다른 명령어로 확인해봅니다. $ sudo ss -tulpn | grep :80 며칠 전에 테스트를 위해 띄워놓은 nginx가 문제였습니다. PID 1049번에서 Nginx가 실행 중이니 해당 프로세스를 제거해보겠습니다. $ sudo kill 1048 제거 되지 않고 다른 프로세스에서 다시 살아납니다? Nginx 를 종료하는 명령어로 정지시켜봅니다. $ sudo nginx -s stop..
-
scp - secured copy protocol인프라/linux 2024. 3. 22. 19:19
aws에서 인프라를 구축하면서 ec2를 private subnet에 두고 외부에서 접근할 방법을 찾던 중 학습한 내용입니다. Bastion Host 역할을 하는 ec2에서 private subnet의 ec2에 ssh로 접근하는 방법을 사용하고 있습니다. 나름의 Microsevice를 구축하면서 새로운 EC2를 private subnet에서 사용해야하는 상황입니다. public ec2에서 private ec2로 ssh 통신을 하려고 하니 보안키가 필요한데, 보안키는 로컬 환경에 가지고 있습니다. 로컬에 있는 보안키를 어떻게 EC2로 옮길 수 있는지 찾아보니 scp 라는 프로토콜을 알게 되었습니다. $ scp -i /path/to/your/bastion-key.pem /path/to/your/ec2-key...
-
Linux에서 사용자에 따른 환경변수 설정인프라/linux 2024. 3. 17. 15:40
Code Deploy를 사용해서 ci/cd를 구축하던 중 만난 이슈를 정리해봅니다. Code Deploy에서 실행시킬 스크립트의 작동을 확인하기 위해서 EC2에서 실행시키면서 발생하는 권한과 환경변수 설정 이슈 입니다. (EC2에서 RHEL을 사용하고 있습니다.) 글은 크게 4가지 항목으로 진행됩니다. 1. 환경변수가 적용이 되지 않거나 도커가 실행이 되지 않거나 2. 왜? bash_profile!? 3. 해결책 1. 환경변수가 적용이 되지 않거나 도커가 실행이 되지 않거나 CI/CD에 사용되는 스크립트에 쓰일 환경변수를 ./bash_profile에 미리 설정을 하였습니다. #!/bin/bash echo "export USER_ID=your_aws_id" >> ~/.bash_profile echo "e..
-
EC2 RHEL 9.3에서 htop 설치하기인프라/linux 2024. 2. 15. 22:38
부하 테스트를 위해 htop을 설치하던 중 고생을 하여 기록으로 남깁니다. 아래의 명령어로 설치가 안되는 경우에 사용 가능합니다. $ sudo yum install epel-release // 설치 안됨 // Updating Subscription Management repositories. // Unable to read consumer identity // This system is not registered with an entitlement server. You can use subscription-manager to register. 수동으로 설치 하는 과정입니다. $ sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-..
-
[이슈]REMOTE HOST IDENTIFICATION HAS CHANGED!인프라/linux 2024. 1. 5. 19:56
가상 머신을 다시 생성하고 호스트에서 ssh로 접속하려고 했을 때 발생한 이슈 입니다. 자주 만날 것 같아서 메모를 해두겠습니다. known_hosts 라는 파일에 이전 key가 남아있는 것이 문제입니다. $ nano ~/.ssh/known_hosts 파일을 열어보면 현재 접근하려고하는 ip 이전에 생성된 fingerprint key 들이 있습니다. 모두 제거하고 다시 연결하면 문제가 없이 작동합니다. [참고] 한 줄 모두 삭제는 Ctrl + K