This is the 16th day of my participation in the August More Text Challenge. For details, see: August More Text Challenge

A lifelong learner, practitioner, and sharer committed to the path of technology, an original blogger who is busy and sometimes lazy, and a teenager who is occasionally boring and sometimes humorous.

Welcome to search “Jge’s IT Journey” on wechat!

Install and configure GitLab on Linux

What is GitLab?

GitLab is an open source project for a repository management system that uses Git as a code management tool and builds a Web service based on it.

Features of GitLab

Provides the ability to manage, plan, create, validate, package, publish, configure, monitor and secure applications. It is an online code repository hosting software, a code management platform that provides code hosting, submit for review, and issue tracking

The server must have the following requirements: CPU2 core and at least 4 gb memory

Git, GitLab, GitHub

Git version operation based on command, all command operation, no visual interface;

Gitlab is an online code warehouse software based on Git implementation, which provides a Web management interface for internal enterprises.

Github is an online repository software based on Git implementation. It provides a visual management interface and provides open and private repositories. Most open source projects choose Github as their code hosting repository;

Service component

  • Nginx: Static Web server: port 80.
  • Gitlab-shell: Used to process git commands and modify authorized key lists;
  • Gitlab-workhorse: Lightweight Reverse proxy server (GO);
  • Gitlab-workhorse is an agile reverse proxy that handles large HTTP requests such as file upload, download, git
  • Push /pull and Git downloads, other requests are reversely proxyed to the GitLab Rails application, i.e. to unicorn on the back end;
  • Logrotate: Log file management tool;
  • Postgresql: database.
  • Reids: Cache database;
  • Sidekiq: Used to execute queue tasks in the background (asynchronously) (Ruby);
  • Unicorn: An HTTP server written in Ruby: port 8080;
  • Gitlab Rails application: Is hosted on this server

Function is introduced

  • Web-based management platform;
  • Has the perfect authority control and the identity authentication module;
  • Problem tracking and code quality management;
  • Code review;
  • Document management, knowledge base management;

Steps to install GitLab

[root@localhost ~]# ls /var/cache/yum/x86_64/\$releasever/gitlab_gitlab-ce/packages/ // * * * ~]# yum install -y curl openssh-server openssh-clients cronie policycoreutils-python postfix // Install dependencies [root@localhost ~]#  curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash // Download gitlab yum repository source, Right of sudo to carry (applicable to ordinary users)/root @ localhost ~ # yum list | grep gitlab - ce / / see if any gitlab - ce gitlab - ce. X86_64 11.7.5 - ce. 0. El7 Gitlab-ce [root@localhost ~]# yum -y install gitlab-ce [root@localhost ~]# ls /var/cache/yum/x86_64/\$releasever/gitlab_gitlab-ce/ \$releasever/gitlab_gitlab-ce/ / ### set URL [root@localhost ~]# vim External_url 'http://gitlab.bdqn.cn' [root@localhost ~]# vim /etc/hosts // Edit a domain name resolution 192.168.1.21 gitlab.bdqn.cn [root@localhost ~]# gitlab-ctl reconfigure // Reconfigure the gitlab configuration file [root@localhost ~]# gitlab-ctl Ok: run: alertManager: (PID 5151) 363s OK: run: gitaly: (PID 4934) 368s OK: run: gitlab-monitor: (pid 5070) 366s ok: run: gitlab-workhorse: (pid 4897) 370s ok: run: logrotate: (pid 4120) 416s ok: run: nginx: (pid 4071) 418s ok: run: node-exporter: (pid 4974) 367s ok: run: postgres-exporter: (pid 5178) 362s ok: run: postgresql: (pid 3564) 458s ok: run: prometheus: (pid 5111) 364s ok: run: redis: (pid 3420) 464s ok: run: redis-exporter: (pid 5090) 365s ok: run: sidekiq: (pid 3934) 430s ok: run: unicorn: (pid 3862) 431s [root@localhost ~]# gitlab-ctl restart // Restart the gitlab service [root@localhost ~]# free -m // Check the running memory [root@localhost ~]# Firefox gitlab.bdqn.cn // To view the Gitlab page, or use the IP address [root@localhost ~]# Firefox 192.168.1.21Copy the code

Problems with gitLab pages; Check whether ports 80 and 8080 are occupied. When accessing the home page 502, check whether port 8080 is occupied

Gitlab - CTL start // start gitlab service gitlab- CTL stop // Stop gitlab service gitlab- CTL start unicorn (add component name Gitlab -ctl tail // Check gitlab running status. Gitlab -ctl reconfigure // Recompile the configuration file after modification. Gitlab -ctl tail // Check Gitlab logsCopy the code

Configure the GitLab mail service

Sendmail/Postfix/SMTP Old mail Box Online mail box of the mail service server

Procedure For configuring the SMTP mailbox

[root@localhost ~]# vim /etc/gitlab/gitlab.rb gitlab_rails['gitlab_email_from'] = '[email protected]' // Specify where to send email, # CTRL +v enter visual block +x gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.163.com Gitlab_rails ['smtp_port'] = 25 Gitlab_rails ['smtp_user_name'] = "[email protected]" // Set POP3/SMTP/IMAP client authentication password. // Set POP3/SMTP/IMAP client authentication password. Gitlab_rails ['smtp_authentication'] = "163.com" gitlab_rails['smtp_authentication'] = "login" Check whether the authorization code gitlab_rails[' smtp_ENABle_starttls_auto '] = true // Encryption mode Gitlab_rails [' smtp_TLS '] = false // Encryption mode User ['git_user_email'] = "[email protected]" ### Recompile the configuration file [root@localhost ~]# gitlab- CTL reconfigure Restart the Gitlab service [root@localhost ~]# gitlab-ctl restart Enter the console [root@localhost ~]# gitlab-rails console ------------------------------------------------------------------------------------- GitLab: 11.7.5 (c5B5b18) GitLab Shell 8.4.4 PostgresQL: 9.6.11 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Loading production Environment (Rails 5.0.7.1) irb(main):001:0> Notify. Test_email ('[email protected]','yangxiaofeiNB','hello,world! ').deliver_now // send the message, deliver_now means send immediately (format: recipient's email address, subject line, message content) IRB (main):003:0> exit // Exit the consoleCopy the code

Daily operations of GitLab

Gitlab backup [root@localhost ~]# gitlab-rake gitlab:backup:create //gitlab backup: backup directory [root@localhost ~]# ls /var/opt/gitlab/backups/ 1550541218_2019_02_19_11.7.5_gitlab_backup.tar // A tar package is generated after backup. File format: Timestamp, current date, current GitLab version, backup packageCopy the code

[root@localhost ~]# gitlab-ctl stop sidekiq OK: down: sidekiq: 0s, normally up [root@localhost ~]# gitlab-ctl stop unicorn ok: down: unicorn: 0s, Normally up Switch to the backup directory [root@localhost ~]# CD /var/opt/gitlab/backups/ [root@localhost backups]# ls 1550541218_2019_02_19_11.7.5_gitlab_backup.tar [root@localhost backups]# gitlab-rake gitlab:backup:restore BACKUP=1550541218_2019_02_19_11.7.5 Do you want to continue (yes/no)? yes Do you want to continue (yes/no)? Yes [root@localhost backups]# gitlab-ctl start sidekiq ok: run: sidekiq: (pid 19474) 0s [root@localhost backups]# gitlab- CTL start unicorn // Ok: run: unicorn: (pid 19536) 1s data recovery is completeCopy the code

Visit the GitLab Web page

Gitlab.bdqn.com or http://localhost

Two ways to access the console

[root@localhost ~]# gitlab- Rails console ------------------------------------------------------------------------------------- GitLab: 11.7.5 (c5B5b18) GitLab Shell 8.4.4 PostgresQL: 9.6.11 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Loading production Irb (main):001:0> 2, [root@localhost ~]# gitlab- Rails console production ------------------------------------------------------------------------------------- GitLab: 11.7.5 (c5B5b18) GitLab Shell 8.4.4 PostgresQL: 9.6.11 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Loading production The environment (Rails 5.0.7.1) irb (main) : 001-0 >Copy the code

The root password is changed. Procedure

[root@localhost ~]# gitlab-rails console production ------------------------------------------------------------------------------------- GitLab: 11.7.5 (c5B5b18) GitLab Shell 8.4.4 PostgresQL: 9.6.11 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Loading production Environment (Rails 5.0.7.1) irb(main):001:0> user = user. where(id:1).first Irb (main):003:0> user.password='1234.com' // change the password in the irb(main):003:0> user.save! Enqueued ActionMailer::DeliveryJob (Job ID: 7661b452-fcb4-48a0-b9f0-35995ba21258) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", # < GlobalID: 0 x00007f4360748a10 @ uri = # < uri: : GID GID: / / gitlab/User / 1 > > = > true irb (main) : 004:0 > exit and modifications are successful, Login test using Web ## The change is completeCopy the code

View GitLab logs

[root@localhost ~]# gitlab-ctl tail // View the overall log View component related logs [root@localhost ~]# gitlab-ctl tail redis // View redis logs [root@localhost ~]# gitlab-ctl tail logrotateCopy the code

Upload files to GitLab over SSH remote connection

[root@localhost ~]# ssh-keygen -t rsa -c "[email protected]" // Is the email address [root@localhost. SSH]# PWD /root/.ssh [root@localhost .ssh]# ls id_rsa id_rsa.pub [root@localhost .ssh]# cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDG+woCe7UsBcXhU/I5hRZ0B7fzOOzzGsYzm1+qSvxn1SRaWQ53TNfWJJKpmamodHDI0IWHld6MI+2IB5bSXobNjrV1 W147m34fE3KZZ4Kx9wwQ89UnUzqREIPDHnTLozHOE36AxGh6pREFawMjxJJjzd6d3xC9PM9bQ3KaY80agGY44N1vO6c+Turfkpyre3fyITudEqPlrCibJF9e ikXgFhHNtrrWVAII6LUKU89LNfXKKYfOmXvB+T+ZYODkXqPR5GPCz4IIuGd5fxpfAmnTvm+Sz3Dp5APVSmveEx9ivtRVsb5lqlYoXJT1vL+D9dQKFY7HI8/F TtOSduQNLfrv [email protected] Copy the key, Go to The web page to add a key to verify The remote login. [root@localhost. SSH]# ssh-t [email protected] The authenticity of host 'gitlab.bdqn.cn (192.168.1.21) 'can' t be established. The ECDSA key fingerprint is SHA256:88 ixrb6xhdt9svsq3n78nqbfzpplw8kznkqluldud6w ECDSA  key fingerprint is MD5:3e:34:68:db:3a:f6:5c:a5:de:18:9b:1c:cc:ef:f9:ff. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'gitlab. BDQN. Cn, 192.168.1.21' (ECDSA) to the list of known hosts. Welcome to gitlab, @ root!Copy the code

Clone the project and upload it

[root@localhost ~]# yum install -y git // [root@localhost ~]# git config --global user.name "zhangsan" [root@localhost ~]# git config --global The user. The email "[email protected]"/root @ localhost ~ # git clone [email protected]: ios/ios. Git / / cloning project libraries Is cloning to 'ios'... Warning: You appear to have cloned an empty repository. [root@localhost ~]# ls // generate a directory, [root@localhost ~]# CD ios initial-setup-ks. CFG # CD ios initial-setup-ks. CFG # CD ios initial-setup-ks. CFG # CD ios initial-setup-ks. CFG [root@localhost ~]# echo 111 > readme.md // Enter the content [root@localhost ios]# git [root@localhost ios]# git commit -m "test111" [master (root) ad3C913] test111 1 file changed, 1 insertion(+) create mode 100644 readme.md [root@localhost ios]# git push origin master Add Counting objects: 3, done. Writing objects: 100% (3/3), 209 bytes | 0 bytes/s, done. Total 3 (delta 0), Reused zero (0) delta To [email protected]: ios/ios git * [new branch] master - > master into a web page can see the project cloning project [root@localhost ~]# mkdir test [root@localhost ~]# cd test/ [root@localhost test]# git clone [email protected]: ios/ios. The git is clone to 'ios'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 in flue (delta 0), reused 0 (delta 0) 100% (3/3), done. [root@localhost test]# ls ios [root@localhost test]# cd ios/ [root@localhost ios]# ls README.mdCopy the code

Recommended reading

99% of Linux operation and maintenance engineers must master the command and use

Common commands of the Oracle database in Linux

Common commands of the vi/vim editor in Linux

Install and manage programs in Linux (basic process of package encapsulation, RPM command, source code compilation and installation)

Manage accounts and rights in Linux

Linux disk and file system management

Process and scheduled task management in Linux

Analyze and rectify system faults in Linux

Common KVM commands in Linux

Easily take you to play with the Linux environment under the date syntax!

Exciting 10 command line games that anyone can play with just 2 commands!

17 Funny, but useless, Linux Easter Eggs. It’s the ultimate fun!

Yum warehouse configuration and use, really sweet ah!

Linux graphical terminal screenshot and shortcut key practical tips!

In this paper, to the end.


Original is not easy, if you think this article is a little useful to you, please give me a like, comment or forward for this article, because this will be my power to output more quality articles, thanks!

By the way, dig friends remember to give me a free attention yo! In case you get lost and you can’t find me next time.

See you next time!