gitlab部署

Gitlab部署

//配置yum源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# rm -f /etc/yum.repos.d/
[root@localhost ~]# dnf clean all
[root@localhost ~]# dnf list all

//配置epel源
[root@localhost ~]# dnf -y install epel-release

//安装git
[root@localhost ~]# dnf -y install git

//安装依赖包
[root@localhost ~]# dnf -y install openssh-server openssh-clients postfix cronie

//启动postfix服务并设置开机自启
[root@localhost ~]# systemctl enable --now postfix.service
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.

//下载gitlab的rpm包
[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm

//下载policycoreutils-python的rpm包
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm

[root@localhost ~]# rpm -qa | grep policycoreutils
policycoreutils-2.9-9.el8.x86_64
//如果系统有这个报的话,请先卸载
[root@localhost ~]# rpm -e policycoreutils-2.9-9.el8.x86_64

//安装policycoreutils-python
[root@localhost ~]# rpm -ivh policycoreutils-python-2.5-34.el7.x86_64.rpm --nodeps
warning: policycoreutils-python-2.5-34.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...

   1:policycoreutils-python-2.5-34.el7################################# [100%]

//安装gitlab
[root@localhost ~]# rpm -ivh gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm  --nodeps
warning: gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...

............

       *.                  *.

      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.

         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.

     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/

//修改配置文件
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.169.139'   //将此处设为gitlab的服务器ip地址亦或域名

//重载配置文件并重启gitlab
[root@localhost ~]# gitlab-ctl reconfigure   //时间有点久,请耐心等待
[root@localhost ~]# gitlab-ctl restart

//破解管理员密码
[root@localhost ~]# gitlab-rails console -e  production
Loading production environment (Rails 6.1.6.1)
irb(main):001:0> user = User.where(id: 1).first     //id为1是超级管理员
=> #
irb(main):002:0> user.password = 'zic12345'         //设置密码,最少8位
=> "zic12345"
irb(main):003:0> user.password_confirmation = 'zic12345'
=> "zic12345"
irb(main):004:0> user.save!         //保存,没问题会返回true
=> true
irb(main):005:0> exit           //退出

去浏览器输入ip访问

gitlab部署

gitlab部署

Gitlab的基本使用

新建项目

建立项目之前需要将gitlab服务器的ssh公钥添加到

gitlab部署

gitlab部署

如果本地有ssh公钥就直接进行使用,没有可以生成

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:
SHA256:nrcevcXEAkfQd4JMgqqiGSFatYKmhmqzZGj8a59xUTA root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|       E .o=o.   |
|    .   +  o+ o .|
| . . . . .. .. o |
|+.o . . .  o .   |
|*o . . .S   . o  |
|B.. .  ... . +   |
|+O . . .o o . o  |
|Bo..  +  . o o   |
|..+ooo   .o .    |
+----[SHA256]-----+

查看/root/.ssh/id_rsa.pub文件的内容,将内容复制到如下位置,然后保存

gitlab部署

新建项目

gitlab部署

gitlab部署

gitlab部署

查看项目分支

gitlab部署

使用命令行的方式管理项目

首先将gitlab项目克隆到本地来,使用如下命令

选择想要克隆的项目

gitlab部署

gitlab部署

选择克隆,复制ssh克隆

gitlab部署

然后使用git clone命令

[root@localhost ~]# git clone git@192.168.169.139:gitlab-instance-63929587/zic.git
Cloning into 'zic'...

The authenticity of host '192.168.169.139 (192.168.169.139)' can't be established.

ECDSA key fingerprint is SHA256:h0JBqfyD7nmBvCwBazGyK6b50D/gE11IG/dW6E3J1Ug.

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.169.139' (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.

//可以看到多了一个zic的目录
[root@localhost ~]# ls
anaconda-ks.cfg  gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm  policycoreutils-python-2.5-34.el7.x86_64.rpm  zic
//进入项目
[root@localhost ~]# cd zic/
[root@localhost zic]# ls
README.md

上传文件

在上传文件之前,需要做两件事,指定本地访问项目的邮箱和用户

//指定邮箱
[root@localhost zic]# git config --global user.email "root@example.com"
//指定用户
[root@localhost zic]# git config --global user.name "root"

上传文件

//新建文件
[root@localhost zic]# touch file1
[root@localhost zic]# ls
file1  README.md

//添加文件
[root@localhost zic]# git add file1     //如果想上传多个文件的话就直接指定,上传所有文件就使用'.'代表整个目录
//提交,选项-m是描述信息
[root@localhost zic]# git commit -m "file1"
[main 228cd02] file1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file1
 //上传
 [root@localhost zic]# git push
Enumerating objects: 4, done.

Counting objects: 100% (4/4), done.

Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.

Writing objects: 100% (3/3), 260 bytes | 260.00 KiB/s, done.

Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To 192.168.169.139:gitlab-instance-63929587/zic.git
   a6e2488..228cd02  main -> main

到gitlab的web管理界面进行验证,file1文件已经上传了上来

gitlab部署

新建分支

//创建一个名为zic的分支
[root@localhost zic]# git branch zic

//进行同步
[root@localhost zic]# git push origin zic
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for zic, visit:
remote:   http://192.168.169.139/gitlab-instance-63929587/zic/-/merge_requests/new?merge_request%5Bsource_branch%5D=zic
remote:
To 192.168.169.139:gitlab-instance-63929587/zic.git
 * [new branch]      zic -> zic

gitlab部署

切换分支

//切换到分支zic
[root@localhost zic]# git checkout zic
Switched to branch 'zic'

//在分支zic里面上传一个文件
[root@localhost zic]# touch file2

[root@localhost zic]# git add file2

[root@localhost zic]# git commit -m "file2"
[zic 6295df5] file2
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file2
//在分支里推送不能直接使用push命令,直接使用他会提醒你使用'git push --set-upstream origin'
[root@localhost zic]# git push
fatal: The current branch zic has no upstream branch.

To push the current branch and set the remote as upstream, use

    git push --set-upstream origin zic
//这条命令是将zic这个分支与前面的分支main进行合并处理

[root@localhost zic]# git push --set-upstream origin zic
Enumerating objects: 3, done.

Counting objects: 100% (3/3), done.

Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.

Writing objects: 100% (2/2), 256 bytes | 256.00 KiB/s, done.

Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for zic, visit:
remote:   http://192.168.169.139/gitlab-instance-63929587/zic/-/merge_requests/new?merge_request%5Bsource_branch%5D=zic
remote:
To 192.168.169.139:gitlab-instance-63929587/zic.git
   228cd02..6295df5  zic -> zic
Branch 'zic' set up to track remote branch 'zic' from 'origin'.

gitlab部署

拉取文件

//将分支zic里的文件都拉取到分支main里
//切换到main分支
[root@localhost zic]# git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.

//进行拉取,拉取到本地
[root@localhost zic]# git pull origin zic
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:

  git config pull.rebase false  # merge (the default strategy)
  git config pull.rebase true   # rebase
  git config pull.ff only       # fast-forward only

You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

From 192.168.169.139:gitlab-instance-63929587/zic
 * branch            zic        -> FETCH_HEAD
Updating 228cd02..6295df5
Fast-forward
 file2 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file2

//推送
[root@localhost zic]# git push
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To 192.168.169.139:gitlab-instance-63929587/zic.git
   228cd02..6295df5  main -> main

gitlab部署

Original: https://www.cnblogs.com/zicnotes/p/16720879.html
Author: Zic师傅
Title: gitlab部署

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/606586/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 10分钟轻松学会 Python turtle 绘图

    先说明一下turtle绘图的基础知识: 1. 画布(canvas) 画布就是turtle为我们展开用于绘图区域, 我们可以设置它的大小和初始位置 1.1 设置画布大小 turtle…

    Linux 2023年6月8日
    0100
  • 【建议收藏】你知道数据库是怎么运行的吗?

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    Linux 2023年6月11日
    080
  • Docker-compose资源编排

    Docker-compose 1.简介 Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。 Docker-Compose将所管…

    Linux 2023年6月13日
    0110
  • logstash写入文件慢的问题排查记录

    终于找到根本原因了!!!!! logstash部署到k8s集群内部的,当所在节点的CPU资源被其他应用抢占时,logstash的处理速度就会降低 问题现象 logstash从kaf…

    Linux 2023年6月14日
    0173
  • sublime text里面中文字体显示异常解决方案

    sublime text下载之后一开始转成中文之后,会出现中文显示异常的问题,比如下图中”门”字显示异常 通过如下的设置可以解决该问题: 首选项&#8211…

    Linux 2023年6月13日
    0197
  • 最简单的,在win,linux中,用powershell,自动获取Let’s Encrypt证书方法

    powershell传教士原创 2020-04-12,2022-05更新 Let’s Encrypt证书有效期3个月,支持泛域名【*.你的网站.net】。支持n天内(一…

    Linux 2023年6月14日
    0101
  • Vue3 框架基础随笔 (一)

    Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架。 Vue可以使用简单的代码实现一个单页面应用。 基本格式 Vue通过模板语法来声明式的将数据渲…

    Linux 2023年6月14日
    082
  • k8s vs k3s: 差异解析

    2. K3s的优势 小型 K3s 的最大优势是它的尺寸最小(小于 100 MB),这有助于它以最少的设置在小型硬件中启动 Kubernetes 集群。 快速部署 curl -sfL…

    Linux 2023年6月13日
    0114
  • 阿里云Linux-Centos8安装mysql8

    1. 安装MySQL 依次执行以下&#x…

    Linux 2023年6月14日
    093
  • 积分排名查看

    1年05个月 2018-9-17 1年04个月 2018-9-04 1年04个月 2018-8-23 1年04个月 2018-8-21 posted @2018-08-21 21:…

    Linux 2023年6月7日
    095
  • 消息中间件MQ的学习境界和路线

    在《深入理解Java类加载机制,再也不用死记硬背了》里我提到了对于一门语言的”会”的三个层次。本篇将以知识地图的形式展现学习消息中间件MQ各个层次要掌握的内…

    Linux 2023年6月14日
    0111
  • 项目管理中的关键路径法-时窗图解法cpm

    完成单个活动所需的时间称为活动时间,可以形象地以一个矩形窗格来表示,这个窗格称为 时间窗口,简称 时窗。 1.1 分类 单位时窗: 基本时窗,时窗的不可分割的最小单元, 活动时窗:…

    Linux 2023年6月13日
    095
  • linux常用的一些命令

    时隔一年半,楼主又回来了,以前就想看一下鸟叔的教程,现在如愿了!也没有认真的去啃一本书真是惭愧啊,其实在linux环境中命令的用法真的可以查看命令的help,现学现用也是不错的 以…

    Linux 2023年6月8日
    098
  • make及makefile简单介绍

    GUN make是一种代码维护工具。 make工具会根据makefile文件定义的规则和步骤,完成整个软件项目的代码维护工作。 一般用来简化编译工作,可以极大地提高软件开发地效率。…

    Linux 2023年6月7日
    070
  • 服务器部署 Vue 和 Django 项目的全记录

    本篇记录我在一个全新服务器上部署 Vue 和 Django 前后端项目的全过程,内容包括服务器初始配置、安装 Django 虚拟环境、python web 服务器 uWSGI 和反…

    Linux 2023年6月7日
    0113
  • Golang中字符串、数组、切片排序

    使用Golang的sort包用来排序,包括二分查找等操作。下面通过实例代码来分享下sort包的使用技巧: 使用接口排序: sort.Sort(data Interface) 自定义…

    Linux 2023年6月6日
    0113
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球