GitLab仓库管理系统安装详细步骤

8 篇文章 1 订阅
3 篇文章 0 订阅

前言

本案例安装 gitlab、jenkins、并部署springboot应用程序,所以准备了3台服务器。

`服务器1:安装gitlab
服务器2:安装jdk、maven、git、jenkins
因为jenkins需要jdk、maven、git
服务器3:安装jdk。
jenkins自动部署的springboot应用程序在服务器3

注意:以上springboot项目中用到的java版本与服务器2,服务器3中安装的一致
我虚拟机模拟搭建时版本如下:

  • jdk : jdk-11.0.16.1
  • maven : 3.8.6
  • jenkins : Jenkins 2.361.4 LTS
  • springboot : 2.7.1

一、安装gitlab

gitlab中文官网
英文官网

1、手动安装gitlab

官方安装

1)查看内存是否符合条件

内存大于4G

[root@VM-16-2-centos ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           7725         231        7262           0         231        7260
Swap:            0           0           0

2)安装依赖

yum install -y curl policycoreutils-python openssh-server perl
systemctl enable sshd
systemctl start sshd

3)配置镜像

curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash

4)安装gitlab

EXTERNAL_URL="http://192.168.109.144" yum install -y gitlab-jh

在这里插入图片描述
在这里插入图片描述

2、docker安装gitlab

1)安装gitlab

restart aways:开机自启动

docker run --detach \
 --hostname 192.168.109.144 \
 --publish 443:443 --publish 80:80 \
 --name gitlab \
 --restart always \
 --volume $GITLAB_HOME/config:/etc/gitlab:z \
 --volume $GITLAB_HOME/logs:/var/log/gitlab:z \
 --volume $GITLAB_HOME/data:/var/opt/gitlab:z \
 --shm-size 256m \
 registry.gitlab.cn/omnibus/gitlab-jh:latest

查看镜像

[root@localhost ~]# docker images
REPOSITORY                             TAG       IMAGE ID       CREATED      SIZE
registry.gitlab.cn/omnibus/gitlab-jh   latest    ead385313244   2 days ago   3.03GB

2)启动gitlab

整体如下:

[root@localhost ~]# docker start gitlab
gitlab

3)查看容器,进入容器,查看密码

docker ps -a

docker exec -it gitlab /bin/bash

cat /etc/gitlab/initial_root_password

整体如下:

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE                                         COMMAND             CREATED         STATUS                     PORTS                                                                              NAMES
c2c7bd2c196a   registry.gitlab.cn/omnibus/gitlab-jh:latest   "/assets/wrapper"   6 minutes ago   Up 6 minutes (unhealthy)   0.0.0.0:80->80/tcp, :::80->80/tcp, 22/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   gitlab
[root@localhost ~]# docker exec -it gitlab /bin/bash
root@192:/# cd /etc/gitlab/
root@192:/etc/gitlab# ll
total 184
drwxrwxr-x. 3 root root    268 Nov 16 09:28 ./
drwxr-xr-x. 1 root root     66 Nov 16 09:27 ../
-rw-------. 1 root root  19349 Nov 16 09:28 gitlab-secrets.json
-rw-------. 1 root root 138956 Nov 16 09:27 gitlab.rb
-rw-------. 1 root root    749 Nov 16 09:28 initial_root_password
-rw-------. 1 root root    513 Nov 16 09:27 ssh_host_ecdsa_key
-rw-r--r--. 1 root root    182 Nov 16 09:27 ssh_host_ecdsa_key.pub
-rw-------. 1 root root    411 Nov 16 09:27 ssh_host_ed25519_key
-rw-r--r--. 1 root root    102 Nov 16 09:27 ssh_host_ed25519_key.pub
-rw-------. 1 root root   2610 Nov 16 09:27 ssh_host_rsa_key
-rw-r--r--. 1 root root    574 Nov 16 09:27 ssh_host_rsa_key.pub
drwxr-xr-x. 2 root root      6 Nov 16 09:28 trusted-certs/
root@192:/etc/gitlab# cat initial_root_password
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: bvWqJ2Dg+eOhI+E5Lu6695yoPfJoiwoBH+4aLsXnQM4=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
root@192:/etc/gitlab# 

进入容器查看默认生成的密码密码存在/etc/gitlab/initail_root_password中

4)登录并修改密码

访问网址:http://192.168.109.144
用户名:root
密码:密码存在/etc/gitlab/initail_root_password中,24小时后会过期,所以登陆后需要修改密码。
在这里插入图片描述

开始修改密码:主菜单——》管理员——》用户——》编辑密码——》保存更改
在这里插入图片描述
在这里插入图片描述

5)重新登录验证新密码是否生效

二、IDEA新建本地项目关联远程本地仓库和git仓库

1、创建本地项目,配置maven

2、创建本地Git仓库

选择VCS——》Create Git Repository——》跳出弹框选择需要版本控制的项目,ok
在这里插入图片描述
在这里插入图片描述

3、将本地项目提交到本地仓库

在这里插入图片描述

4、连接远程仓库

在这里插入图片描述

5、推送代码push

在这里插入图片描述

总结:遇到的问题

1)关联远程仓库时遇到如下问题:

在这里插入图片描述
原因:
解决:
将当前用户加入到gitlab本项目仓库权限中
进入项目跟目录.git路径下编辑config文件
在这里插入图片描述

[core]    repositoryformatversion = 0    filemode = false    bare = false    logallrefupdates = true    symlinks = false    ignorecase = true[remote "origin"]    url = http://qlx:qwedsa123@192.168.109.144/root/test1.git
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小东很不戳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值