코딩하는 문과생
[AWS] springboot pjt 배포 시 메모리 부족 현상 본문
1. EC2내 스프링 부트 프로젝트 배포를 위해 sh파일을 작성
[deploy.sh]
cd $REPOSITORY/$PROJECT_NAME/
echo "> GIT Pull"
git pull
echo "> 프로젝트 Build 시작"
./gradlew build
echo "> step1 디렉토리로 이동"
cd $REPOSITORY
echo "> Build 파일 복사"
cp $REPOSITORY/$PROJECT_NAME/build/libs/*.jar $REPOSITORY/
echo "> 현재 구동중인 애플리케이션 pid 확인"
CURRENT_PID = $(pgrep -f ${PROJECT_NAME}*.jar)
echo "현재 구동 중인 애플리케이션pid: $CURRENT_PID"
if [ -z "$CURRENT_PID" ]; then
echo ">현재 구동 중인 애플리케이션이 없으므로 종료하지 않습니다."
else
echo ">kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi
echo ">새 어플리케이션 배포"
JAR_NAME=$(ls -tr $REPOSITORY/ | grep *.jar | tail -n 1)
echo "> JAR NAME : $JAR_NAME"
nohup java -jar -Dspring.config.location=classpath:/application.properties, /home/ec2-user/app/application-oauth.properties, /home/ec2-user/app/application-real-db.properties \
-Dspring.profiles.active=real $REPOSITORY/$JAR_NAME 2>&1 &
2. 문제발생
> Task :test FAILED
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000f840e000, 17698816, 0) failedrrno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 17698816 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/ec2-user/app/step1/springboot-sample/hs_err_pid24542.log
-> 프로젝트 빌드 시 메모리 부족 현상 발생
[해당 서버 메모리 확인 명령어]
$ free -h
3. 해결
1. swap 설정
$ sudo fallocate -l 1G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
2. git clone 다시하기
$ sudo rm -rf "기존 프로젝트"
$ git clone "주소"
4. 결과 - 성공
'개발 관련 지식 > AWS' 카테고리의 다른 글
[AWS] Error: 날 빡치게 만든 Nginx... (0) | 2020.03.06 |
---|---|
[AWS] Error: IntelliJ와 RDS 데이터 연동 문제 (0) | 2020.03.06 |
[AWS] Error: 포트가 이미 사용 중입니다. (0) | 2020.03.05 |
[AWS] RDS (0) | 2020.01.04 |
[AWS] 비전공자들을 위한 AWS 교육 (0) | 2019.11.27 |