版本控制gitlab

版本控制gitlab

一. 版本控制

1. 常用的版本控制工具:
  • gitlab 公司服务器搭建,用来存放开发人员的代码
  • svn (subversion):是一个自由开源的版本控制系统
    • 文件和目录可以超越时空。Subversion将文件存放在中心版本库里,这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况,这样就可以借此将数据恢复到以前的版本,并可以查看数据的更改细节
  • github 国外
  • 码云gitee 国内
2. 开发人员发布流程
  • 由开发人员在开发环境自测提出发布,填写变更单,将邮件发送给开发人员的上级,同意之后发送到测试环境

  • 在测试环境测试之后,变更单签字之后,发送给运维人员

  • 运维人员在预部署环境敲一遍,测试完成后,备份,有问题回滚,没有问题在上线

  • 出现问题发邮件给运维上级,然后运维上级跟开发上级沟通,没有沟通好找运维上级找CTO

3. 介绍
  • 对软件开发过程中各种程序代码、配置文件及说明文档等文件变更的管理,是软件配置管理的核心思想之一。

  • 版本控制最主要的功能就是追踪文件的变更(新增,删除,修改),将什么时候、什么人更改了文件的什么内容等信息忠实地了记录下来,形成一个版本,每一次文件的改变,文件的版本号都将增加

  • 软件开发往往是多人协同作业,版本控制可以有效地解决版本的同步以及不同开发者之间的开发通信问题,提高协同开发的效率。并行开发中最常见的不同版本软件的错误(Bug)修正问题也可以通过版本控制中分支与合并的方法有效地解决。

  • 将开发好的放入代码仓库没有问题的

  • 第一版开发基线,发送到测试环境测试,在发送到生产环境在测试定为基线,在开发新功能,不能发到代码仓库,新的代码会产生新的分支,分支围绕主干(开发基线),新版本在开发时基于基线,开发完成之后测试没问题合并

  • 版本控制是软件配置管理的核心功能。

二. gitlab部署

1. gitlab网址
[root@node7 ~]# wget https://mirror.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm
[root@node7 ~]# ls
anaconda-ks.cfg  gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm
2. 关闭防火墙和selinux安装依赖包
[root@node7 ~]# vim /etc/selinux/config 
[root@node7 ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@node7 ~]# 

[root@node7 ~]# dnf -y install git curl openssh-server openssh-clients postfix cronie
缺少policycoreutils-python
[root@node7 ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm
[root@node7 ~]# ls
anaconda-ks.cfg
gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm
policycoreutils-python-2.5-34.el7.x86_64.rpm
强制安装
[root@node7 ~]# rpm -ivh --nodeps policycoreutils-python-2.5-34.el7.x86_64.rpm 
warning: policycoreutils-python-2.5-34.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
        file /usr/bin/semodule_package from install of policycoreutils-python-2.5-34.el7.x86_64 conflicts with file from package policycoreutils-2.9-16.el8.x86_64
        file /usr/share/man/ru/man8/semodule_package.8.gz from install of policycoreutils-python-2.5-34.el7.x86_64 conflicts with file from package policycoreutils-2.9-16.el8.x86_64
[root@node7 ~]#
将policycoreutils卸载在次安装
[root@node7 ~]# rpm -e policycoreutils

[root@node7 ~]# rpm -qa|grep policycoreutils
policycoreutils-python-2.5-34.el7.x86_64
[root@node7 ~]# 


[root@node7 ~]# rpm -ivh --nodeps 
policycoreutils-python-2.5-34.el7.x86_64.rpm 
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%]
[root@node7 ~]# 
3. 启动postfix服务并设置开机自启
[root@node7 ~]# systemctl enable --now postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@node7 ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*          
LISTEN 0      100        127.0.0.1:25        0.0.0.0:*          
LISTEN 0      128             [::]:22           [::]:*          
LISTEN 0      100            [::1]:25           [::]:*          
[root@node7 ~]# 
4. 安装gitlab
[root@node7 ~]# rpm -ivh gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm 
warning: gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-15.2.2-ce.0.el7        ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.

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


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

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=15-2

[root@node7 ~]# 
5. 配置gitlab
[root@node7 ~]# vim /etc/gitlab/gitlab.rb
[root@node7 ~]# cat /etc/gitlab/gitlab.rb|grep http://192.168.232.128
external_url 'http://192.168.232.128'
[root@node7 ~]# 

将selinux.rb中注释掉
[root@node7 recipes]# pwd
/opt/gitlab/embedded/cookbooks/gitlab/recipes
[root@node7 recipes]# vim selinux.rb 
[root@node7 recipes]# 

[root@node7 ~]# export LANG=en_US.UTF-8
[root@node7 ~]# bash

重新配置
[root@node7 ~]# gitlab-ctl reconfigure

[root@node7 sv]# ls
alertmanager  gitlab-exporter  gitlab-workhorse  logrotate  node-exporter      postgresql  puma   redis-exporter
gitaly        gitlab-kas       grafana           nginx      postgres-exporter  prometheus  redis  sidekiq
[root@node7 sv]# 

[root@node7 recipes]# gitlab-ctl stop
ok: down: alertmanager: 1s, normally up
ok: down: gitaly: 0s, normally up
ok: down: gitlab-exporter: 0s, normally up
ok: down: gitlab-kas: 1s, normally up
ok: down: gitlab-workhorse: 0s, normally up
ok: down: grafana: 0s, normally up
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 1s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 1s, normally up
ok: down: prometheus: 0s, normally up
ok: down: puma: 0s, normally up
ok: down: redis: 1s, normally up
ok: down: redis-exporter: 0s, normally up
ok: down: sidekiq: 0s, normally up
[root@node7 recipes]# gitlab-ctl restart
ok: run: alertmanager: (pid 534736) 1s
ok: run: gitaly: (pid 534803) 0s
ok: run: gitlab-exporter: (pid 534871) 1s
ok: run: gitlab-kas: (pid 534914) 0s
ok: run: gitlab-workhorse: (pid 534990) 1s
ok: run: grafana: (pid 535000) 0s
ok: run: logrotate: (pid 535035) 0s
ok: run: nginx: (pid 535124) 1s
ok: run: node-exporter: (pid 535173) 0s
ok: run: postgres-exporter: (pid 535248) 1s
ok: run: postgresql: (pid 535298) 0s
ok: run: prometheus: (pid 535329) 1s
ok: run: puma: (pid 535384) 0s
ok: run: redis: (pid 535389) 0s
ok: run: redis-exporter: (pid 535541) 1s
ok: run: sidekiq: (pid 535625) 0s

[root@node7 recipes]# gitlab-ctl reconfigure
[root@node7 ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 116358) 0s
ok: run: gitaly: (pid 116412) 1s
ok: run: gitlab-exporter: (pid 116470) 0s
ok: run: gitlab-kas: (pid 116502) 0s
ok: run: gitlab-workhorse: (pid 116526) 1s
ok: run: grafana: (pid 116541) 0s
ok: run: logrotate: (pid 116638) 1s
ok: run: nginx: (pid 116644) 0s
ok: run: node-exporter: (pid 116656) 1s
ok: run: postgres-exporter: (pid 116702) 0s
ok: run: postgresql: (pid 116810) 0s
ok: run: prometheus: (pid 116850) 1s
ok: run: puma: (pid 116914) 1s
ok: run: redis: (pid 116990) 0s
ok: run: redis-exporter: (pid 117008) 0s
ok: run: sidekiq: (pid 117187) 0s
[root@node7 ~]# 

[root@node7 recipes]# ss -antl
State          Recv-Q         Send-Q                 Local Address:Port                   Peer Address:Port         Process         
LISTEN         0              128                        127.0.0.1:8082                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:9236                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:8150                        0.0.0.0:*                            
LISTEN         0              128                          0.0.0.0:22                          0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:8151                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:3000                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:8153                        0.0.0.0:*                            
LISTEN         0              100                        127.0.0.1:25                          0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:8154                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:8155                        0.0.0.0:*                            
LISTEN         0              511                          0.0.0.0:8060                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:9121                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:9090                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:9187                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:9093                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:9100                        0.0.0.0:*                            
LISTEN         0              1024                       127.0.0.1:9229                        0.0.0.0:*                            
LISTEN         0              511                          0.0.0.0:80                          0.0.0.0:*                            
LISTEN         0              128                        127.0.0.1:9168                        0.0.0.0:*                            
LISTEN         0              128                             [::]:22                             [::]:*                            
LISTEN         0              100                            [::1]:25                             [::]:*                            
LISTEN         0              1024                               *:9094                              *:*                            
LISTEN         0              128                            [::1]:9168                           [::]:*                            
[root@node7 recipes]# 
5.1 查看版本
[root@node7 gitlab]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 15.2.2
[root@node7 gitlab]# 
5.2 出现错误
报错:
Error executing action `run` on resource 'execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8]'

There was an error running gitlab-ctl reconfigure:

execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 49) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
STDERR: initdb: error: invalid locale settings; check LANG and LC_* environment variables
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1

解决:将selinux.rb后面注释掉
[root@node7 recipes]# pwd
/opt/gitlab/embedded/cookbooks/gitlab/recipes
[root@node7 recipes]# ls selinux.rb 
selinux.rb
[root@node7 recipes]# 
[root@node7 ~]# export LANG=en_US.UTF-8
[root@node7 ~]# bash
6. 破解密码
[root@node7 ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
 GitLab:       15.2.2 (4ecb014a935) FOSS
 GitLab Shell: 14.9.0
 PostgreSQL:   13.6
------------------------------------------------------------[ booted in 22.46s ]
Loading production environment (Rails 6.1.4.7)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = '12345678'
=> "12345678"
irb(main):003:0> user.password_confirmation = '12345678'
=> "12345678"
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit
[root@node7 ~]# 
6.1 gitlab常用管理操作
  • 项目管理(通常只是创建新项目)
  • 创建成员组(针对某个项目创建一个成员组)
  • 用户管理(此用户乃gitlab用户而非系统用户)
    • 来了新员工,为其添加gitlab用户
    • 员工离职,将其gitlab用户禁用或删除
7. 登录
  • 在这里插入图片描述

  • 在这里插入图片描述

8. 创建新项目
8.1 创建项目
  • 在这里插入图片描述

  • 在这里插入图片描述

在这里插入图片描述

  • 创建好项目

在这里插入图片描述

8.2 项目配置,将本地文件传到项目中
Git 全局设置
[root@node7 ~]# git config --global user.name "root"
[root@node7 ~]# git config --global user.email "1@2.com"

创建一个新的存储库
[root@node7 ~]# git clone http://192.168.232.128/gitlab-instance-8a7fa3dc/run.git
Cloning into 'run'...
Username for 'http://192.168.232.128': root
Password for 'http://root@192.168.232.128': 
warning: You appear to have cloned an empty repository.
[root@node7 ~]# ls
anaconda-ks.cfg
gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm
policycoreutils-python-2.5-34.el7.x86_64.rpm
run
[root@node7 ~]# ls run/
[root@node7 ~]# ls -a run/
.  ..  .git
[root@node7 ~]# 

[root@node7 ~]# cd run/
[root@node7 run]# ls
[root@node7 run]# git switch -c main
Switched to a new branch 'main'
[root@node7 run]# touch README.md
[root@node7 run]# git add README.md
[root@node7 run]# git commit -m "add README"
[main (root-commit) 733985a] add README
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
[root@node7 run]# git push -u origin main
Username for 'http://192.168.232.128': root
Password for 'http://root@192.168.232.128': 
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 202 bytes | 202.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.232.128/gitlab-instance-8a7fa3dc/run.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
[root@node7 run]# 
  • readme文件

在这里插入图片描述

9. 创建组
9.1 点开menu
  • 创建组

在这里插入图片描述

在这里插入图片描述

  • 创建用户

在这里插入图片描述

在这里插入图片描述

  • 编辑用户

在这里插入图片描述

  • 设置密码

在这里插入图片描述

  • 将用户加入组

在这里插入图片描述

  • 在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

  • 查看

在这里插入图片描述

  • 查看项目

在这里插入图片描述

  • 查看tom用户

在这里插入图片描述

  • 把tom加入项目

在这里插入图片描述

  • 邀请组

在这里插入图片描述

在这里插入图片描述

10. 使用普通用户登录
10.1 普通用户登录
  • 刚登录设置密码,123456789

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值