How To Install GitLab Server In Linux
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed environment variables in .gitlab-ci.yml.
https://cloudaffaire.com/gitlab-ci-yml-part-ten-basics-of-environment-variables/
So far we have focused on the development aspects of GitLab using a free account provided by GitLab.com. Next, we will cover some basics of GitLab server administration. Instead of using GitLab.com provided GitLab server, you can install your own GitLab server. In this blog post, we will discuss how to install GitLab server in a Linux system.
GitLab Components:
A typical install of GitLab will be on GNU/Linux. It uses NGINX or Apache as a web front end to proxypass the Unicorn web server. By default, communication between Unicorn and the front end is via a Unix domain socket but forwarding requests via TCP is also supported. The web front end accesses /home/git/gitlab/public bypassing the Unicorn server to serve static pages, uploads (e.g. avatar images or attachments), and precompiled assets. GitLab serves web pages and the GitLab API using the Unicorn web server. It uses Sidekiq as a job queue which, in turn, uses Redis as a non-persistent database backend for job information, meta data, and incoming jobs.
The GitLab web app uses PostgreSQL for persistent database information (e.g. users, permissions, issues, other meta data). GitLab stores the bare Git repositories it serves in /home/git/repositories by default. It also keeps default branch and hook information with the bare repository. When serving repositories over HTTP/HTTPS GitLab utilizes the GitLab API to resolve authorization and access as well as serving Git objects.
The add-on component GitLab Shell serves repositories over SSH. It manages the SSH keys within /home/git/.ssh/authorized_keys which should not be manually edited. GitLab Shell accesses the bare repositories through Gitaly to serve Git objects and communicates with Redis to submit jobs to Sidekiq for GitLab to process. GitLab Shell queries the GitLab API to determine authorization and access.
Gitaly executes Git operations from GitLab Shell and the GitLab web app, and provides an API to the GitLab web app to get attributes from Git (e.g. title, branches, tags, other meta data), and to get blobs (e.g. diffs, commits, files).
Below is the list of all components of GitLab:
- NGINX: Webserver to routes requests to appropriate components, terminates SSL.
- Unicorn (GitLab Rails): Handles requests for the web interface and API.
- Sidekiq: Background jobs processor.
- Gitaly: Git RPC service for handling all Git calls made by GitLab.
- Praefect: A transparent proxy between any Git client and Gitaly storage nodes.
- GitLab Workhorse: Smart reverse proxy, handles large HTTP requests.
- GitLab Shell: Handles git over SSH sessions.
- GitLab Pages: Hosts static websites.
- Registry: Container registry, allows pushing and pulling of images.
- Redis: Caching service.
- PostgreSQL: Database for persistent database information (e.g. users, permissions, issues, other meta data).
- PgBouncer: Database connection pooling, failover.
- Consul: Database node discovery, failover.
- GitLab self-monitoring: Prometheus: Time-series database, metrics collection, and query service.
- GitLab self-monitoring: Alertmanager: Deduplicates, groups, and routes alerts from Prometheus.
- GitLab self-monitoring: Grafana: Metrics dashboard.
- GitLab self-monitoring: Sentry: Track errors generated by the GitLab instance.
- GitLab self-monitoring: Jaeger: View traces generated by the GitLab instance.
- Redis Exporter: Prometheus endpoint with Redis metrics.
- PostgreSQL Exporter: Prometheus endpoint with PostgreSQL metrics.
- PgBouncer Exporter: Prometheus endpoint with PgBouncer metrics.
- GitLab Exporter: Generates a variety of GitLab metrics.
- Node Exporter: Prometheus endpoint with system metrics.
- Mattermost: Open-source Slack alternative.
- MinIO: Object storage service.
- Runner: Executes GitLab CI jobs.
- Database Migrations: Database migrations.
- Certificate Management: TLS Settings, Let’s Encrypt.
- GitLab Geo Node: Geographically distributed GitLab nodes.
- LDAP Authentication: Authenticate users against centralized LDAP directory.
- Outbound email (SMTP): Send email messages to users.
- Inbound email (SMTP): Receive messages to update issues.
- Elasticsearch: Improved search within GitLab.
- Sentry integration: Error tracking for deployed apps.
- Jaeger integration: Distributed tracing for deployed apps.
Note: A typical GitLab install does not include all the above components.
How To Install GitLab Server In Linux?
Step 1: Install GitLab server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
#################################### ## How To Install GitLab In Linux ## #################################### ## Prerequisites: ## One Linux VM with internet access ## CPU: Atleast 2 core ## RAM: Atleast 4 GB ## IP: 192.168.0.10 (used in this demo, you can use any private ip) ## OS: CentOS7 | Ubuntu ## ------- ## CentOS7 ## ------- ## Install and configure the necessary dependencies sudo yum install -y curl policycoreutils-python openssh-server sudo systemctl enable sshd sudo systemctl start sshd ## Open HTTP, HTTPS and SSH access in the system firewall sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo systemctl reload firewalld ## Install Postfix to send notification emails sudo yum install postfix sudo systemctl enable postfix sudo systemctl start postfix ## Add the GitLab package repository and install the package curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash ## Install the GitLab package. Change 192.168.0.10 to the URL/IP at which you want to access your GitLab instance sudo EXTERNAL_URL="192.168.0.10" yum install -y gitlab-ee ## Check if all services running properly sudo gitlab-ctl status ## Check the GitLab configuration file sudo cat /etc/gitlab/gitlab.rb ## ------ ## Ubuntu ## ------ ## Install and configure the necessary dependencies sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates ## Install Postfix to send notification emails sudo apt-get install -y postfix ## Add the GitLab package repository and install the package curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash ## Install the GitLab package. Change 192.168.0.10 to the URL/IP at which you want to access your GitLab instance sudo EXTERNAL_URL="192.168.0.10" apt-get install gitlab-ee ## Check if all services running properly sudo gitlab-ctl status ## Check the GitLab configuration file sudo cat /etc/gitlab/gitlab.rb |
Step 2: Log in to your GitLab Server. Open 192.168.0.10 in your favorite browser and set the root user password.
Our GitLab server has been successfully installed.
Hope you enjoyed this article. In the next blog post, we will discuss the GitLab Server Configuration.
To get more details on GitLab you can follow the below link.
https://docs.gitlab.com/ee/README.html
To Get more details on Git you can follow the below links.
https://cloudaffaire.com/category/devops/git/