GitLab安装部署

Git,GitHub,GitLab,这三个东东长得好像呀,都是个啥?

Git是Linus Torvalds(如果不知道这位大神是谁,请出门左转,慢走不送~)为了帮助管理Linux内核而开发的一个开放源代码的版本控制软件。

GitHub,又名全球最大同行交友软件(O(∩_∩)O哈哈~),是一个面向开源及私有项目的托管平台,因为仅仅支持Git作为唯一的版本库格式,故名GitHub。

GitLab是由GitLabInc.开发的,是基于MIT许可证的Git仓库管理工具,具有Wiki和Issue跟踪功能,目前有企业版和社区版两个分支,对于个人来说,社区版应该是完全够用的。

其实,简单来说,可以把GitLab看做是个个人版的GitHub,也就是说,可以在自己服务器上部署一套GitLab服务,该服务可以提供代码仓库托管等功能,用法与GibHub基本一致。

GitLab安装

  1. # 安装并配置必要的依赖
  2. [root@cos ~]# yum install -y curl policycoreutils-python openssh-server
  3. [root@cos ~]# systemctl enable sshd
  4. [root@cos ~]# systemctl start sshd
  5. # CentOS7系统中,在防火墙打开场景下,打开HTTP, HTTPS和SSH访问
  6. [root@cos ~]# firewall-cmd --permanent --add-service=http
  7. [root@cos ~]# firewall-cmd --permanent --add-service=https
  8. [root@cos ~]# systemctl reload firewalld
  9. # 安装Postfix,用来发送通知邮件
  10. [root@cos ~]# yum install postfix
  11. [root@cos ~]# systemctl enable postfix
  12. [root@cos ~]# systemctl start postfix

注意:为了避免下载失败导致GitLab安装失败,可以配置清华镜像,镜像配置操作如下

  1. # GitLab Community Edition镜像使用帮助
  2. # https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
  3. # 1. 新建/etc/yum.repos.d/gitlab-ce.repo, 内容如下
  4. [gitlab-ce]
  5. name=Gitlab CE Repository
  6. baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
  7. gpgcheck=0
  8. enabled=1

使用yum安装GitLab社区版

  1. # yum安装GitLab社区版
  2. [root@cos ~]# yum makecache
  3. [root@cos ~]# yum install gitlab-ce
  4. Loaded plugins: fastestmirror
  5. Loading mirror speeds from cached hostfile
  6. * base: mirrors.huaweicloud.com
  7. * epel: hkg.mirror.rackspace.com
  8. * extras: mirrors.huaweicloud.com
  9. * updates: mirrors.huaweicloud.com
  10. Resolving Dependencies
  11. --> Running transaction check
  12. ---> Package gitlab-ce.x86_64 0:12.9.1-ce.0.el7 will be installed
  13. --> Finished Dependency Resolution
  14. Dependencies Resolved
  15. =========================================================================================
  16. Package Arch Version Repository Size
  17. =========================================================================================
  18. Installing:
  19. gitlab-ce x86_64 12.9.1-ce.0.el7 gitlab-ce 721 M
  20. Transaction Summary
  21. =========================================================================================
  22. Install 1 Package
  23. Total download size: 721 M
  24. Installed size: 721 M
  25. Is this ok [y/d/N]: y
  26. Downloading packages:
  27. gitlab-ce-12.9.1-ce.0.el7.x86_64.rpm | 721 MB 00:01:49
  28. Running transaction check
  29. Running transaction test
  30. Transaction test succeeded
  31. Running transaction
  32. Installing : gitlab-ce-12.9.1-ce.0.el7.x86_64 1/1
  33. It looks like GitLab has not been configured yet; skipping the upgrade script.
  34. *. *.
  35. *** ***
  36. ***** *****
  37. .****** *******
  38. ******** ********
  39. ,,,,,,,,,***********,,,,,,,,,
  40. ,,,,,,,,,,,*********,,,,,,,,,,,
  41. .,,,,,,,,,,,*******,,,,,,,,,,,,
  42. ,,,,,,,,,*****,,,,,,,,,.
  43. ,,,,,,,****,,,,,,
  44. .,,,***,,,,
  45. ,*,.
  46. _______ __ __ __
  47. / ____(_) /_/ / ____ _/ /_
  48. / / __/ / __/ / / __ `/ __ \
  49. / /_/ / / /_/ /___/ /_/ / /_/ /
  50. \____/_/\__/_____/\__,_/_.___/
  51. Thank you for installing GitLab!
  52. GitLab was unable to detect a valid hostname for your instance.
  53. Please configure a URL for your GitLab instance by setting `external_url`
  54. configuration in /etc/gitlab/gitlab.rb file.
  55. Then, you can start your GitLab instance by running the following command:
  56. sudo gitlab-ctl reconfigure
  57. For a comprehensive list of configuration options please see the Omnibus GitLab readme
  58. https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
  59. GitLab now ships with a newer version of PostgreSQL (11.7), but it is not yet
  60. enabled by default. To upgrade, please see:
  61. https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server
  62. Verifying : gitlab-ce-12.9.1-ce.0.el7.x86_64 1/1
  63. Installed:
  64. gitlab-ce.x86_64 0:12.9.1-ce.0.el7
  65. Complete!

安装完成后,重点关注下面提示信息:

  1. GitLab was unable to detect a valid hostname for your instance.
  2. GitLab无法为你的GitLab检测到有效的主机名。
  3. Please configure a URL for your GitLab instance by setting `external_url`
  4. configuration in /etc/gitlab/gitlab.rb file.
  5. 请通过配置`external_url`为你的GitLab实例配置一个URL,该配置项在/etc/gitlab/gitlab.rb文件中。
  6. Then, you can start your GitLab instance by running the following command:
  7. sudo gitlab-ctl reconfigure
  8. 然后,通过运行sudo gitlab-ctl reconfigure启动你的GitLab实例

注意:配置完成后,需要使用sudo gitlab-ctl reconfigure命令重新配置并启动GitLab实例才行。

在GitLab安装完成后,首次登录时,需要配置GitLab管理员密码,如下图所示。

注意:管理员账号为root,管理员密码非常重要,是维护GitLab服务的重要账户,尽量不要搞忘了。

GitLab配置及内存优化

根据上面的安装步骤安装完成后后,启动GitLab实例后,你可能会想,这下可以愉快的与GitLab玩耍了吧、

砰,一大盆凉水浇过来、

GitLab是非常吃内存和服务器性能的,为了在自己主机或者虚拟机上正常启动和访问,需要进行下面配置和调优。

先看下官方给出的推荐CPU,内存配置:

GitLab推荐至少2核CPU,只有1核的话,可能会导致GitLab服务卡死,无法正常对外服务。

由上可知,内存配置主要影响GitLab服务的并发用户数量,对于自己使用来说,感觉2GB完全够用了。

GitLab配置文件路径:/etc/gitlab/gitlab.rb。下面对GitLab关键配置进行修改:

  1. ## GitLab URL
  2. ##! URL on which GitLab will be reachable.
  3. ##! 用户访问GitLab的URL地址
  4. external_url 'http://cos'
  5. ###! Minimum worker_processes is 2 at this moment
  6. ###! GitLab默认开启进程数为CPU核数+1,可以提高服务器的相应时间,太吃内存
  7. ###! GitLab的最小工作进程,该参数最小值为2,设为1可能导致服务器卡死
  8. unicorn['worker_processes'] = 2
  9. ### **Only change these settings if you understand well what they mean**
  10. ###! 工程进程的内存限制,默认最小为400MB,最大为650MB
  11. unicorn['worker_memory_limit_min'] = "200 * 1 << 20"
  12. unicorn['worker_memory_limit_max'] = "300 * 1 << 20"
  13. # sidekiq并发数默认值为25
  14. sidekiq['concurrency'] = 5
  15. ###! Changing any of these settings requires a restart of postgresql.
  16. ###! By default, reconfigure reloads postgresql if it is running. If you
  17. ###! change any of these settings, be sure to run `gitlab-ctl restart postgresql`
  18. ###! after reconfigure in order for the changes to take effect.
  19. ##! **recommend value is 1/4 of total RAM, up to 14GB.**
  20. ##! 数据库缓存,默认值为256MB
  21. ##!推荐值为1/4的RAM大小,按推荐值肯定崩了
  22. postgresql['shared_buffers'] = "128MB"
  23. ##! 数据库并发数
  24. postgresql['max_worker_processes'] = 4

GitLab启动

GitLab安装配置完成后,我们可以通过gitlab-ctl start命令启动,gitlab-ctl stop命令停止GitLab服务。

  1. # 查看GitLab服务状态
  2. [root@cos ~]# gitlab-ctl status
  3. run: gitaly: (pid 2202) 830s; run: log: (pid 2201) 830s
  4. run: gitlab-workhorse: (pid 2212) 830s; run: log: (pid 2211) 830s
  5. run: logrotate: (pid 2217) 830s; run: log: (pid 2214) 830s
  6. run: nginx: (pid 2198) 830s; run: log: (pid 2197) 830s
  7. run: postgresql: (pid 2204) 830s; run: log: (pid 2203) 830s
  8. run: redis: (pid 2213) 830s; run: log: (pid 2210) 830s
  9. run: sidekiq: (pid 2195) 830s; run: log: (pid 2193) 830s
  10. run: unicorn: (pid 2196) 830s; run: log: (pid 2194) 830s

GitLab服务启动后,我们可以通过Web页面访问GitLab服务。

接下来,会专门再写一篇博客讲述如何在Windows上通过Git客户端像访问GitHub一样访问GitLab,敬请期待~

一文搞懂GitLab安装部署及服务配置的更多相关文章

  1. 教你搞懂Jenkins安装部署!

    前言:请各大网友尊重本人原创知识分享,谨记本人博客:南国以南i Jenkins介绍 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用 ...

  2. Web端即时通讯基础知识补课:一文搞懂跨域的所有问题!

    本文原作者: Wizey,作者博客:http://wenshixin.gitee.io,即时通讯网收录时有改动,感谢原作者的无私分享. 1.引言 典型的Web端即时通讯技术应用场景,主要有以下两种形式 ...

  3. 一文搞懂vim复制粘贴

    转载自本人独立博客https://liushiming.cn/2020/01/18/copy-and-paste-in-vim/ 概述 复制粘贴是文本编辑最常用的功能,但是在vim中复制粘贴还是有点麻 ...

  4. 三文搞懂学会Docker容器技术(下)

    接着上面一篇:三文搞懂学会Docker容器技术(上) 三文搞懂学会Docker容器技术(中) 7,Docker容器目录挂载 7.1 简介 容器目录挂载: 我们可以在创建容器的时候,将宿主机的目录与容器 ...

  5. 一文搞懂指标采集利器 Telegraf

    作者| 姜闻名 来源|尔达 Erda 公众号 ​ 导读:为了让大家更好的了解 MSP 中 APM 系统的设计实现,我们决定编写一个<详聊微服务观测>系列文章,深入 APM 系统的产品.架构 ...

  6. 一文搞懂RAM、ROM、SDRAM、DRAM、DDR、flash等存储介质

    一文搞懂RAM.ROM.SDRAM.DRAM.DDR.flash等存储介质 存储介质基本分类:ROM和RAM RAM:随机访问存储器(Random Access Memory),易失性.是与CPU直接 ...

  7. 基础篇|一文搞懂RNN(循环神经网络)

    基础篇|一文搞懂RNN(循环神经网络) https://mp.weixin.qq.com/s/va1gmavl2ZESgnM7biORQg 神经网络基础 神经网络可以当做是能够拟合任意函数的黑盒子,只 ...

  8. 一文搞懂 Prometheus 的直方图

    原文链接:一文搞懂 Prometheus 的直方图 Prometheus 中提供了四种指标类型(参考:Prometheus 的指标类型),其中直方图(Histogram)和摘要(Summary)是最复 ...

  9. 三文搞懂学会Docker容器技术(中)

    接着上面一篇:三文搞懂学会Docker容器技术(上) 6,Docker容器 6.1 创建并启动容器 docker run [OPTIONS] IMAGE [COMMAND] [ARG...] --na ...

随机推荐

  1. layui加tp5图片上传实例

    <div class="layui-fluid"> <div class="layui-row"> <form class=&qu ...

  2. 手机端页面访问PC页面自动跳手机端代码

    <script> var mobileAgent = new Array("iphone", "ipod", "ipad", & ...

  3. Yii2.0 URL美化功能Nginx与Apache配置文件

    NGinx: location / { index index.html index.htm index.php; try_files $uri $uri/ /index.php$is_args$ar ...

  4. 最全的ASCII码对照表

    转自https://blog.csdn.net/jinduozhao/article/details/75398793 十进制代码 十六进制代码 MCS 字符或缩写 DEC 多国字符名 ASCII 控 ...

  5. Spring基础之AOP

    一.AOP能解决什么问题 业务层每个service都要管理事务,在每个service中单独写事务,就会产生很多重复性的代码,而且修改事务时,需要修改源码,不利于维护.为此,把横向重复的代码,纵向抽取形 ...

  6. 痞子衡嵌入式:MCUBootUtility v2.3发布,这次不再放过任何一款Flash

    -- 痞子衡的 NXP-MCUBootUtility 开源项目自2018年8月27日第一笔提交至今已有21个月,目前累计代码已近50000行.相信这个工具为大家开发 i.MXRT 项目提供了一些便利, ...

  7. Gauge框架在JS中的简单应用

    gauge框架简介 Gauge是一个轻量级的跨平台测试自动化工具. gauge安装[Win10 64位下测试] [百度网盘链接]https://pan.baidu.com/s/1bidE34gLLrS ...

  8. 关于Backus-Naur Form巴克斯诺尔范式和扩展巴克斯范式的知识点和相关词语中英文对照

    巴克斯诺尔范式的相关词语中英文对照和知识点 syntax 语法 强调的是编程语言的组形式,例如一个句子中会包含表达式.陈述还有各种单元等等 semantics 语义 强调的是这个编程语言的实际含义,例 ...

  9. Alpha冲刺 —— 个人总结

    这几日Alpha冲刺的个人进展汇总,收获满满,我成长了. 我们的团队博客链接,团队作业第五次--Alpha冲刺 4.30 今日进展 改进数据库:字段命名重新规范,在record表中添加confirme ...

  10. Rocket - debug - Example: Accessing Registers Using Program Buffer

    https://mp.weixin.qq.com/s/8yYLVg-RXX3XX0T431lxeA 介绍riscv debug接口的使用实例:使用Program Buffer读取寄存器. 1. Wri ...