gitlab部署

文章目录

    • 1.GitLab简介、gitlab和github区别
    • 2.部署
    • 3.web端设置
    • 4.测试:克隆项目


1.GitLab简介、gitlab和github区别

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。

gitlab和github区别主要体现在GitHub如果使用私有仓库,是需要付费的,GitLab可以在上面搭建私人的免费仓库;

2.部署

实验需求:虚拟机最小需求:4G内存 4核cpu(组件较多)
官网:https://gitlab.cn/install
下载网址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
gitlab部署_第1张图片

安装依赖性
[root@server1 ~]# yum install -y curl policycoreutils-python openssh-server perl

安装gitlab
[root@server1 ~]# yum install -y gitlab-ce-15.9.3-ce.0.el7.x86_64.rpm      ##较大1.2G、清华源下载
[root@server1 ~]# cd /etc/gitlab/
[root@server1 gitlab]# vim gitlab.rb
external_url 'http://192.168.56.11'			#gitlab访问地址

自动化部署:
注意:修改配置文件后,都需要重新reconfigure
[root@server1 gitlab]# gitlab-ctl reconfigure
gitlab部署_第2张图片
确保服务均run状态
gitlab部署_第3张图片

3.web端设置

登录
用户:root
初始密码: cat /etc/gitlab/initial_root_password

gitlab部署_第4张图片
语言设置
gitlab部署_第5张图片
gitlab部署_第6张图片
修改密码,初始密码24小时后过期
gitlab部署_第7张图片
新建项目
gitlab部署_第8张图片
新建项目后初始化在gitlab完成,可以克隆初始化后的文件
gitlab部署_第9张图片

添加密钥
gitlab部署_第10张图片

4.测试:克隆项目

[root@server1 ~]# git clone git@192.168.56.11:root/demo.git
Cloning into 'demo'...
The authenticity of host '192.168.56.11 (192.168.56.11)' can't be established.
ECDSA key fingerprint is SHA256:wENyii9Q7PhKduD9pHQD5G3EbAt68JiY51ifHt4lD7Y.
ECDSA key fingerprint is MD5:65:e0:39:b7:a3:97:d2:19:81:6e:70:f2:a4:e0:12:d8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.56.11' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

[root@server1 ~]# ls
demo
[root@server1 ~]# cd demo/
[root@server1 demo]# git remote -v
origin  git@192.168.56.11:root/demo.git (fetch)
origin  git@192.168.56.11:root/demo.git (push)

增加发布页面

[root@server1 demo]# echo www.westos.org > index.html
[root@server1 demo]# ls
index.html  README.md

[root@server1 demo]# git add  index.html
[root@server1 demo]# git commit -m "add index.html"
[main e72f22d] add index.html
 1 file changed, 1 insertion(+)
 create mode 100644 index.html
[root@server1 demo]# git push -u origin main
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 286 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.56.11:root/demo.git
   30504ed..e72f22d  main -> main
Branch main set up to track remote branch main from origin.

gitlab部署_第11张图片


你可能感兴趣的:(CICD,gitlab)