GitLab部署实战案例
GitLab部署实战案例
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.查看官方文档
1>.查看GitLab服务的安装文档
本篇博客使用Ubuntu最新的长期支持版"Ubuntu Server 18.04.4 LTS"部署GitLab,其它版本可参考官方文档,如下图所示。 博主推荐阅读: https://about.gitlab.com/install/
2>.查看部署GitLib的环境要求
博主推荐阅读: https://docs.gitlab.com/ee/install/requirements.html#cpu
3>.安装包下载地址
博主推荐阅读: https://packages.gitlab.com/gitlab/gitlab-ce
4>.下载GitLab软件包到本地
5>.将GitLab软件包上传到Ubuntu操作系统上
二.Ubuntu系统上部署GitLab
1>.将Ubuntu默认的软件源换为国内的软件源(这样下载速度会更快,国内比较知名的软件源有很多,比如阿里源,清华源等)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
[root@gitlab201.yinzhengjie.org.cn ~]# free -h total used free shared buff/cache available Mem: 7.8G 193M 7.3G 1.4M 257M 7.3G Swap: 3.8G 0B 3.8G [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# uname -r 4.15.0-55-generic [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# uname -m x86_64 [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# cat /etc/issue Ubuntu 18.04.3 LTS \n \l [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# lscpu | grep "^CPU(s)" CPU(s): 2 [root@gitlab201.yinzhengjie.org.cn ~]#
[root@gitlab201.yinzhengjie.org.cn ~]# vim /etc/apt/sources.list [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# cat /etc/apt/sources.list deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse [root@gitlab201.yinzhengjie.org.cn ~]#
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
[root@gitlab201.yinzhengjie.org.cn ~]# apt update Get:1 http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB] Get:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB] Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB] Get:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB] Get:5 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [74.6 kB] Get:6 http://mirrors.aliyun.com/ubuntu bionic/main Sources [829 kB] Get:7 http://mirrors.aliyun.com/ubuntu bionic/multiverse Sources [181 kB] Get:8 http://mirrors.aliyun.com/ubuntu bionic/restricted Sources [5,324 B] Get:9 http://mirrors.aliyun.com/ubuntu bionic/universe Sources [9,051 kB] Get:10 http://mirrors.aliyun.com/ubuntu bionic/main amd64 Packages [1,019 kB] Get:11 http://mirrors.aliyun.com/ubuntu bionic/main Translation-en [516 kB] Get:12 http://mirrors.aliyun.com/ubuntu bionic/restricted amd64 Packages [9,184 B] Get:13 http://mirrors.aliyun.com/ubuntu bionic/restricted Translation-en [3,584 B] Get:14 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 Packages [8,570 kB] Get:15 http://mirrors.aliyun.com/ubuntu bionic/universe Translation-en [4,941 kB] Get:16 http://mirrors.aliyun.com/ubuntu bionic/multiverse amd64 Packages [151 kB] Get:17 http://mirrors.aliyun.com/ubuntu bionic/multiverse Translation-en [108 kB] Get:18 http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Sources [3,180 B] Get:19 http://mirrors.aliyun.com/ubuntu bionic-security/restricted Sources [4,548 B] Get:20 http://mirrors.aliyun.com/ubuntu bionic-security/main Sources [143 kB] Get:21 http://mirrors.aliyun.com/ubuntu bionic-security/universe Sources [167 kB] Get:22 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 Packages [651 kB] Get:23 http://mirrors.aliyun.com/ubuntu bionic-security/main Translation-en [211 kB] Get:24 http://mirrors.aliyun.com/ubuntu bionic-security/restricted amd64 Packages [23.8 kB] Get:25 http://mirrors.aliyun.com/ubuntu bionic-security/restricted Translation-en [6,528 B] Get:26 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 Packages [648 kB] Get:27 http://mirrors.aliyun.com/ubuntu bionic-security/universe Translation-en [215 kB] Get:28 http://mirrors.aliyun.com/ubuntu bionic-security/multiverse amd64 Packages [6,756 B] Get:29 http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Translation-en [2,700 B] Get:30 http://mirrors.aliyun.com/ubuntu bionic-updates/main Sources [311 kB] Get:31 http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Sources [6,536 B] Get:32 http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Sources [5,840 B] Get:33 http://mirrors.aliyun.com/ubuntu bionic-updates/universe Sources [278 kB] Get:34 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages [872 kB] Get:35 http://mirrors.aliyun.com/ubuntu bionic-updates/main Translation-en [303 kB] Get:36 http://mirrors.aliyun.com/ubuntu bionic-updates/restricted amd64 Packages [32.9 kB] Get:37 http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Translation-en [8,468 B] Get:38 http://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 Packages [1,055 kB] Get:39 http://mirrors.aliyun.com/ubuntu bionic-updates/universe Translation-en [326 kB] Get:40 http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse amd64 Packages [10.1 kB] Get:41 http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Translation-en [4,636 B] Get:42 http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Sources [1,796 B] Get:43 http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Sources [5,596 B] Get:44 http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Sources [19.4 kB] Get:45 http://mirrors.aliyun.com/ubuntu bionic-proposed/main Sources [68.7 kB] Get:46 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 Packages [115 kB] Ign:47 http://mirrors.aliyun.com/ubuntu bionic-proposed/main Translation-en Get:48 http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted amd64 Packages [16.1 kB] Get:49 http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Translation-en [5,576 B] Get:50 http://mirrors.aliyun.com/ubuntu bionic-proposed/universe amd64 Packages [145 kB] Ign:51 http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Translation-en Get:52 http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse amd64 Packages [7,596 B] Get:53 http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Translation-en [2,836 B] Get:54 http://mirrors.aliyun.com/ubuntu bionic-backports/universe Sources [2,496 B] Get:55 http://mirrors.aliyun.com/ubuntu bionic-backports/main Sources [2,532 B] Get:56 http://mirrors.aliyun.com/ubuntu bionic-backports/main amd64 Packages [2,512 B] Get:57 http://mirrors.aliyun.com/ubuntu bionic-backports/main Translation-en [1,644 B] Get:58 http://mirrors.aliyun.com/ubuntu bionic-backports/universe amd64 Packages [4,028 B] Get:59 http://mirrors.aliyun.com/ubuntu bionic-backports/universe Translation-en [1,900 B] Get:47 http://mirrors.aliyun.com/ubuntu bionic-proposed/main Translation-en [42.3 kB] Get:51 http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Translation-en [31.2 kB] Fetched 31.9 MB in 8s (4,021 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 137 packages can be upgraded. Run 'apt list --upgradable' to see them. [root@gitlab201.yinzhengjie.org.cn ~]#
2>.查看GitLab软件包会帮咱们安装哪些文件
[root@gitlab201.yinzhengjie.org.cn ~]# ll /yinzhengjie/download/ total 734204 drwxr-xr-x 2 root root 45 Mar 13 01:33 ./ drwxr-xr-x 4 root root 39 Mar 13 01:31 ../ -rw-r--r-- 1 root root 751821442 Mar 13 01:33 gitlab-ce_12.8.6-ce.0_amd64.deb [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# dpkg -c /yinzhengjie/download/gitlab-ce_12.8.6-ce.0_amd64.deb | wc -l #我大致统计了一下啊,带盖需要安装7w+文件哟~ 70863 [root@gitlab201.yinzhengjie.org.cn ~]#
3>.安装GitLab软件包
[root@gitlab201.yinzhengjie.org.cn ~]# ll /yinzhengjie/download/ total 734204 drwxr-xr-x 2 root root 45 Mar 13 01:33 ./ drwxr-xr-x 4 root root 39 Mar 13 01:31 ../ -rw-r--r-- 1 root root 751821442 Mar 13 01:33 gitlab-ce_12.8.6-ce.0_amd64.deb [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# dpkg -i /yinzhengjie/download/gitlab-ce_12.8.6-ce.0_amd64.deb #我们开始安装GitLab,安装完成后请点击保存按钮。
4>.GitLab安装成功
5>.修改GitLab的配置文件并使之生效
[root@gitlab201.yinzhengjie.org.cn ~]# vim /etc/gitlab/gitlab.rb [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# grep "^[a-Z]" /etc/gitlab/gitlab.rb external_url 'http://gitlab201.yinzhengjie.org.cn' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_prort'] = 465 gitlab_rails['smtp_user_name'] = "y1053419035@qq.com" gitlab_rails['smtp_password'] = "授权码" #注意哈,这里的授权码可以参考下面的链接如何获取。 gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = :login gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = "y1053419035@qq.com" user['git_user_email'] = "y1053419035@qq.com" [root@gitlab201.yinzhengjie.org.cn ~]# [root@gitlab201.yinzhengjie.org.cn ~]# gitlab-ctl reconfigure #如下图所示,等待gitlab重新配置完成即可~ 博主推荐阅读: https://www.cnblogs.com/yinzhengjie2020/p/12355157.html
6>.GitLab配置完成
GitLab配置完成之后,使用浏览器第一次访问80端口时会自动跳转到如下图所示的界面: http://gitlab201.yinzhengjie.org.cn/
7>.使用默认的管理员root用户登录GitLab,如下图所示
8>.GitLab登录成功
三.GitLab的基础使用
1>.创建用户
博主推荐阅读: https://www.cnblogs.com/yinzhengjie2020/p/12439667.html
2>.创建项目组
3>.
4>.
5>.
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。 欢迎加入基础架构自动化运维:598432640,大数据SRE进阶之路:959042252,DevOps进阶之路:526991186