본문 바로가기

DevOps/Jenkins

[Jenkins] Jenkins 설치 - Package

반응형

Jenkins 설치 - Package

sudo yum -y update;
sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo;
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key;
sudo yum upgrade -y;
sudo amazon-linux-extras install epel -y;

sudo amazon-linux-extras install java-openjdk11 -y

sudo systemctl daemon-reload;
sudo systemctl start jenkins;

sudo systemctl status jenkins;

sudo yum install -y docker;
sudo systemctl enable docker;
sudo systemctl start docker;
sudo usermod -aG docker jenkins;

- Amazon 리눅스의 경우 sudo amazon-linux-extras install epel -y; 명령어 실행 필요

- docker 설치 부분은 docker를 이용하여 jenkins를 설치하기 위한 사전 작업 

 

Jenkins 설치시 Java 11버전이 아닌 Java 1.8버전으로 설치했을 경우 서비스 확인시 아래와 같은 에러가 나타날 수 있다.

 

# systemctl status jenkins

 

# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Thu 2022-12-22 01:42:26 UTC; 44s ago
 Main PID: 3991 (code=exited, status=1/FAILURE)

Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: jenkins.service: main process exited, code=exited,...URE
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Failed to start Jenkins Continuous Integration Server.
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Unit jenkins.service entered failed state.
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: jenkins.service failed.
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: jenkins.service holdoff time over, scheduling restart.
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Stopped Jenkins Continuous Integration Server.
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: start request repeated too quickly for jenkins.service
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Failed to start Jenkins Continuous Integration Server.
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Unit jenkins.service entered failed state.
Dec 22 01:42:26 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: jenkins.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

  

# journalctl -xe -u jenkins

→ Linux 서비스 매니저인 systemd는 로그 데이터를 journal이라는 바이너리 형식으로 저장한다. journalctl은 journal에서 로그를 검색하고 조회할 수 있는 systemd 유틸리티 중 하나이다.

 

# journalctl -xe -u jenkins

-- Unit jenkins.service has begun starting up.
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[6017]: jenkins: invalid Java version: openjdk version "1.8.0_342"
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[6017]: OpenJDK Runtime Environment (build 1.8.0_342-b07)
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[6017]: OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode)
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: jenkins.service: main process exited, code=exited, status=1/FAILURE
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Failed to start Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit jenkins.service has failed.
--
-- The result is failed.
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Unit jenkins.service entered failed state.
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: jenkins.service failed.
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: jenkins.service holdoff time over, scheduling restart.
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Stopped Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit jenkins.service has finished shutting down.
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: start request repeated too quickly for jenkins.service
Dec 22 01:46:25 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Failed to start Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit jenkins.service has failed.

 

jenkins: invalid Java version: openjdk version "1.8.0_342" 

위 에러와 같이 22년 이후 jenkins 버전에서는 Java 11버전 필요하며 Java 1.8버전을 사용한다면 Java 11버전 설치가 필요

https://www.jenkins.io/blog/2022/06/28/require-java-11/

 

Jenkins requires Java 11 or newer

As noted above, members of the Jenkins community began working on Java 11 support in 2018, well before the present author’s involvement in the project and well beyond the present author’s ability to identify and name everyone who was involved in the ef

www.jenkins.io

Java 11버전 설치 방법

# Java 11버전 다운
sudo amazon-linux-extras install -y java-openjdk11

# 패키지 관리자에 corrtto rpm 레포지토리 추가
sudo rpm --import https://yum.corretto.aws/corretto.key
sudo curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo

# java 11 설치
sudo yum install -y java-11-amazon-corretto-devel

# 설치가능 패키지 확인
yum list java*jdk-devel

# 11버전 설치
yum install -y java-11-openjdk-devel.x86_64

# 기존 Java 1.8버전이 설치되어 있기 때문에 Java 11버전으로 변경 
 update-alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.amzn2.0.1.x86_64/jre/bin/java)
   2           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64/bin/java)
*+ 3           /usr/lib/jvm/java-11-amazon-corretto/bin/java

Enter to keep the current selection[+], or type selection number: 3

# Java 버전 확인
java -verison

 

Jenkins 다시 시작

# sudo systemctl daemon-reload;
# sudo systemctl restart jenkins;

# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-12-22 02:05:44 UTC; 51s ago
 Main PID: 13089 (java)
    Tasks: 44
   Memory: 439.5M
   CGroup: /system.slice/jenkins.service
           └─13089 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war --httpPort=8080

Dec 22 02:05:09 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: f3b1526dada14bab996dea3cc3ee903e
Dec 22 02:05:09 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: This may also be found at: /var/lib/jenkins/secrets/initia...word
Dec 22 02:05:09 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: *************************************************************
Dec 22 02:05:09 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: *************************************************************
Dec 22 02:05:09 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: *************************************************************
Dec 22 02:05:44 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: 2022-12-22 02:05:44.486+0000 [id=29]        INFO        je...tion
Dec 22 02:05:44 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: 2022-12-22 02:05:44.513+0000 [id=23]        INFO        hu...ning
Dec 22 02:05:44 ip-10-20-2-177.ap-northeast-2.compute.internal systemd[1]: Started Jenkins Continuous Integration Server.
Dec 22 02:05:45 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: 2022-12-22 02:05:45.285+0000 [id=45]        INFO        h....ller
Dec 22 02:05:45 ip-10-20-2-177.ap-northeast-2.compute.internal jenkins[13089]: 2022-12-22 02:05:45.285+0000 [id=45]        INFO        hu...t #1
Hint: Some lines were ellipsized, use -l to show in full.

# netstat -an | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN

 

Jenkins 메인 페이지 접근

 - http://IP:8080 (default port)

 

/var/lib/jenkins/secrets/initialAdminPassword 파일에서 Administrator 패스워드 확인 후 입력

Install suggested plugins 클릭하여 기본 플러그인 다운로드

 

설치 진행중

 

기본 플러그인들이 설치되면 초기 계정 생성 화면이 나옴 (관리자 계정 추가)

 

도메인 설정

 

아래와 같이 Jenkins 메인 화면이 나오면 설치 완료

 

 

 

[참고]

- https://www.jenkins.io/doc/tutorials/tutorial-for-installing-jenkins-on-AWS/

- 패스트캠퍼스, 한 번에 끝내는 AWS 인프라 구축과 DevOps 운영 초격차 패키지 Online

 

반응형

'DevOps > Jenkins' 카테고리의 다른 글

[Jenkins] docker Build failed: no space left on device  (1) 2023.12.26
[Jenkins] Jenkins pipeline 소개  (0) 2022.12.21
[Jenkins] Jenkins 개요  (0) 2022.12.21