[git] basic maintenance and use of gitlab

[git] basic maintenance and use of gitlab

 

 

Basic introduction

GitLab is a self managed Git project warehouse. You can build your own warehouse for personal code management. Its function is similar to github.

install

Download gitlab download address: https://about.gitlab.com/downloads/

Install dependent packages

1 2 3 4 5 6 7 8 9 10 11 sudo yum install curl-devel sudo yum install expat-devel sudo yum install gettext-devel sudo yum install openssl-devel sudo yum install zlib-devel sudo yum install perl-devel sudo yum install curl sudo yum install openssh-server sudo yum install openssh-clients sudo yum install postfix sudo yum install cronie<br>  sudo yum install policycoreutils-python 

Ubuntu system uses apt get to install dependent packages.

Install using the script on the gitlab official website

1 curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

Or install gitlab using yum or up2date from gitlab

1 sudo yum install gitlab-ce

Configure email

1 2 3 yum install postfix systemctl enable postfix systemctl start postfix

  

After installation, log in using the Web

 

Enter the management page of gitlab to maintain common function points such as grouping, engineering and users.

 

Operation and maintenance after installing gitlab

Initial configuration service

1 sudo gitlab-ctl reconfigure

Start service

1 sudo gitlab-ctl start

Out of Service

1 sudo gitlab-ctl stop

Restart service

1 sudo gitlab-ctl restart

Backup warehouse

Modify / etc / gitlab / gitlab rb

Configure the path to be backed up, and then re execute the command sudo gitlab CTL reconfigure to update the configuration.

Execute the following command to create a backup

1 sudo gitlab-rake gitlab:backup:create

When creating a backup, the following information will be displayed (the groups on gitlab and all projects will be backed up in turn).

Backup file format: Unix timestamp_ gitlab_backup.tar, for example, the following example of a backup file.

 

Warehouse recovery for backup

1 gitlab-rake gitlab:backup:restore BACKUP=1483198680

When restoring, the selected version is the Unix timestamp generated by the backup.

Note: during recovery, stop the service first to avoid data error caused by double write.  

Modify the configuration / etc / gitlab / gitlab RB file

Modify data file directory

1 2 find out git_data_dir Configuration information, adding git_data_dir "/data/gitlab-data"

Modify backup directory

1 gitlab_rails['backup_path'] = "/data/gitlab-data/backups"

Configure mailbox

1 2 3 4 5 6 7 8 9 10 11 gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "your.smtp.server" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "your.smtp user" gitlab_rails['smtp_password'] = "your.smtp password" gitlab_rails['smtp_domain'] = "your.demain.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['gitlab_email_from'] = 'gitlab@mail.domain.com' gitlab_rails['gitlab_email_reply_to'] = 'noreply@mail.domain.com'

Modify the domain name or IP address of git warehouse

1 2 # external_url 'http://192.168.1.100 '# replace # modify to domain name access external_url 'http://gitlab.your.com' 

  

Check the log information of the service

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # Check the redis log sudo gitlab-ctl tail redis   # Check the postgresql log sudo gitlab-ctl tail postgresql   # Check the log of gitlab workhorse sudo gitlab-ctl tail gitlab-workhorse   # Check the log of logrotate sudo gitlab-ctl tail logrotate   # Check the log of nginx sudo gitlab-ctl tail nginx   # Check the sidekiq log sudo gitlab-ctl tail sidekiq   # Check unicorn's log sudo gitlab-ctl tail unicorn

  

Check service status

1 sudo gitlab-ctl status

General service status display information

Display format:

Status: process name: (process ID) running time (seconds); Log service process and running time of the process

1 2 3 4 5 6 7 run: gitlab-workhorse: (pid 11892) 281s; run: log: (pid 8630) 4742472s run: logrotate: (pid 11904) 280s; run: log: (pid 8631) 4742472s run: nginx: (pid 11911) 280s; run: log: (pid 8796) 4742455s run: postgresql: (pid 12866) 18s; run: log: (pid 8627) 4742472s run: redis: (pid 11989) 249s; run: log: (pid 8638) 4742472s run: sidekiq: (pid 12850) 20s; run: log: (pid 8634) 4742472s run: unicorn: (pid 12022) 247s; run: log: (pid 8629) 4742472s
state explain
run running state
down Service stop

 

Common problems

1. The page displays 500, Whoops, something Wen wrong on our end

1 2 3 4 5 6 7 500   Whoops, something went wrong on our end.   Try refreshing the page, or going back and attempting the action again.   Please contact your GitLab administrator if this problem persists.

How to check and locate problems?

Use the command to check the status of all services

1 sudo gitlab-ctl status

Check the service status as follows

1 2 3 4 5 6 7 run: gitlab-workhorse: (pid 11892) 91s; run: log: (pid 8630) 4742282s run: logrotate: (pid 11904) 90s; run: log: (pid 8631) 4742282s run: nginx: (pid 11911) 90s; run: log: (pid 8796) 4742265s down: postgresql: 1s, normally up, want up; run: log: (pid 8627) 4742282s run: redis: (pid 11989) 59s; run: log: (pid 8638) 4742282s run: sidekiq: (pid 12201) 2s; run: log: (pid 8634) 4742282s run: unicorn: (pid 12022) 57s; run: log: (pid 8629) 4742282s

Positioning problem

From the service status information, the status of the database postgresql is down, that is, the service is stopped.

Check the operation log of the database postgresql and check what errors occur?

1 2 3 4 5 6 7 8 $ sudo gitlab-ctl tail postgresql ==> /var/log/gitlab/postgresql/state <==   ==> /var/log/gitlab/postgresql/current <== 2016-12-24_01:39:39.00188 FATAL:  data directory "/var/opt/gitlab/postgresql/data" has group or world access 2016-12-24_01:39:39.00190 DETAIL:  Permissions should be u=rwx (0700). 2016-12-24_01:39:40.00698 FATAL:  data directory "/var/opt/gitlab/postgresql/data" has group or world access 2016-12-24_01:39:40.00700 DETAIL:  Permissions should be u=rwx (0700).

The log shows that only the user has read / write permission to access the database, and user groups and other users cannot have permission.

After modifying the permissions of the database data, check that the service is running normally.

After understanding the problem location and solution, other problems can be easily found and solved in the log. The problems may be due to low disk space, wrong user permissions or other reasons.

 

2. How to reset the password if the gitlab administrator forgot the password

Gitlab modifies the root user password

Open the terminal with rails tool

1 sudo gitlab-rails console production

Query the user's email, user name, password and other information. id:1 indicates the root account

1 user = User.where(id: 1).first

Reset password

1 2 user.password = 'New password' user.password_confirmation = 'New password' 

Save password

1 user.save!

Complete operation ruby script

1 2 3 4 user = User.where(id: 1).first user.password = 'New password' user.password_confirmation = 'New password' user.save!

Then log in again with the reset password.

 

Done.

Keywords: GitLab

Added by Benny Johnson on Mon, 03 Jan 2022 14:54:37 +0200