preface
The new version of GitLab Community Edition has integrated CI/CD support. To some extent, it can say goodbye to Jenkins’ dependence. I originally planned to deploy GitLab based on Docker, but I still feel a little heavy. For the Intranet offline environment, container-based deployment may not be a reasonable solution. Here, the traditional deployment method is used to introduce the simple and long-term effective GitLab deployment scheme for your reference. Perhaps in the future, container-based deployment scheme and CI/CD sharing will be added, depending on needs.
RHEL7/CentOS7 online and offline installation of GitLab configuration practice, GitLab Chinese configuration use summary
Update record
April 10, 2018 – First draft
Read the original – https://wsgzao.github.io/post/gitlab/
Further reading
GitLab Installation – https://about.gitlab.com/installation
GitLab profile
GitLab is an open source version management system developed by Ruby On Rails, which implements a self-hosted Git project repository. GitLab is an open source Git repository management software that integrates code hosting, testing and deployment into one. It can access public or private projects through web interface. Like Github, GitLab can browse code and manage defects and comments. Manages team access to the repository, makes it easy to browse committed versions, and provides a file history library. It also provides a snippet collection feature that makes it easy to reuse code and find it later when needed.
Git family member
- Git is a version control system. It is a command. It is a tool.
- Gitlib: a development library used to implement Git functionality.
- Github is an online repository for code hosting based on Git implementation. Public projects are free, and private projects can be created for a fee.
- GitLab: Is an online code repository hosting software based on Git implementation, you can use GitLab to build a set of similar to Github system.
GitLab has certain requirements for hardware. The CPU of 1 core can basically meet the requirements, supporting about 100 users. However, when running GitLab website, it also needs to run multiple background jobs, so it will be a little short. You need at least 4GB of addressable memory (RAM swapping) to install and use GitLab, and memory will also be used by the operating system and any other running applications, so keep in mind that you need at least 4GB of free space before you can run GitLab. If you use less memory, GitLab will give strange errors during the reconfiguration operation. I used virtual machines to create 1GB and 2GB CentOS systems respectively to install GitLab. It was really too tight and I couldn’t hurt it.
Gitlab’s service composition
- Nginx: static Web server
- Gitlab-shell: Used to process Git commands and modify the Authorized Keys list
- Gitlab-workhorse: lightweight reverse proxy server
- Logrotate: log file management tool
- Postgresql: indicates a database
- Redis: cache database
- Sidekiq: Used to perform queue tasks in the background (asynchronous execution)
- Unicorn: An HTTP server for Rack Applications, GitLab Rails applications are hosted on this server
GitLab workflow
[Image upload failed…(image-fDB67F-1523359408993)]
GitLab installation
Install Gitlab-CE online
Install the necessary dependencies and skip them if you don't need them
yum install pygpgme yum-utils
# On CentOS 7 (and RedHat/Oracle/Scientific Linux 7), the commands below will also open HTTP and SSH access in the system firewall.
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
# Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step and configure an external SMTP server after GitLab has been installed.
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
# Use Aliyun for acceleration
cd /etc/yum.repos.d/ && rm -f *.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# Add GitLab image source and install it
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# Create a REPO of Gitlab-CE, using Tsinghua University accelerator
vim /etc/yum.repos.d/gitlab_gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
Configure and start GitLab
gitlab-ctl reconfigure
The first time you visit GitLab, the system will redirect the page to the reset password page. You need to input the password of the initial administrator account, the user name of the administrator is root, and the new password will be the password you just entered.
0.0.0.0:80
Copy the code
Install Gitlab-CE offline
# Use Aliyun for acceleration
cd /etc/yum.repos.d/ && rm -f *.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# Add GitLab image source and install it
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# Create a REPO of Gitlab-CE, using Tsinghua University accelerator
vim /etc/yum.repos.d/gitlab_gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
# install yum-plugin-downloadonly plugin
yum install -y yum-plugin-downloadonly
Download gitlab-ce related RPM to the specified directory
mkdir -p /tmp/repo/gitlab-ce/
yum install --downloadonly --downloaddir=/tmp/repo/gitlab-ce/ gitlab-ce
Copy files to Intranet for offline installation
rpm -ivh /tmp/repo/gitlab-ce/*
Configure and start GitLab
gitlab-ctl reconfigure
The first time you visit GitLab, the system will redirect the page to the reset password page. You need to input the password of the initial administrator account, the user name of the administrator is root, and the new password will be the password you just entered.
0.0.0.0:80
Copy the code
GitLab localization
If all the team members have good English skills, there is no need to be Sinicized. My personal suggestion is to stick to the original version instead of sinicizing
GitLab Chinese community projects, v7 – v8.8 is initiated by Larry Li “GitLab Chinese community edition project” https://gitlab.com/larryli/gitlab
Localization project from v8.9 by @ xhang started on the https://gitlab.com/xhang/gitlab
If you don't have Git installed, install it first
yum install -y git
Create gitlba Chinese package download directory
mkdir -p /tmp/gitlab
cd /tmp/gitlab
Download the latest Chinese package
git clone https://gitlab.com/xhang/gitlab.git
If you want to download 10.0.2, you can run the following statement
git clonehttps://gitlab.com/xhang/gitlab.git - b v10.0.2 - usefulStop GitLab and execute the following statement
gitlab-ctl stop
cp /tmp/gitlab/gitlab/* /opt/gitlab/embedded/service/gitlab-rails/ -rf
Cp -i is an alias of cp -i. Cp -i is an alias of cp -i. Bashrc: alias cp= 'cp-i' alias cp= 'cp-i' Run commands or log out
source ~/.bashrc
You can then reconfigure and start
gitlab-ctl reconfigure
gitlab-ctl restart
Copy the code
GitLab command
# grammar
gitlab-ctl command (subcommand)
Service Management Commands
start Start all services
stop Shut down all services
restart Restart all services
status Check the status of all services
tail # View log information
service-list # list all startup services
graceful-kill Stop a service smoothly
Start all services
gitlab-ctl start
Start a single service
gitlab-ctl start nginx
# View logs, view all logs
gitlab-ctl tail
# tail -f to view a specific log
gitlab-ctl tail nginx
General Commands
help # help
reconfigure After modifying the configuration file, you need to reload it
show-config Check all service configuration files
uninstall # Uninstall this software
cleanse # Delete gitLab data and start from scratch
Display all service configuration files
gitlab-ctl show-config
# uninstall gitlab
gitlab-ctl uninstall
Copy the code
QQ Mailbox Configuration
By default, GitLab can not send confirmation email when registering with QQ mailbox. Check out many email configuration tutorials online, most of which are misleading. Like this kind of software, ultimately summed up as a word: everything to the official website documents prevail. QQ mailbox is best to use enterprise mailbox, I use personal mailbox test is some small problems, the correct configuration is as follows:
# editor gitlab. Rb
vim /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
Copy the code
GitLab use
Login GitLab
- To log in to the GitLab interface, enter IP in the address bar of the browser. The user name and password used for the first login of the old version are
root
和5iveL! fe
- The user is forced to change the password upon the first login. After the password is changed, enter the new password to log in
Create a Project
1. Install Git tool Linux: Install Git and use its own source to install Git
yum install git
Copy the code
2. Generate a key file: Run ssh-keygen to generate a key file: SSH /id_rsa.pub.
ssh-keygen -t rsa
Copy the code
3. Create a Project in GitLab’s home page
4. Add the SSH key file generated in Step 2.
Profile Settings => SSH Keys => Add SSH key
Copy the code
Simple configuration
Configure the name of the person using Git repository
git config --global user.name "wangao"
Create Git repository email address
git config --global user.email "[email protected]"
Create a local directory with the same name that contains all project files
git clone[email protected]: root/test. The gitGo to the project directory
cd test/
Create a target file that needs to be uploaded to GitLab
echo "test" > test.sh
# add test.sh file to index
git add test.sh
Commit test.sh to the local repository
git commit -m "test.sh"
# synchronize files to GitLab server
git push -u origin master
The uploaded test.sh file has been synchronized to GitLab
Copy the code