One, foreword

1. Main content of this paper

  • GitLab Community Edition deployment
  • The GITLAB configuration disables create group permissions
  • GITLAB configures mail (SMTP)
  • GITLAB backup configuration
  • Description of GITLAB common commands

    2. Introduction to GITLAB

    Gitlab is an open source git warehouse management platform, convenient for team cooperation development and management. A complete CI (continuous integration), CD (continuous release) process can be implemented on GITLAB. But also provides free use of the Plan, as well as the free version can deploy an independent community (https://gitlab.com/gitlab-org/gitlab-ce). Website: https://about.gitlab.com/

    Second, preparation work

    1, install the base dependency (this step can be skipped, many servers install by default)

    # installation technology rely on sudo yum install - y curl policycoreutils - python openssh server # SSH service & set to startup sudo systemctl enable SSHD sudo systemctl start sshd

    2. Install Postfix

    Postfix is a mail server that GitLab uses to send mail

    Sudo systemctl enable postfix sudo systemctl start postfix sudo systemctl install -y postfix

    3. Open SSH and HTTP services

    According to the actual situation, when the company’s internal server started, the firewall was not opened

    Sudo firewall-cmd --add-service= SSH --permanent sudo firewall-cmd --add-service= HTTP --permanent sudo firewall-cmd --reload

    III. Deployment process

    This time we are deploying the community version: GITLAB-CE. If you want to deploy the commercial version, you can change the keyword to: GITLAB-EE

    1. YUM installs GITLAB

  • Add the GitLab Community Edition Package

    curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash 
  • Install GitLab Community Edition

    sudo yum install -y gitlab-ce 

    After successful installation, you will see the following graphic printed by GITLAB-CE

Exception handling:

PolicyCoreutils-Python is needed by installing GitLab which is running on Centos7 if you are sure your CentOS is running on Centos7

Solution:

sudo yum installpolicycoreutils-python

If this method is invalid, your version of CentOS must not be centos7 if your version of CentOS is centos8. So get a new version of GitLab, which means download a new one, and here’s the latest address

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/

Download command:

Wget HTTP: / / https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm

Installation:

Sudo RPM -i gitlab - ce - 12.10.1 - ce. 0. El8. X86_64. RPM

PolicyCoreutils-python-utils is needed by gitlab-ce 12.10.1-ce.0.el8.x86_64 policyCoreutils-python-utils is needed by gitlab-ce 12.10.1-ce.0.el8.x86_64 policyCoreutils-python-utils is needed by gitlab-ce 12.10.1-ce.0.el8.x86_64

sudo yum install policycoreutils-python-utils

Then reinstall.

Reference: https://blog.csdn.net/fu18838928050/article/details/107901895

2. Configure the GitLab site URL

The default GitLab configuration file path is /etc/gitlab/gitlab.rb. The default site URL configuration entry is:

external_url 'http://gitlab.example.com'

Here I change the URL of the Gitlab site to “external_url ‘http://192.168.0.80:9000” or you can use IP instead of the domain name. Here you can do it according to your own needs

# modified configuration file sudo vi/etc/gitlab/gitlab rb # configuration page address (about in line 15) external_url 'http://192.168.0.80:9000'

3. Start and access GitLab

  • Start the GitLab

    Sudo gitlab-ctl reconfigure: Running handlers complete Chef Client finished 432/613 resources updated in 03 minutes 43 seconds gitlab Reconfigured!
  • Visit GitLab

Resolve the set domain name DNS to the server IP, or modify the local host to point the domain name to the server IP.

Access:http://192.168.0.80:9000



You will be prompted to set a password for the administrator account. The default username for an administrator account is root.

After setting up, you can log in with root account. After logging in, you will enter the welcome screen.

IV. Common configuration of GITLAB

1. Mail configuration

The configuration of email addresses allows GitLab to send email notifications when corresponding events occur. For example, the configuration of Tencent enterprise email addresses is as follows:

gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.exmail.qq.com" gitlab_rails['smtp_port'] = 465 Gitlab_rails ['smtp_user_name'] = "Your mailbox" gitlab_rails['smtp_password'] = "Your mailbox password" gitlab_rails['smtp_domain'] = "exmail.qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true Gitlab_rails ['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'Your mailbox'

Specific reference: https://docs.gitlab.com/omnibus/settings/smtp.html

2. Disable the create group permission

By default, GitLab allows all registered users to create groups. For teams, however, it is usually only the Leader who is given relevant permissions. Although you can cancel the permissions in the user administration interface, it is not convenient after all. We can configure GitLab to disable the Create Group permission by default.

Gitlab_rails ['gitlab_default_can_create_group'] ['gitlab_default_can_create_group'] ['gitlab_default_can_create_group'] ['gitlab_default_can_create_group'] ### GitLab user privileges gitlab_rails['gitlab_default_can_create_group'] = false # Reconfigure and start GitLab sudo gitlab-ctl reconfigure

3. Configure the code location

Locate the git_data_dirs selection and configure the address


git_data_dirs({
   "default" => {
     "path" => "/data/tools/gitlab/data"
    }
})

Refer to the link: https://docs.gitlab.com/omnibus/settings/configuration.html

4. Gitlab backup

1) Modify the configuration file

# open gitlab vim configuration file/etc/gitlab/gitlab rb # set the backup file save position gitlab_rails [' backup_path] = "/ data/tools/gitlab/backup" # Set expiration time for backup files, in seconds, default 7 days gitlab_rails['backup_keep_time'] = 604800

After performing the WQ save, refresh the configuration

gitlab-ctl reconfigure

2) Verify the backup command

Execute the backup command to check the corresponding file path to see if the backup file has been created

gitlab-rake gitlab:backup:create

The execution is printed as follows:



The red font described as gitlab.rb and gitlab-secrets. JSON are sensitive files that need to be backed up manually

3) Timed backup via cron

Method 1. Enter “crontab-e” on the command line and add the corresponding task. Save WQ and exit.

0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1

Method 2: Edit the /etc/crontab file directly (vim /etc/crontab) and add the corresponding tasks

And certain tasks are added at 2 am every day, 2 * * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1

Restart the cron service

systemctl restart crond.service

5. Introduction to common commands of gitlab-ctl

The command instructions
check-config Check if there is any configuration in GitLab. The RB deleted in the specified version
deploy-page Installation and deployment page
diff-config Compare the user configuration to the package available configuration
remove-accounts Delete all users and groups
upgrade upgrade
service-list View all services
once If the GitLab service is stopped, the service is started, and if it is started, nothing is done
restart Restart the GitLab service
start Start the GitLab service if it is stopped and restart the service if it is started
stop Stop the GitLab service
status View GitLab service status
reconfigure Reconfigure reconfigures GitLab and starts

Refer to the link: https://ken.io/note/centos7-gitlab-install-tutorial