Linux架构篇、第五章_03gitlab的搭建

Linux_架构篇

欢迎来到Linux的世界,看笔记好好学多敲多打,每个人都是大神!

题目:

版本号: 1.0,0
作者: @老王要学习
日期: 2025.05.14
适用环境: Rocky9.5

文档说明

本文档聚焦于 Centos7 环境下 GitLab 的搭建与配置。详细介绍了硬件、软件要求,涵盖准备环境步骤,如更新缓存、卸载旧内核等,还阐述了网页访问配置流程,包括查看临时密码、登录、设置中文、创建群组用户项目等操作

环境准备

硬件要求

  • 服务器: 2核CPU、2GB内存,20GB硬盘空间
  • 网络: 确保服务器具有固定的IP地址,并且防火墙允许FTP端口(默认22端口)的通信

软件要求

  • 操作系统:Rocky9.5
  • FTP软件:SecureCRT
  • 软件包:gitlab-ce-17.9.7-ce.0.el8.x86_64

一、准备环境

1.1更新缓存关闭防火墙与selinux

dnf update

systemctl stop firewalld && systemctl disable firewalld

sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

reboot

1.2卸载旧内核

#查看内核版本
rpm -qa |grep kernel

#卸载
dnf remove kernel-modules-core-5.14.0-503.14.1.el9_5.x86_64

reboot

1.3添加 GitLab 软件源

#添加GitLab 软件源如下: 
cat>/etc/yum.repos.d/gitlab.repo<<EOF
[gitlab-ce] name=Gitlab CE Repository baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0 enabled=1
EOF

# 更新软件源信息
dnf makecache

#显示系统中已启用的可用软件库
dnf repolist 
#输出如下: 
repo id                            repo name
appstream                          Rocky Linux 9 - AppStream
baseos                             Rocky Linux 9 - BaseOS
extras                             Rocky Linux 9 - Extras
gitlab-ce                          Gitlab CE Repository

1.4安装配置gitlab

#导入下载好的安装包
[root@gitlab01 ~]# ls
anaconda-ks.cfg  gitlab-ce-17.9.7-ce.0.el8.x86_64.rpm

#本地安装
dnf -y localinstall gitlab-ce-17.9.7-ce.0.el8.x86_64.rpm 

#配置gitlab.rb 
sed -i "s/external_url 'http:\/\/gitlab.example.com'/external_url 'http:\/\/192.168.174.10'/" /etc/gitlab/gitlab.rb 

#重新配置并应用 GitLab 的各项设置
gitlab-ctl reconfigure

#启动 GitLab 所依赖的全部服务或者特定服务
gitlab-ctl start

#查看端口号是否启动
ss -antpl | grep 80
LISTEN 0      511          0.0.0.0:8060      0.0.0.0:*    users:(("nginx",pid=3103,fd=8),("nginx",pid=3102,fd=8),("nginx",pid=3101,fd=8))
LISTEN 0      4096       127.0.0.1:9236      0.0.0.0:*    users:(("gitaly",pid=3080,fd=11),("gitaly",pid=3080,fd=5))                     
LISTEN 0      1024       127.0.0.1:8080      0.0.0.0:*    users:(("ruby",pid=2906,fd=24),("ruby",pid=2905,fd=24),("ruby",pid=2676,fd=24))
LISTEN 0      128        127.0.0.1:8082      0.0.0.0:*    users:(("ruby",pid=2710,fd=10))                                                
LISTEN 0      128        127.0.0.1:8092      0.0.0.0:*    users:(("ruby",pid=2708,fd=23))                                                
LISTEN 0      511          0.0.0.0:80        0.0.0.0:*    users:(("nginx",pid=3103,fd=7),("nginx",pid=3102,fd=7),("nginx",pid=3101,fd=7))

二、网页访问进行配置

2.1查看gitlab临时密码

grep "Password:" /etc/gitlab/initial_root_password 
#输出如下: 
Password: 9nZIxuuxPuuXcSXiRao0flJYQvQkoxncbRIDa69wd14=

2.2进入gitlab网页进行登录

http://192.168.174.10/

![[Linux实训笔记/5月/image/Pas在这里插入图片描述

2.3配置切换为中文页面

在这里插入图片描述

在这里插入图片描述

2.4修改登录密码(自定义密码)

在这里插入图片描述

2.5创建群组

在这里插入图片描述

2.5.1创建群组

在这里插入图片描述

2.5.2创建群组(dev)——私有——公司团队——创建完成

在这里插入图片描述

2.6创建用户

2.6.1回到主页——添加人员

在这里插入图片描述

2.6.2创建新的用户(项目经理)

在这里插入图片描述

2.6.3给pm添加密码

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

2.6.4登录pm账号

在这里插入图片描述

在这里插入图片描述

2.7同上创建步骤创建用户user1、user2并赋予密码

在这里插入图片描述

在这里插入图片描述

2.8创建好的用户添加到群组并赋予对应权限

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

2.8.1要求pm(项目经理)——所有者

在这里插入图片描述

2.8.2要求user1(成员)——维护者

在这里插入图片描述

2.8.3要求user2(成员)——开发者

在这里插入图片描述

2.8.4添加完的效果如下

在这里插入图片描述

2.8.5为自己上传头像(自己想尝试可以退出当前,登录其他成员账号,根据如下步骤设置适合的头像)

在这里插入图片描述

2.9创建项目

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

2.10添加SSH密钥

# 启动前一章创建git查看秘钥段
[root@git01 ~]# cat /root/.ssh/id_rsa.pub 
#输出如下: 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+peONJ63yFzsBBsZ6Pd+NDlBl91cE+Vd3P5JtYhLw/EwKIMpe6gpvGlJZwTkAdW0BE/HyVj7miibgspn/imhSfXRpj0ZvohVXaLFn7FNsYjyhiKSY0mHT/um/FM1wekwWILcBdRMYPkBgL9t0nGfgoROWsCGHgNAlRh+FT1lCQJmID/Vxq4G4j1bvxw2IMfA8lEzPTLzFkhwwFTfMs+nh09CsIA0QL2I5AQaGNJ2Vy/eWV1hlLIDHzYaAX3eiO56oifMXbB7zBJA2qSGzCsKxSNIRJ0d9ogLXCzi4PfC2K8afcb2UzCEMMSWEmUzkuZIsVMMDf8TTELvGFrx9ulOD root@git01

在这里插入图片描述

2.11回到主页进入项目中

在这里插入图片描述

2.12创建新的库并推送

在这里插入图片描述

#创建新的库
mkdir /tmp/mypm
cd /tmp/mypm/

# 从Git远程仓库克隆代码到本地
git clone git@192.168.174.10:dev/my-project01.git
#输出如下: 
Cloning into 'my-project01'...
The authenticity of host '192.168.174.10 (192.168.174.10)' can't be established.
ECDSA key fingerprint is SHA256:Il0oHe9B52faODmM7davM8wp6hS9d9G0ZpIj8EOq75Y.
ECDSA key fingerprint is MD5:8f:ea:88:36:da:8a:eb:1b:85:9e:78:94:ea:52:44:67.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.174.10' (ECDSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>

#进入库中写入文件
cd my-project01/
echo "今天也要努力" >>pm.txt

# 添加到缓存区
git add .

# 添加缓存区
git commit -m "add pm.txt"
#输出如下: 
[master (root-commit) 0f97f01] add pm.txt
 1 file changed, 1 insertion(+)
 create mode 100644 pm.txt

2.13推送现有的 Git 仓库

# 创建新的分支main
git switch --create main
#输出如下: 
Switched to a new branch 'main'

# 推送到Git仓库
git push --set-upstream origin main
#输出如下: 
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 218 bytes | 218.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To 192.168.174.10:dev/my-project01.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值