在线安装:
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
或者
sudo apt-get install gitlab-ce=13.2.2-ce.0
手动离线安装:
wget —content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/jessie/gitlab-ce_13.2.2-ce.0_amd64.deb/download.deb
dpkg -i gitlab-ce_13.2.2-ce.0_amd64.deb
版本升级

  1. cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
  2. dpkg -i gitlab-ce_13.2.3-ce.0_amd64.deb
  3. dpkg -i gitlab-ce_13.2.4-ce.0_amd64.deb
  4. dpkg -i gitlab-ce_13.2.5-ce.0_amd64.deb
  5. dpkg -i gitlab-ce_13.2.6-ce.0_amd64.deb
  6. dpkg -i gitlab-ce_13.2.7-ce.0_amd64.deb
  7. dpkg -i gitlab-ce_13.2.8-ce.0_amd64.deb
  8. dpkg -i gitlab-ce_13.2.9-ce.0_amd64.deb
  9. dpkg -i gitlab-ce_13.2.10-ce.0_amd64.deb
  10. dpkg -i gitlab-ce_13.3.0-ce.1_amd64.deb
  11. dpkg -i gitlab-ce_13.3.1-ce.0_amd64.deb
  12. dpkg -i gitlab-ce_13.3.2-ce.0_amd64.deb
  13. dpkg -i gitlab-ce_13.3.3-ce.0_amd64.deb
  14. dpkg -i gitlab-ce_13.3.4-ce.0_amd64.deb
  15. dpkg -i gitlab-ce_13.3.5-ce.0_amd64.deb
  16. dpkg -i gitlab-ce_13.3.6-ce.0_amd64.deb
  17. dpkg -i gitlab-ce_13.3.7-ce.0_amd64.deb
  18. dpkg -i gitlab-ce_13.3.8-ce.0_amd64.deb
  19. dpkg -i gitlab-ce_13.3.9-ce.0_amd64.deb
  20. dpkg -i gitlab-ce_13.4.0-ce.0_amd64.deb
  21. dpkg -i gitlab-ce_13.4.1-ce.0_amd64.deb
  22. dpkg -i gitlab-ce_13.4.2-ce.0_amd64.deb
  23. dpkg -i gitlab-ce_13.4.3-ce.0_amd64.deb
  24. dpkg -i gitlab-ce_13.4.4-ce.0_amd64.deb
  25. dpkg -i gitlab-ce_13.4.5-ce.0_amd64.deb
  26. dpkg -i gitlab-ce_13.4.6-ce.0_amd64.deb
  27. dpkg -i gitlab-ce_13.4.7-ce.0_amd64.deb
  28. dpkg -i gitlab-ce_13.5.0-ce.0_amd64.deb
  29. dpkg -i gitlab-ce_13.5.1-ce.0_amd64.deb
  30. dpkg -i gitlab-ce_13.5.2-ce.0_amd64.deb
  31. dpkg -i gitlab-ce_13.5.3-ce.0_amd64.deb
  32. dpkg -i gitlab-ce_13.5.4-ce.0_amd64.deb
  33. dpkg -i gitlab-ce_13.5.5-ce.0_amd64.deb
  34. dpkg -i gitlab-ce_13.5.6-ce.0_amd64.deb
  35. dpkg -i gitlab-ce_13.5.7-ce.0_amd64.deb
  36. dpkg -i gitlab-ce_13.6.0-ce.0_amd64.deb
  37. dpkg -i gitlab-ce_13.6.1-ce.0_amd64.deb
  38. dpkg -i gitlab-ce_13.6.2-ce.0_amd64.deb
  39. dpkg -i gitlab-ce_13.6.3-ce.0_amd64.deb
  40. dpkg -i gitlab-ce_13.6.4-ce.0_amd64.deb
  41. dpkg -i gitlab-ce_13.6.5-ce.0_amd64.deb
  42. dpkg -i gitlab-ce_13.6.6-ce.0_amd64.deb
  43. dpkg -i gitlab-ce_13.6.7-ce.0_amd64.deb
  44. dpkg -i gitlab-ce_13.7.0-ce.0_amd64.deb
  45. dpkg -i gitlab-ce_13.7.1-ce.0_amd64.deb
  46. dpkg -i gitlab-ce_13.7.2-ce.0_amd64.deb
  47. dpkg -i gitlab-ce_13.7.3-ce.0_amd64.deb
  48. dpkg -i gitlab-ce_13.7.4-ce.0_amd64.deb
  49. dpkg -i gitlab-ce_13.7.5-ce.0_amd64.deb
  50. dpkg -i gitlab-ce_13.7.6-ce.0_amd64.deb
  51. dpkg -i gitlab-ce_13.7.7-ce.0_amd64.deb
  52. dpkg -i gitlab-ce_13.7.8-ce.0_amd64.deb
  53. dpkg -i gitlab-ce_13.7.9-ce.0_amd64.deb
  54. dpkg -i gitlab-ce_13.8.0-ce.0_amd64.deb
  55. dpkg -i gitlab-ce_13.8.1-ce.0_amd64.deb
  56. dpkg -i gitlab-ce_13.8.2-ce.0_amd64.deb
  57. dpkg -i gitlab-ce_13.8.3-ce.0_amd64.deb
  58. dpkg -i gitlab-ce_13.8.4-ce.0_amd64.deb
  59. dpkg -i gitlab-ce_13.8.5-ce.0_amd64.deb
  60. dpkg -i gitlab-ce_13.8.6-ce.0_amd64.deb
  61. dpkg -i gitlab-ce_13.8.7-ce.0_amd64.deb
  62. dpkg -i gitlab-ce_13.8.8-ce.0_amd64.deb
  63. dpkg -i gitlab-ce_13.9.0-ce.0_amd64.deb
  64. dpkg -i gitlab-ce_13.9.1-ce.0_amd64.deb
  65. dpkg -i gitlab-ce_13.9.2-ce.0_amd64.deb
  66. dpkg -i gitlab-ce_13.9.3-ce.0_amd64.deb
  67. dpkg -i gitlab-ce_13.9.4-ce.0_amd64.deb
  68. dpkg -i gitlab-ce_13.9.5-ce.0_amd64.deb
  69. dpkg -i gitlab-ce_13.9.6-ce.0_amd64.deb
  70. dpkg -i gitlab-ce_13.9.7-ce.0_amd64.deb
  71. dpkg -i gitlab-ce_13.10.0-ce.0_amd64.deb
  72. dpkg -i gitlab-ce_13.10.1-ce.0_amd64.deb
  73. dpkg -i gitlab-ce_13.10.2-ce.0_amd64.deb
  74. dpkg -i gitlab-ce_13.10.3-ce.0_amd64.deb
  75. dpkg -i gitlab-ce_13.10.4-ce.0_amd64.deb
  76. dpkg -i gitlab-ce_13.10.5-ce.0_amd64.deb
  77. dpkg -i gitlab-ce_13.11.0-ce.0_amd64.deb
  78. dpkg -i gitlab-ce_13.11.1-ce.0_amd64.deb
  79. dpkg -i gitlab-ce_13.11.2-ce.0_amd64.deb
  80. dpkg -i gitlab-ce_13.11.3-ce.0_amd64.deb
  81. dpkg -i gitlab-ce_13.11.4-ce.0_amd64.deb
  82. dpkg -i gitlab-ce_13.11.5-ce.0_amd64.deb
  83. dpkg -i gitlab-ce_13.11.7-ce.0_amd64.deb
  84. dpkg -i gitlab-ce_13.12.0-ce.0_amd64.deb
  85. dpkg -i gitlab-ce_13.12.1-ce.0_amd64.deb
  86. dpkg -i gitlab-ce_13.12.2-ce.0_amd64.deb
  87. dpkg -i gitlab-ce_13.12.3-ce.0_amd64.deb
  88. dpkg -i gitlab-ce_13.12.4-ce.0_amd64.deb
  89. dpkg -i gitlab-ce_13.12.5-ce.0_amd64.deb
  90. dpkg -i gitlab-ce_13.12.6-ce.0_amd64.deb
  91. dpkg -i gitlab-ce_13.12.7-ce.0_amd64.deb
  92. dpkg -i gitlab-ce_13.12.8-ce.0_amd64.deb
  93. dpkg -i gitlab-ce_13.12.9-ce.0_amd64.deb
  94. dpkg -i gitlab-ce_13.12.10-ce.0_amd64.deb
  95. dpkg -i gitlab-ce_13.12.11-ce.0_amd64.deb
  96. dpkg -i gitlab-ce_13.12.12-ce.0_amd64.deb
  97. dpkg -i gitlab-ce_13.12.15-ce.0_amd64.deb
  98. dpkg -i gitlab-ce_14.0.0-ce.0_amd64.deb
  99. dpkg -i gitlab-ce_14.0.1-ce.0_amd64.deb
  100. dpkg -i gitlab-ce_14.0.2-ce.0_amd64.deb
  101. dpkg -i gitlab-ce_14.0.3-ce.0_amd64.deb
  102. dpkg -i gitlab-ce_14.0.4-ce.0_amd64.deb
  103. dpkg -i gitlab-ce_14.0.5-ce.0_amd64.deb
  104. dpkg -i gitlab-ce_14.0.6-ce.0_amd64.deb
  105. dpkg -i gitlab-ce_14.0.7-ce.0_amd64.deb
  106. dpkg -i gitlab-ce_14.0.8-ce.0_amd64.deb
  107. dpkg -i gitlab-ce_14.0.9-ce.0_amd64.deb
  108. dpkg -i gitlab-ce_14.0.10-ce.0_amd64.deb
  109. dpkg -i gitlab-ce_14.0.11-ce.0_amd64.deb
  110. dpkg -i gitlab-ce_14.0.12-ce.0_amd64.deb
  111. dpkg -i gitlab-ce_14.1.0-ce.0_amd64.deb
  112. dpkg -i gitlab-ce_14.1.1-ce.0_amd64.deb
  113. dpkg -i gitlab-ce_14.1.2-ce.0_amd64.deb
  114. dpkg -i gitlab-ce_14.1.3-ce.0_amd64.deb
  115. dpkg -i gitlab-ce_14.1.4-ce.0_amd64.deb
  116. dpkg -i gitlab-ce_14.1.5-ce.0_amd64.deb
  117. dpkg -i gitlab-ce_14.1.6-ce.0_amd64.deb
  118. dpkg -i gitlab-ce_14.1.7-ce.0_amd64.deb
  119. dpkg -i gitlab-ce_14.1.8-ce.0_amd64.deb
  120. dpkg -i gitlab-ce_14.2.0-ce.0_amd64.deb
  121. dpkg -i gitlab-ce_14.2.1-ce.0_amd64.deb
  122. dpkg -i gitlab-ce_14.2.2-ce.0_amd64.deb
  123. dpkg -i gitlab-ce_14.2.3-ce.0_amd64.deb
  124. dpkg -i gitlab-ce_14.2.4-ce.0_amd64.deb
  125. dpkg -i gitlab-ce_14.2.5-ce.0_amd64.deb
  126. dpkg -i gitlab-ce_14.2.6-ce.0_amd64.deb
  127. dpkg -i gitlab-ce_14.2.7-ce.0_amd64.deb
  128. dpkg -i gitlab-ce_14.3.0-ce.0_amd64.deb
  129. dpkg -i gitlab-ce_14.3.1-ce.0_amd64.deb
  130. dpkg -i gitlab-ce_14.3.2-ce.0_amd64.deb
  131. dpkg -i gitlab-ce_14.3.3-ce.0_amd64.deb
  132. dpkg -i gitlab-ce_14.3.4-ce.0_amd64.deb
  133. dpkg -i gitlab-ce_14.3.5-ce.0_amd64.deb
  134. dpkg -i gitlab-ce_14.3.6-ce.0_amd64.deb
  135. dpkg -i gitlab-ce_14.4.0-ce.0_amd64.deb
  136. dpkg -i gitlab-ce_14.4.1-ce.0_amd64.deb
  137. dpkg -i gitlab-ce_14.4.2-ce.0_amd64.deb
  138. dpkg -i gitlab-ce_14.4.3-ce.0_amd64.deb
  139. dpkg -i gitlab-ce_14.4.4-ce.0_amd64.deb
  140. dpkg -i gitlab-ce_14.4.5-ce.0_amd64.deb
  141. dpkg -i gitlab-ce_14.5.0-ce.0_amd64.deb
  142. dpkg -i gitlab-ce_14.5.1-ce.0_amd64.deb
  143. dpkg -i gitlab-ce_14.5.2-ce.0_amd64.deb
  144. dpkg -i gitlab-ce_14.5.3-ce.0_amd64.deb
  145. dpkg -i gitlab-ce_14.5.4-ce.0_amd64.deb
  146. dpkg -i gitlab-ce_14.6.0-ce.0_amd64.deb
  147. dpkg -i gitlab-ce_14.6.1-ce.0_amd64.deb
  148. dpkg -i gitlab-ce_14.6.2-ce.0_amd64.deb
  149. dpkg -i gitlab-ce_14.6.3-ce.0_amd64.deb
  150. dpkg -i gitlab-ce_14.6.4-ce.0_amd64.deb
  151. dpkg -i gitlab-ce_14.6.5-ce.0_amd64.deb
  152. dpkg -i gitlab-ce_14.6.6-ce.0_amd64.deb
  153. dpkg -i gitlab-ce_14.6.7-ce.0_amd64.deb
  154. dpkg -i gitlab-ce_14.7.0-ce.0_amd64.deb
  155. dpkg -i gitlab-ce_14.7.1-ce.0_amd64.deb
  156. dpkg -i gitlab-ce_14.7.2-ce.0_amd64.deb
  157. dpkg -i gitlab-ce_14.7.3-ce.0_amd64.deb
  158. dpkg -i gitlab-ce_14.7.4-ce.0_amd64.deb
  159. dpkg -i gitlab-ce_14.7.5-ce.0_amd64.deb
  160. dpkg -i gitlab-ce_14.7.6-ce.0_amd64.deb
  161. dpkg -i gitlab-ce_14.7.7-ce.0_amd64.deb
  162. dpkg -i gitlab-ce_14.8.0-ce.0_amd64.deb
  163. dpkg -i gitlab-ce_14.8.1-ce.0_amd64.deb
  164. dpkg -i gitlab-ce_14.8.2-ce.0_amd64.deb
  165. dpkg -i gitlab-ce_14.8.3-ce.0_amd64.deb
  166. dpkg -i gitlab-ce_14.8.4-ce.0_amd64.deb
  167. dpkg -i gitlab-ce_14.8.5-ce.0_amd64.deb
  168. dpkg -i gitlab-ce_14.8.6-ce.0_amd64.deb
  169. dpkg -i gitlab-ce_14.9.0-ce.0_amd64.deb
  170. dpkg -i gitlab-ce_14.9.1-ce.0_amd64.deb
  171. dpkg -i gitlab-ce_14.9.2-ce.0_amd64.deb
  172. dpkg -i gitlab-ce_14.9.3-ce.0_amd64.deb
  173. dpkg -i gitlab-ce_14.9.4-ce.0_amd64.deb
  174. dpkg -i gitlab-ce_14.9.5-ce.0_amd64.deb
  175. dpkg -i gitlab-ce_14.10.0-ce.0_amd64.deb
  176. dpkg -i gitlab-ce_14.10.1-ce.0_amd64.deb
  177. dpkg -i gitlab-ce_14.10.2-ce.0_amd64.deb
  178. dpkg -i gitlab-ce_14.10.3-ce.0_amd64.deb
  179. dpkg -i gitlab-ce_14.10.4-ce.0_amd64.deb
  180. dpkg -i gitlab-ce_14.10.5-ce.0_amd64.deb
  181. dpkg -i gitlab-ce_15.0.0-ce.0_amd64.deb
  182. dpkg -i gitlab-ce_15.0.1-ce.0_amd64.deb
  183. dpkg -i gitlab-ce_15.0.2-ce.0_amd64.deb
  184. dpkg -i gitlab-ce_15.0.3-ce.0_amd64.deb
  185. dpkg -i gitlab-ce_15.0.4-ce.0_amd64.deb
  186. dpkg -i gitlab-ce_15.1.0-ce.0_amd64.deb
  187. dpkg -i gitlab-ce_15.1.1-ce.0_amd64.deb
  188. dpkg -i gitlab-ce_15.1.2-ce.0_amd64.deb

踩过的坑:

  1. 从14.8.0升级到14.8.1出现以下错误:

1657173598083.png
解决方案:
创建文件夹mkdir /var/opt/gitlab/gitlab-rails/shared/registry
1657173798297.png
参考文档:https://gitlab.com/gitlab-org/gitlab/-/issues/353625
2.从14.9.5升级到14.10.0出现以下错误:
Running handlers:
There was an error running gitlab-ctl reconfigure:
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: Command execution failed. STDOUT/STDERR suppressed for sensitive resource
1657176400881.png
解决方案:
sudo gitlab-rake db:migrate
1657176507101.png
sudo gitlab-rake gitlab:background_migrations:finalize[ProjectNamespaces::BackfillProjectNamespaces,projects,id,’[null\,”up”]’]
1657176545950.png
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
参考文档:https://yangyq.net/2022/05/gitlab-update-error.html

GitLab从旧服务器迁移到新服务器

1657075226399.png
1657075263635.png
1657075290625.png
迁移前首先要保证新旧服务器上的GitLab版本号一致。

查看当前GitLab版本

cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
1
显示为 10.3.3。

1 新服务器升级系统
内核和软件一起升级

yum -y update
1
升级完成后查看系统版本号

cat /etc/redhat-release
1
输出如下:CentOS Linux release 7.6

2 新服务器上安装GitLab
安装教程在这里
安装完成后,最新版本的GitLab是 12.0.1。相当于说,要在旧服务器上把GitLab从10.3.3升级到12.0.1。

3 旧服务器升级GitLab
GitLab不能跨版本升级,需一个一个大版本升级。例如:10.8.7是10的最后一个版本,11.11.0是11的最后一个版本,则从 10.3.3 升级到 12.0.1,需要经过 10.3.3 -> 10.8.7 -> 11.11.0 -> 12.0.1。。

yum install -y gitlab-ce-10.8.7-ce.0.el7
yum install -y gitlab-ce-11.11.0-ce.0.el7
yum install -y gitlab-ce
1
2
3
注:如果不指定版本号,则自动升级到最新版本。

在每一次升级后,都要测试GitLab后台系统是否正常,如果不能访问了,则说明本次升级失败,应解决错误或回退版本。

4 拷贝旧服务器的备份文件到新服务器
4.1 备份旧服务器的文件
gitlab-rake gitlab:backup:create
1
默认将会在 /var/opt/gitlab/backups/ 目录下生成备份文件。

4.2 使用scp命令从本地旧服务器复制文件到新服务器
scp /var/opt/gitlab/backups/1561597102_2019_06_27_12.0.1_gitlab_backup.tar root@xxx.xxx.xxx.xxx:/var/opt/gitlab/backups/
1
根据提示输入自己新服务器的密码:xxxxxx

5 新服务器恢复GitLab
5.1 将备份文件权限修改为777,避免出现权限不够的问题
cd /var/opt/gitlab/backups
chomd 777 1561597102_2019_06_27_12.0.1_gitlab_backup.tar
1
2
5.2 停止数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
1
2
5.3 恢复备份文件到GitLab
gitlab-rake gitlab:backup:restore BACKUP=备份文件编号
1
例如:备份文件名为1561597102_2019_06_27_12.0.1_gitlab_backup.tar,则编号为1561597102_2019_06_27_12.0.1。
在提示中敲入“yes”继续。

5.4 启动GitLab
gitlab-ctl start

最后检查新旧GitLab的内容,完全一模一样,迁移成功!