2020年 · 点滴记录

搭建gitlab仓库

搭建公司内部的gitlab,查了些资料整理记录下

【一】首选官方安装方式:https://about.gitlab.com/install/

1.安装和配置必要的依赖项

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates

接下来,安装Postfix以发送通知电子邮件。如果要使用其他解决方案发送电子邮件,请跳过此步骤, 并在安装GitLab之后配置外部SMTP服务器

sudo apt-get install -y postfix

在安装Postfix的过程中,可能会出现一个配置屏幕。选择“ Internet网站”,然后按Enter。使用服务器的外部DNS作为“邮件名”,然后按Enter。如果出现其他屏幕,请继续按Enter接受默认设置。

2.添加GitLab软件包存储库并安装软件包

添加GitLab软件包存储库。

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash

接下来,安装GitLab软件包。更改https://gitlab.example.com为您要访问GitLab实例的URL。安装将自动配置并在该URL上启动GitLab。
对于https://URL,GitLab将使用Let’s Encrypt自动请求证书,这需要入站HTTP访问和有效的主机名。您也可以使用自己的证书或仅使用http://。

sudo EXTERNAL_URL=”https://gitlab.example.com” apt-get install gitlab-ee

3.浏览到主机名并登录

首次访问时,您将被重定向到密码重置屏幕。提供初始管理员帐户的密码,您将被重定向回登录屏幕。使用默认帐户的用户名root登录。

【二】获取安装包安装,获取安装包地址:https://packages.gitlab.com/gitlab
此处安装系统版本:
# lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
root@localhost:~#dpkg -i gitlab-ce_12.5.7-ce.0_amd64.deb   #开始安装会有很长的信息打印出来
……
* service[postgres-exporter] action restart
– restart service service[postgres-exporter]
* service[grafana] action restart
– restart service service[grafana]

Running handlers:
Running handlers complete
Chef Client finished, 546/1454 resources updated in 04 minutes 58 seconds
gitlab Reconfigured!         #安装完成显示内容
root@localhost:~#gitlab-ctl reconfigure
root@localhost:~#gitlab-ctl start
ok: run: alertmanager: (pid 6376) 0s
ok: run: gitaly: (pid 6378) 1s
ok: run: gitlab-exporter: (pid 6401) 0s
ok: run: gitlab-workhorse: (pid 6405) 1s
ok: run: grafana: (pid 6412) 0s
ok: run: logrotate: (pid 6424) 0s
ok: run: nginx: (pid 6435) 1s
ok: run: node-exporter: (pid 6440) 0s
ok: run: postgres-exporter: (pid 6444) 1s
ok: run: postgresql: (pid 6449) 0s
ok: run: prometheus: (pid 6458) 1s
ok: run: redis: (pid 6465) 0s
ok: run: redis-exporter: (pid 6469) 1s
ok: run: sidekiq: (pid 6475) 0s
ok: run: unicorn: (pid 6482) 1s
root@localhost:~#gitlab-ctl status
run: alertmanager: (pid 6376) 152s; run: log: (pid 25009) 7301s
run: gitaly: (pid 6378) 152s; run: log: (pid 24513) 7428s
run: gitlab-exporter: (pid 6401) 151s; run: log: (pid 24948) 7318s
run: gitlab-workhorse: (pid 6405) 151s; run: log: (pid 24856) 7345s
run: grafana: (pid 6412) 150s; run: log: (pid 25264) 7190s
run: logrotate: (pid 6424) 150s; run: log: (pid 24897) 7333s
run: nginx: (pid 6435) 150s; run: log: (pid 24881) 7339s
run: node-exporter: (pid 6440) 149s; run: log: (pid 24927) 7327s
run: postgres-exporter: (pid 6444) 149s; run: log: (pid 25052) 7292s
run: postgresql: (pid 6449) 148s; run: log: (pid 24642) 7416s
run: prometheus: (pid 6458) 148s; run: log: (pid 24992) 7305s
run: redis: (pid 6465) 147s; run: log: (pid 24476) 7434s
run: redis-exporter: (pid 6469) 147s; run: log: (pid 24965) 7311s
run: sidekiq: (pid 6475) 146s; run: log: (pid 24839) 7351s
run: unicorn: (pid 6482) 146s; run: log: (pid 24820) 7355s
安装完成后访问如下图所示:

登录后(用户为root管理员):