server

폐쇄망 gitlab upgrade 작업

정유현 2024. 9. 11. 18:11
728x90

Backup

# gitlab 12.2 이상 지원하는 기능(backup file path : /var/opt/gitlab/backups)
gitlab-backup create

 

백업파일 250G 기준으로 3~4시간정도 소모했다.

총 세가지 파일을 백업해야한다.

  • /etc/gitlab/gitlab.rb - gitlab 설정파일
  • /etc/gitlab/gitlab-secrets.json - gitlab 민감정보파일
  • /var/opt/gitlab/backups - gitlab-backup create로 생성된 .tar file

Gitlab 정보 확인

gitlab-rake gitlab:env:info

 

업그레이드는 최종 목표 버전으로 바로 안되고 필수 업그레이드 순서를 거쳐야한다.

꼭 확인하고 현재 버전 - 중간 필수 버전 - 최종 버전 차례대로 진행이 필요하다.

업그레이드 로드맵 : https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/

패키지 수동 다운로드

gitlab package repo : gitlab/gitlab-ce - Packages · packages.gitlab.com

최종 버전까지 필요한 버전들을 다운로드 받는다.

wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-x.x.x-ce.0.el7.x86_64.rpm/download.rpm

 

외부망을 통해 패키지를 다운받은 후 패키지 파일을 대상 서버에 전송 시킨다.

 

 

https://docs.gitlab.com/ee/administration/package_information/postgresql_versions.html

 

PostgreSQL versions shipped with the Linux package | GitLab

GitLab product documentation.

docs.gitlab.com

 

최종목표버전을 확인하고 PostgreSQL 최소버전 확인 후 먼저 PostgreSQL 업그레이드 진행해야한다.

#메이저 버전만 기입 ex- gitlab-ctl pg-upgrade -V 12
gitlab-ctl pg-upgrade -V <VERSION> 
#메이저 버전만 기입 ex- rm -rf /var/opt/gitlab/postgresql/data.11
rm -rf /var/opt/gitlab/postgresql/data.<OLD_VERSION>
rm -f /var/opt/gitlab/postgresql-version.old

무시하고 업그레이드 진행하면, 아래와 같은 에러발생

rails_migration[gitlab-rails] (gitlab::database_migrations line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: bash[migrate gitlab-rails database] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/rails_migration.rb line 16) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
rails_migration[gitlab-rails] action run fails from x.x.x to x.x.x

해결방법

https://gitlab.com/gitlab-org/gitlab/-/issues/360377

gitlab-rake gitlab:background_migrations:finalize[ProjectNamespaces::BackfillProjectNamespaces,projects,id,'[null\,"up"]']
gitlab-rake db:migrate
gitlab-ctl reconfigure
gitlab-ctl restart

Gitlab 업그레이드 진행

yum localinstall -y gitlab-ce-x.x.x-ce.0.el7.x86_64.rpm
gitlab-ctl reconfigure

 

목표 버전이 될때까지 반복한다.

 

 

정상작동 확인 후 완료

728x90