This is the second day of my participation in the August More text Challenge. For details, see:August is more challenging

Gitlab migration

background

  • Before, GITLab was deployed on Ali Cloud, because the extranet is relatively insecure, it was considered to move to the Intranet

The environment

  • Gitlab – 11.11.3 docker deployment

The implementation of

  1. The backup
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.Copy the code
  1. Start gitLab of the same version on the Intranet machine (GITLab backup and recovery requires the same version)
Docker exec -ti gitlab bash mv 1612427334_2021_02_04_11.3_gitlab_backup. tar /var/opt/gitlab/backups/ chmod 755 The/var/opt/gitlab/backups / 1612427334 _2021_02_04_11. 11.3 _gitlab_backup. Tar chown root: a 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.3Copy the code

The problem

1. Go to the CI/CD Runner page and report 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; 


Copy the code

2. Create a user, when forcing the user to change the password times 500 log display similar: because there is no first time to write an article, log display similar, not I encountered the 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"
Copy the code

Solution: Check whether the corresponding table has null values and start a new gitLab comparison table structure

Solution:

gitlabhq_production=> CREATE SEQUENCE user_preference_id_seq INCREMENT BY 1 NO MINVALUE NO MAXVALUE START WITH 106 OWNED  BY user_preferences.id; Create sequence gitlabhq_PRODUCTION again => ALTER TABLE user_preferences ALTER COLUMN ID SET DEFAULT NEXTVAL('user_preference_id_seq'::regclass); Restore the table structure modifierCopy the code

3. 500 GITLab logs after a merge is submitted to a user:

= = > / var/log/gitlab/postgresql/current < = = 2021-03-18 _05:52:05. ERROR 23424: Null value in column "ID" limits 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"Copy the code

Solution:

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; Create sequence gitlabhq_PRODUCTION => ALTER TABLE merge_request_assignees ALTER COLUMN ID SET DEFAULT NEXTVAL('merge_request_assignees_id_seq'::regclass); Restore the table structure modifierCopy the code

After the migration of Gitlab will have a database sequence loss problem, rebuild the sequence, and restore the field modifiers. Compared to the new GitLab, you will find that you may lose a lot of SEQs, and it is recommended to restore all.

Reference:Gitlab.com/gitlab-org/…