Gitlab搭建与使用第一篇

Gitlab算是目前最流行的一款开源代码管理工具了,由众多组件构成,包括吉塔,postgresql,复述,独角兽,nginx等,可见其复杂性(可从Gitlab官网了解相关信息)。也因此服务器的硬件配置不能太低,当前我们生产用的云主机是1台c5.2xlarge(8个vcpu, 16 g)的实例(官方软硬件要求:https://docs.gitlab.com/ce/install/requirements.html),使用起来勉强可以。

Gitlab在CentOs7.x上安装也仅是一个rpm包,所以安装非常简单。而原来在CentOs6.x上安装Gitlab - ce - 8. x时对Git的客户端版本还有要求(perl-Git, Git版本在1.7.9.6及以上)。

我这里选用目前最新版本12.5.2的rpm包来演示,在这里吐槽一下,Gitlab版本更新实在太频繁了,我完全跟不上步伐。

使用清华的下载源:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.5.2-ce.0.el7.x86_64.rpm

如果想知道在使用的Gitlab版本相关特性以及虫修复,可关注Gitlab的博客:https://about.gitlab.com/blog/categories/releases/

一、环境说明:

为了搭建Gitlab,并实现邮件通知功能,我在Gitlab服务器上同时配置了后缀+鸽舍

域名:demo.com

用于测试的邮箱有:noreply@demo.com; admin@demo.com; firefly@demo.com

IP: 192.168.59.250

主机文件内容如下:

[root@mail家里]#猫localhost/etc/hosts
本地主机127.0.0.1。localdomain localhost4 localhost4。localdomain4
192.168.59.250 mail.demo.com邮件demo.com
192.168.59.250流行
192.168.59.250 gitlab.demo.com
192.168.59.250 jenkins.demo.com

主机名配置如下:
[root@mail家里]#猫/etc/hostname mail.demo.com

二、安装配置

1,开始安装
[root@mail ~] # rpm -ivh gitlab-ce-12.5.2-ce.0.el7.x86_64。rpm
使用rpm包安装完成后,会提示Gitlab尚未配置,可通过修改/etc/Gitlab/Gitlab。rb文件来设置external_url,然后执行命令gitlab-ctl重新配置来启动Gitlab实例。

2,修改配置文件/etc/Gitlab/Gitlab。rb
#猫/etc/gitlab/gitlab. root@mail回家rb | grep - v”^ # | grep - v
“^ $ #配置一个用于外部访问url
external_url ' http://gitlab.demo.com '
#开启邮件通知功能
gitlab_rails [' gitlab_email_enabled ']=true
gitlab_rails [' gitlab_email_from ']=皀oreply@demo.com”
gitlab_rails [' gitlab_email_display_name ']=皀oreply”
gitlab_rails [' gitlab_email_reply_to ']=皀oreply@demo.com”
# git仓库备份路径
gitlab_rails [' backup_path ']="/数据/git-data/备份”
#备份保留周期,默认是7天,过期将被删除
gitlab_rails [' backup_keep_time ']=604800
# git仓库数据默认存放路径
git_data_dirs ({
“默认”=比;{
“路径”=比;“/数据/git-data”
}
})
# smtp邮箱设置,用于发送邮件给到各个git账户
gitlab_rails [' smtp_enable ']=true
gitlab_rails [' smtp_address ']=" mail.demo.com "
gitlab_rails [' smtp_port ']=25
gitlab_rails [' smtp_user_name ']=皀oreply@demo.com”
gitlab_rails [' smtp_password ']=皀oreply”
gitlab_rails [' smtp_domain ']=" demo.com "
gitlab_rails [' smtp_authentication ']=暗锹肌?br/> - - - - - - - - - - - - - - - - - - - - - - -配置结束分割线- - - - - - - - - - - - - - - - - - - - - - -

3,启动服务。完成上述配置后即可执行命令gitlab-ctl重新配置即可完成初始化配置并启动相关服务

[root@mail ~] # gitlab-ctl重新配置
[root@mail ~] # gitlab-ctl
运行现状:alertmanager: 20578 (pid) 2681年代;运行日志:20577 (pid) 2681年代
运行:吉塔:20545 (pid) 2681年代;运行日志:20544 (pid) 2681年代
运行:gitlab-exporter: 20569 (pid) 2681年代;运行日志:20568 (pid) 2681年代
运行:gitlab-workhorse: 20551 (pid) 2681年代;运行日志:20550 (pid) 2681年代
运行:grafana: 20576 (pid) 2681年代;运行日志:20575 (pid) 2681年代
运行:logrotate: 20560 (pid) 2681年代;运行日志:20559 (pid) 2681年代
:运行nginx: 20557 (pid) 2681年代;运行日志:20556 (pid) 2681年代
运行:node-exporter: 20566 (pid) 2681年代;运行日志:20565 (pid) 2681年代
运行:postgres-exporter: 20580 (pid) 2681年代;运行日志:20579 (pid) 2681年代
运行:postgresql: 20549 (pid) 2681年代;运行日志:20543 (pid) 2681年代
运行:普罗米修斯:20582 (pid) 2681年代;运行日志:20581 (pid) 2681年代
运行:复述:20584 (pid) 2681年代;运行日志:20583 (pid) 2681年代
运行:redis-exporter: 20570 (pid) 2681年代;运行日志:20567 (pid) 2681年代
运行:sidekiq: 20553 (pid) 2682年代;运行日志:20552 (pid) 2682年代
运行:独角兽:20562 (pid) 2682年代;null

Gitlab搭建与使用第一篇