自建代码托管平台GitLab教程

大数据那些事

共 3391字,需浏览 7分钟

 · 2021-04-18

点击上方蓝字
关注我吧


GitLab是由GitLabInc.开发,使用MIT许可证的基于网络Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。

GitLab由乌克兰程序员DmitriyZaporozhets和ValerySizov开发,它使用Ruby语言写成。后来,一些部分用Go语言重写。截止2018年5月,该公司约有290名团队成员,以及2000多名开源贡献者。GitLab被IBM,Sony,JülichResearchCenter,NASA,Alibaba,Invincea,O’ReillyMedia,Leibniz-Rechenzentrum(LRZ),CERN,SpaceX等组织使用。

官网地址:https://about.gitlab.com/

安装说明:https://about.gitlab.com/installation/


1

服务器准备


准备一个系统为CentOS7以上版本的服务器,要求内存4G,磁盘50G。

关闭防火墙,并且配置好主机名和IP,保证服务器可以上网。

此教程使用虚拟机:主机名:gitlab-server  IP地址:192.168.6.200


2

安装包准备

Yum在线安装gitlab-ce时,需要下载几百M的安装文件,非常耗时,所以最好提前把所需RPM包下载到本地,然后使用离线rpm的方式安装。

下载地址:

https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm


3

编写安装脚本

安装gitlab步骤比较繁琐,因此我们可以参考官网编写gitlab的安装脚本。

[root@gitlab-server module]# vim gitlab-install.shsudo rpm -ivh /opt/module/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm sudo yuminstall -y curl policycoreutils-python openssh-server cronie sudo lokkit -shttp -s ssh sudo yuminstall -y postfix sudo servicepostfix start sudo chkconfigpostfix on curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh| sudo bash sudo EXTERNAL_URL="http://gitlab.example.com" yum -y install gitlab-ce

给脚本增加执行权限

[root@gitlab-server module]# chmod +x gitlab-install.sh[root@gitlab-server module]# ll总用量 403104-rw-r--r--. 1root root 412774002 4月   7 15:47 gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm-rwxr-xr-x. 1root root       416 4月   7 15:49 gitlab-install.sh

然后执行该脚本,开始安装gitlab-ce。注意一定要保证服务器可以上网。

[root@gitlab-server module]# ./gitlab-install.sh警告:/opt/module/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm:头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY准备中...                          #################################[100%]正在升级/安装...   1:gitlab-ce-13.10.2-ce.0.el7        #################################[100%]。。。。。。


4

初始化GitLab服务

执行以下命令初始化GitLab服务,过程大概需要几分钟,耐心等待…

[root@gitlab-server module]# gitlab-ctl reconfigure 。。。。。。Runninghandlers:Runninghandlers completeChef Clientfinished, 425/608 resources updated in 03 minutes 08 secondsgitlabReconfigured! 


5

启动GitLab服务


执行以下命令启动GitLab服务,如需停止,执行gitlab-ctlstop

[root@gitlab-server module]# gitlab-ctl startok: run:alertmanager: (pid 6812) 134sok: run:gitaly: (pid 6740) 135sok: run:gitlab-monitor: (pid 6765) 135sok: run:gitlab-workhorse: (pid 6722) 136sok: run:logrotate: (pid 5994) 197sok: run:nginx: (pid 5930) 203sok: run:node-exporter: (pid 6234) 185sok: run:postgres-exporter: (pid 6834) 133sok: run:postgresql: (pid 5456) 257sok: run:prometheus: (pid 6777) 134sok: run:redis: (pid 5327) 263sok: run:redis-exporter: (pid 6391) 173sok: run:sidekiq: (pid 5797) 215sok: run:unicorn: (pid 5728) 221s


6

使用浏览器访问GitLab

使用主机名或者IP地址即可访问GitLab服务。需要提前配一下windows的hosts文件。

首次登陆之前,需要修改下GitLab提供的root账户的密码,要求8位以上,包含大小写字母和特殊符号。因此我们修改密码为Atguigu.123456

然后使用修改后的密码登录GitLab。

GitLab登录成功。


7

GitLab创建远程库



8

IDEA集成GitLab

首先在IDEA上安装GitLab插件,对GitLab插件进行配置如下:

push本地代码到GitLab远程库

自定义远程连接

注意:gitlab网页上复制过来的连接是:http://gitlab.example.com/root/git-test.git

需要手动修改为:http://gitlab-server/root/git-test.git

       选择gitlab远程连接,进行push。

首次向连接gitlab,需要登录帐号和密码,用root帐号和我们修改的密码登录即可。

代码Push成功。

只要GitLab的远程库连接定义好以后,对GitLab远程库进行pull和clone的操作和Github、码云一致,此处不再赘述。



扫码关注我们

微信号|bigdata_story

B站|大数据那些事


想获取更多更全资料

扫码加好友入群

欢迎各位大佬加入开源共享

共同面对大数据领域疑难问题

来稿请投邮箱:miaochuanhai@126.com


浏览 95
点赞
评论
收藏
分享

手机扫一扫分享

举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

举报