关于gitlab-ce:gitlab迁移及迁移后500问题

29次阅读

共计 2066 个字符,预计需要花费 6 分钟才能阅读完成。

gitlab 迁徙

背景

  • 之前 gitlab 在阿里云机部署,因为外网绝对不平安思考迁到内网

环境

  • gitlab-11.11.3 docker 部署

施行

  1. 备份
docker exec -ti gitlab bash
gitlab-rake gitlab:backup:create
docker cp gitlab:/var/opt/gitlab/backups/1612427334_2021_02_04_11.11.3_gitlab_backup.tar .
  1. 在内网机器启动雷同版本 gitlab(gitlab 备份复原须要雷同版本 )
docker exec -ti gitlab bash
mv 1612427334_2021_02_04_11.11.3_gitlab_backup.tar /var/opt/gitlab/backups/
chmod 755 /var/opt/gitlab/backups/1612427334_2021_02_04_11.11.3_gitlab_backup.tar
chown root:root /var/opt/gitlab/backups/1612427334_2021_02_04_11.11.3_gitlab_backup.tar
gitlab-rake gitlab:backup:restore BACKUP=1612427334_2021_02_04_11.11.3

问题

1. 进入 ci/cd runner 页面报 500

gitlab-rails console
Ci::Runner.all.update_all(token_encrypted: nil)

gitlab-rails dbconsole
UPDATE projects SET runners_token = null, runners_token_encrypted = null; 

2. 新建用户,在强制用户批改明码时报 500
log 显示相似: 因为没有第一工夫写文章,日志显示相似,不是我遇到的日志。


The form contains the following error:

    PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, 164, t). : INSERT INTO "project_ci_cd_settings" ("project_id") VALUES (164) RETURNING "id"

解决思路:查看对应表有没有 null 值,启动全新的 gitlab 比照表构造

解决:

gitlabhq_production=> CREATE SEQUENCE user_preference_id_seq INCREMENT BY 1 NO MINVALUE NO MAXVALUE START WITH 106 OWNED BY user_preferences.id;   从新创立 sequence
gitlabhq_production=> ALTER TABLE user_preferences ALTER COLUMN id SET DEFAULT NEXTVAL('user_preference_id_seq'::regclass);                         复原表构造修饰符

3. 创立 merge 时指定给用户时,提交后 500
gitlab 日志:

==> /var/log/gitlab/postgresql/current <==
2021-03-18_05:52:05.23424 ERROR:  null value in column "id" violates not-null constraint
2021-03-18_05:52:05.23427 DETAIL:  Failing row contains (null, 61, 4046).
2021-03-18_05:52:05.23427 STATEMENT:  INSERT INTO "merge_request_assignees" ("user_id", "merge_request_id") VALUES (61, 4046) RETURNING "id"

解决:

gitlabhq_production=> CREATE SEQUENCE merge_request_assignees_id_seq INCREMENT BY 1 NO MINVALUE NO MAXVALUE START WITH 106 OWNED BY merge_request_assignees.id;   从新创立 sequence
gitlabhq_production=> ALTER TABLE merge_request_assignees ALTER COLUMN id SET DEFAULT NEXTVAL('merge_request_assignees_id_seq'::regclass);                         复原表构造修饰符 

阐明:迁徙 gitlab 后会有数据库序列失落问题,重建序列,并复原字段修饰符。比照全新 gitlab 你会发现,可能会失落很多 seq,倡议复原所有。

参考:https://gitlab.com/gitlab-org…

正文完
 0