- Gitlab 에서 보안 이슈로 버전 업그레이드가 필요한 상황에서 Gitlab 버전을 업그레이하는 방법에 대해 설명 합니다.
현재 설치 버전 gitlab 정보 확인
- gitlab-rake gitlab:env:info 명령을 통해 확인 하거나
- gitlab 에 접속 해서 직접 설치 정보를 확인 하는 방법이 있습니다.
gitlab-rake gitlab:env:info
System information
System:
Current User: git
Using RVM: no
Ruby Version: 2.7.5p203
Gem Version: 3.1.4
Bundler Version:2.3.15
Rake Version: 13.0.6
Redis Version: 6.2.7
Sidekiq Version:6.4.0
Go Version: unknown
GitLab information
Version: 15.1.2
Revision: ea7455c8292
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 13.6
URL: http://192.112.1.62:6060
HTTP Clone URL: http://1 192.112.1.62 :6060/some-group/some-project.git
SSH Clone URL: git@1 192.112.1.62:some-group/some-project.git
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 14.7.4
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
- 업그레이드를 하기 위해서는 순차적으로 버전을 업그레이드 해야 합니다.
- 15.x->18.x 버전으로 바로 최신 버전으로 업그레이드를 하면 안됩니다.
- 15.1.x -> 15.4.6 -> 15.11.13 -> 16.0.8 -> 16.3.7 -> 16.7.x -> 최신 16.x -0 ->17.x ->18.x 버전으로 단계적으로 업그레이드 단계를 수행 합니다.
GitLab 백업 하기
- 업그레이드가 예기치 않은 이유로 실패 할수 있기때문에 버전을 업그레이드 하기 위해서는 반드시 백업을 수행 해야 합니다.
- gitlab-backup create 수행 하면 /var/opt/gitlab/backups/ 디레톡리에 1753833159_2025_07_30_15.1.2_gitlab_backup.tar 형식의 압축 파일이 생성 됩니다.
- 백업 이후 설정 파일도 백업합니다.
# GitLab 전체 백업 명령어 실행
sudo gitlab-backup create
sudo cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak
sudo cp /etc/gitlab/gitlab-secrets.json /etc/gitlab/gitlab-secrets.json.bak
2025-07-30 08:52:39 +0900 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2025-07-30 08:52:54 +0900 -- Dumping database ... done
2025-07-30 08:52:54 +0900 -- Dumping repositories ...
.................................
.................
2025-07-30 08:54:53 +0900 -- Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
2025-07-30 08:54:53 +0900 -- Backup 1753833159_2025_07_30_15.1.2 is done.
⑷ 1217100
-rw------- 1 git git 1246310400 7 30 08:54 1753833159_2025_07_30_15.1.2_gitlab_backup.tar
⑷ 312
-rw-------. 1 root root 19200 6 25 16:32 gitlab-secrets.json
-rw------- 1 root root 19200 7 30 08:55 gitlab-secrets.json.bak
-rw------- 1 root root 137497 6 25 16:31 gitlab.rb
-rw------- 1 root root 137497 7 30 08:55 gitlab.rb.bak
drwxr-xr-x. 2 root root 155 9 2 2024 ssl
drwxr-xr-x. 2 root root 6 7 6 2022 trusted-certs
Gitlab 업그레이드
- 업그레이드 할 gitlab 버전을 확인 합니다.
yum list --showduplicates gitlab-ce
- 설치 버전 선택시 gitlab-ce-[버전정보] 형식으로 패키지를 설치 하므로 설치할 버전을 정확하게 입력하고 설치 합니다.
sudo yum install -y gitlab-ce-15.4.6-ce.0.el7
- 업그레이드 버전이 설치가 완료되면 reconfigure 명령을 통해 변경된 설정을 Gitlab 에 적용 합니다.
- gitlab-ctl reconfigure 명령 수행 중에는 db(PostgreSQL ) 의 데이터 마이그레이션 작업 및 내부 업그레이드 작업들이 이루어 집니다.
- 정상적으로 작업이 완료 되면 gitlab-ctl start & gitlab-ctl status 명령을 통해 업그레이드 작업이 정상적으로 완료 되었는지 최종 확인 합니다.
run: alertmanager: (pid 15390) 48113s; run: log: (pid 1574) 12270431s
run: gitaly: (pid 15404) 48112s; run: log: (pid 12724) 48707s
run: gitlab-exporter: (pid 15426) 48112s; run: log: (pid 1557) 12270431s
run: gitlab-kas: (pid 15440) 48102s; run: log: (pid 1559) 12270431s
run: gitlab-workhorse: (pid 15454) 48102s; run: log: (pid 1555) 12270431s
run: logrotate: (pid 13090) 1296s; run: log: (pid 12699) 48710s
run: nginx: (pid 15474) 48101s; run: log: (pid 1556) 12270431s
run: node-exporter: (pid 15487) 48100s; run: log: (pid 1554) 12270431s
run: postgres-exporter: (pid 15493) 48100s; run: log: (pid 1549) 12270431s
run: postgresql: (pid 15504) 48099s; run: log: (pid 1550) 12270431s
run: prometheus: (pid 17054) 47458s; run: log: (pid 1558) 12270431s
run: puma: (pid 15815) 48068s; run: log: (pid 1551) 12270431s
run: redis: (pid 15820) 48067s; run: log: (pid 1548) 12270431s
run: redis-exporter: (pid 15827) 48067s; run: log: (pid 1546) 12270431s
run: sidekiq: (pid 15838) 48062s; run: log: (pid 1552) 12270431s
- 보다 높은 최신 버전으로 업그레이드 하기 위해서는 단계적으로 상위 버전 gitlab 버전을 설치하는 단계를 반복 합니다.
버전 업그레이드 정리
#Gitlab 설치 버전 정보 확인
yum --showduplicates list gitlab-ce
#설정 적용
gitlab-ctl reconfigure
#Gitlab 재시작
gitlab-ctl restart
#Gitlab 상태 확인
gitlab-ctl status
#gitlab 업그레이드 버전 정보 확인
gitlab-rake gitlab:env:info
업그레이드 패스 확인 하기 (참고)
- 아래 URL 에 접속 하면 버전 업그레이드시 확인해야 할 내용에 대해 세부적으로 자세히 내용을 들여다 볼수 있습니다.
https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/?distro=centos
Upgrade Path
gitlab-com.gitlab.io
'04.DevTools > Git&GitLab' 카테고리의 다른 글
[GitLab] Project 삭제 방법 (0) | 2024.11.07 |
---|---|
[GitLab] git 빈 디렉토리 커밋 하는 방법 (0) | 2024.09.13 |
[GitLab] Gitlab 명령어 모음 (0) | 2022.04.17 |
[GitLab] 프로젝트 생성 및 관리 (0) | 2022.04.17 |
[GitLab] GitLab 설치 방법 및 환경설정 (0) | 2022.04.16 |