Ubuntu21.10 安装 gitlab

本文将介绍怎样在 Ubuntu21.10 系统下安装 gitlab。

第一步:更新软件源

hxstrive@course:~$ sudo apt update
[sudo] password for hxstrive: 
Hit:1 https://mirrors.aliyun.com/ubuntu focal InRelease            
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease      
Hit:3 https://mirrors.aliyun.com/ubuntu focal-security InRelease
Hit:4 https://mirrors.aliyun.com/ubuntu focal-updates InRelease
Hit:5 https://mirrors.aliyun.com/ubuntu focal-backports InRelease
Reading package lists... Done                        
Building dependency tree... Done
....

hxstrive@course:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
....

第二步:安装依赖包

hxstrive@course:~$ sudo apt install build-essential curl file git ca-certificates
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
file is already the newest version (1:5.39-3).
file set to manually installed.
....

第三步:下载GitLab软件包并安装

hxstrive@course:~$ wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/bionic/gitlab-ce_14.1.2-ce.0_amd64.deb/download.deb
sudo dpkg -i gitlab-ce_14.1.2-ce.0_amd64.deb
--2023-02-21 15:41:10--  https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/bionic/gitlab-ce_14.1.2-ce.0_amd64.deb/download.deb
Resolving packages.gitlab.com (packages.gitlab.com)... 104.18.20.224, 104.18.21.224, 2606:4700::6812:15e0, ...
Connecting to packages.gitlab.com (packages.gitlab.com)|104.18.20.224|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://d20rj4el6vkp4c.cloudfront.net/7/8/ubuntu/package_files/110770.deb?t=1676965573_49ab32f8b34ca9d8a7ecc15c5507370cede9a0e2 [following]
--2023-02-21 15:41:13--  https://d20rj4el6vkp4c.cloudfront.net/7/8/ubuntu/package_files/110770.deb?t=1676965573_49ab32f8b34ca9d8a7ecc15c5507370cede9a0e2
Resolving d20rj4el6vkp4c.cloudfront.net (d20rj4el6vkp4c.cloudfront.net)... 13.35.39.174, 13.35.39.134, 13.35.39.100, ...
Connecting to d20rj4el6vkp4c.cloudfront.net (d20rj4el6vkp4c.cloudfront.net)|13.35.39.174|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 909730422 (868M) [application/x-debian-package]
Saving to: ‘gitlab-ce_14.1.2-ce.0_amd64.deb’

gitlab-ce_14.1.2-ce.0_amd64.deb         100%[===============================================================================>] 867.59M  11.3MB/s    in 85s     

2023-02-21 15:42:39 (10.2 MB/s) - ‘gitlab-ce_14.1.2-ce.0_amd64.deb’ saved [909730422/909730422]

Selecting previously unselected package gitlab-ce.
(Reading database ... 184968 files and directories currently installed.)
Preparing to unpack gitlab-ce_14.1.2-ce.0_amd64.deb ...
Unpacking gitlab-ce (14.1.2-ce.0) ...
Setting up gitlab-ce (14.1.2-ce.0) ...
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-1

第四步:重新配置 gitlab

hxstrive@course:~$ sudo gitlab-ctl reconfigure
Starting Chef Infra Client, version 15.14.0
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - logrotate (0.1.0)
  - postgresql (0.1.0)
  - redis (0.1.0)
  - monitoring (0.1.0)
  - registry (0.1.0)
  - mattermost (0.1.0)
  - gitaly (0.1.0)
  - consul (0.1.0)
  - praefect (0.1.0)
  - gitlab-kas (0.1.0)
  - gitlab-pages (0.1.0)
  - letsencrypt (0.1.0)
  - nginx (0.1.0)
  - runit (5.1.3)
  - acme (4.1.3)
  - crond (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default
  * directory[/etc/gitlab] action create
    - change mode from '0755' to '0775'
....

第五步:启动 gitlab

hxstrive@course:~$ sudo gitlab-ctl start
ok: run: alertmanager: (pid 41358) 156s
ok: run: gitaly: (pid 41307) 158s
ok: run: gitlab-exporter: (pid 41289) 159s
ok: run: gitlab-workhorse: (pid 41272) 160s
ok: run: grafana: (pid 41374) 155s
ok: run: logrotate: (pid 40125) 480s
ok: run: nginx: (pid 40681) 366s
ok: run: node-exporter: (pid 41281) 160s
ok: run: postgres-exporter: (pid 41365) 155s
ok: run: postgresql: (pid 40375) 456s
ok: run: prometheus: (pid 41302) 158s
ok: run: puma: (pid 40599) 384s
ok: run: redis: (pid 40162) 473s
ok: run: redis-exporter: (pid 41291) 159s
ok: run: sidekiq: (pid 40618) 378s

第六步:查看 gitlab 状态

hxstrive@course:~$ sudo gitlab-ctl status
run: alertmanager: (pid 41358) 183s; run: log: (pid 40859) 353s
run: gitaly: (pid 41307) 185s; run: log: (pid 40217) 491s
run: gitlab-exporter: (pid 41289) 186s; run: log: (pid 40750) 376s
run: gitlab-workhorse: (pid 41272) 187s; run: log: (pid 40659) 397s
run: grafana: (pid 41374) 182s; run: log: (pid 41167) 229s
run: logrotate: (pid 40125) 507s; run: log: (pid 40134) 503s
run: nginx: (pid 40681) 393s; run: log: (pid 40691) 391s
run: node-exporter: (pid 41281) 187s; run: log: (pid 40735) 383s
run: postgres-exporter: (pid 41365) 182s; run: log: (pid 40879) 349s
run: postgresql: (pid 40375) 483s; run: log: (pid 40387) 479s
run: prometheus: (pid 41302) 185s; run: log: (pid 40828) 361s
run: puma: (pid 40599) 411s; run: log: (pid 40609) 409s
run: redis: (pid 40162) 500s; run: log: (pid 40178) 497s
run: redis-exporter: (pid 41291) 186s; run: log: (pid 40806) 366s
run: sidekiq: (pid 40618) 405s; run: log: (pid 40630) 403s

第七步:设置防火墙,开启对应的端口

# 开启 HTTPS
hxstrive@course:~$ sudo ufw allow https
Rules updated
Rules updated (v6)

# 开启 HTTP
hxstrive@course:~$ sudo ufw allow http
Rules updated
Rules updated (v6)

# 开启 SSH
hxstrive@course:~$ sudo ufw allow ssh
Rules updated
Rules updated (v6)

# 启动防火墙
hxstrive@course:~$ sudo ufw enable
Firewall is active and enabled on system startup

# 查看防火墙状态
hxstrive@course:~$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
443                        ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
22/tcp                     ALLOW       Anywhere                  
443 (v6)                   ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
22/tcp (v6)                ALLOW       Anywhere (v6)

第八步:访问 gitlab

使用浏览器访问 http://ip:80  ,例如:  http://192.168.116.134   ,如下图:

Ubuntu21.10 安装 gitlab

使用 gitlab 的 root 账号登录,可以使用 sudo cat /etc/gitlab/initial_root_password 命令查看默认密码,如下:

hxstrive@course:~$ sudo cat /etc/gitlab/initial_root_password
[sudo] password for hxstrive: 
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: tBmEwHjR5TeXPy3nYDLoejMohY8Lw9dyS963BeGneSI=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

上面“tBmEwHjR5TeXPy3nYDLoejMohY8Lw9dyS963BeGneSI=”就是默认密码。

天赋如同自然花木,要用学习来修剪。 —— 培根
0 不喜欢
说说我的看法 -
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号