gitlab部署,使用

gitlab部署

gitlab用来多人协同开发的企业级代码仓库平台,也叫远程仓库
注意必须安装gitlab系统语言必须用英文

//看locale命令看系统当前的字符集,如果是en_US.UTF-8就不用改
[root@localhost ~]# locale
LANG=zh_CN.UTF-8        //当前是中文的字符集

#改系统英文的方法
//安装英文的语言包
yum install -y langpacks-en.noarch
//修改字符集为英文,二选一
临时修改:
export LANG="en_US.UTF-8"
永久修改:
echo 'export LANG="en_US.UTF-8"'  >> /etc/profile
//修改之后,重新加载 profile 文件(使之立即生效)
source /etc/profile
//看字符集
echo $LANG
修改之前:
	en_US.UTF-8     英文
修改之后:
    zh_CN.UTF-8     中文

#注意安装gitlab至少要4个内存
[root@localhost ~]# dnf -y install curl openssh-server openssh-clients postfix cronie git
// postfix 邮件服务

#关闭防火墙和selinux
[root@localhost ~]# systemctl disable --now firewalld.service   
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config 
SELINUX=disabled

#这个是我的报错,和解决办法
[root@localhost ~]# systemctl enable --now postfix
Job for postfix.service failed because the control process exited with error code.
See "systemctl status postfix.service" and "journalctl -xe" for details.

[root@localhost ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset>
   Active: failed (Result: exit-code) since Wed 2022-08-10 17:19:47 CST; 25s ago
  Process: 90746 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
  Process: 90744 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, sta>
  Process: 90684 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=>

810 17:19:44 192.168.70.139 systemd[1]: Starting Postfix Mail Transport Agent...
810 17:19:44 192.168.70.139 aliasesdb[90684]: /usr/sbin/postconf: warning: vali>
810 17:19:44 192.168.70.139 aliasesdb[90684]: /usr/sbin/postconf: fatal: unable>
810 17:19:45 192.168.70.139 aliasesdb[90684]: newaliases: warning: valid_hostna>
810 17:19:45 192.168.70.139 aliasesdb[90684]: newaliases: fatal: unable to use >
810 17:19:46 192.168.70.139 postfix[90746]: warning: valid_hostname: numeric ho>
810 17:19:46 192.168.70.139 postfix[90746]: fatal: unable to use my own hostname
810 17:19:47 192.168.70.139 systemd[1]: postfix.service: Control process exited>
[root@localhost ~]# vim /etc/postfix/main.cf
myhostname = host.domain.tld    //取消这个注释
#myhostname = virtual.domain.tld
[root@localhost ~]# systemctl enable --now postfix
[root@localhost ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset>
   Active: active (running) since Wed 2022-08-10 17:23:46 CST; 5s ago
//成功解决问题,没有报错就不用取消注释
[root@localhost ~]# ss -antl
State     Recv-Q    Send-Q         Local Address:Port         Peer Address:Port    
LISTEN    0         128                  0.0.0.0:111               0.0.0.0:*       
LISTEN    0         32             192.168.122.1:53                0.0.0.0:*       
LISTEN    0         128                  0.0.0.0:22                0.0.0.0:*       
LISTEN    0         5                  127.0.0.1:631               0.0.0.0:*       
LISTEN    0         100                127.0.0.1:25        //这个       0.0.0.0:*       
//端口号尽量要少,后面会出现很多端口号,一样的端口号会有冲突
[root@localhost ~]# rpm -ivh gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm 
警告:gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
错误:依赖检测失败:
        policycoreutils-python 被 gitlab-ce-15.2.2-ce.0.el7.x86_64 需要
[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 -ivh --nodeps policycoreutils-python-2.5-34.el7.x86_64.rpm 
警告:policycoreutils-python-2.5-34.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [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.
[root@localhost ~]# rpm -e --nodeps policycoreutils    //这样解决依赖关系删,会比  dnf -y remove   删除好,
//显示已经装过包了,删除了在装
//--nodeps  忽略依赖关系下载
[root@localhost ~]# rpm -ivh --nodeps policycoreutils-python-2.5-34.el7.x86_64.rpm 
警告:policycoreutils-python-2.5-34.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:policycoreutils-python-2.5-34.el7################################# [100%]
[root@localhost ~]# rpm -ivh gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm 
//报错就看这篇博客底部,的报错解答
警告:gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   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`

#重载配置文件并重启gitlab
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://192.168.70.139'    //改成自己本机的IP,或域名
//普通用户要sudo借权,我下载是root用户就不用
[root@localhost ~]# gitlab-ctl reconfigure   //重新配置
//gitlab-ctl stop    停止
//gitlab-ctl restart   重启开启服务端口
//如果改了配置文件就要重新配置
[root@localhost ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 58372) 0s
ok: run: gitaly: (pid 58382) 1s
ok: run: gitlab-exporter: (pid 58457) 0s
ok: run: gitlab-kas: (pid 58459) 1s
ok: run: gitlab-workhorse: (pid 58522) 0s
ok: run: logrotate: (pid 58593) 1s
ok: run: nginx: (pid 58604) 0s
ok: run: node-exporter: (pid 58612) 1s
ok: run: postgres-exporter: (pid 58623) 0s
ok: run: postgresql: (pid 58674) 1s
ok: run: prometheus: (pid 58717) 0s
ok: run: puma: (pid 60451) 0s
ok: run: redis: (pid 60456) 0s
ok: run: redis-exporter: (pid 60503) 1s
ok: run: sidekiq: (pid 60840) 0s

#查看当前的gitlab版本
[root@localhost ~]# head -1 /opt/gitlab/version-manifest.txt

#看到这个界面就成功 ip+/users/sign_in
在这里插入图片描述

破解管理员密码

[root@localhost ~]# 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 68.02s ]
Loading production environment (Rails 6.1.4.7)

irb(main):003:0> user = User.where(id: 1).first     //id为root账户
=> #<User id:1 @root>
irb(main):004:0> user.password = '12345678'
=> "12345678"
irb(main):005:0> user.password_confirmation = '12345678'
=> "12345678"
irb(main):006:0> user.save!
=> true
irb(main):007:0> exit
[root@localhost ~]# 

登录
在这里插入图片描述

gitlab设置中文界面

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

gitlab关闭任何人都可以注册账户

注意只要涉及到角色就设置为修改为developer角色,只可以读的权限
组或者用户基本设置为developer角色
在这里插入图片描述
在这里插入图片描述

创建项目
在这里插入图片描述

在这里插入图片描述
项目名不能用中文
在这里插入图片描述

设置权限,让开发人员有权限传
在这里插入图片描述

在这里插入图片描述
//程序员是用软件svn传项目程序,这里我用的是命令式

//创建用户
[root@localhost ~]# git config --global user.name "root"
//邮箱
[root@localhost ~]# git config --global user.email "1@2.com"
//克隆项目
[root@localhost ~]# git clone http://192.168.70.150/gitlab-instance-4f4e6713/test.git
Cloning into 'test'...
Username for 'http://192.168.70.150': root      //gitlab的用户名
Password for 'http://root@192.168.70.150':      //gitlab的密码12345678
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@localhost ~]# ls
anaconda-ks.cfg                       policycoreutils-python-2.5-34.el7.x86_64.rpm
gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm  test   //项目
//.git  是个项目仓库
[root@localhost ~]# ls -a test/
.  ..  .git  README.md
//切换到主分支
[root@localhost test]# git switch -c master
Switched to a new branch 'master'
[root@localhost test]# ls
README.md
[root@localhost test]# echo 'hello develop' > develop.html  
//创建测试文件
[root@localhost test]# cat develop.html 
hello develop
//添加到git暂存区
[root@localhost test]# git add develop.html
//提交状态,取名"第一次开发"
[root@localhost test]# git commit -m "第一次开发"
[master ca3b890] 第一次开发
 1 file changed, 1 insertion(+)
 create mode 100644 develop.html

//分支重命名,主分支原来叫master,现在改为main
[root@localhost test]# git branch -M main
//主分支上传到gitlab远程仓库
[root@localhost test]# git push -uf origin main
Username for 'http://192.168.70.150': root
Password for 'http://root@192.168.70.150': 
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), 294 bytes | 294.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.70.150/gitlab-instance-4f4e6713/test.git
   a998280..ca3b890  main -> main
branch 'main' set up to track 'origin/main'.



查看
在这里插入图片描述

设置ssh密钥

前言
前提条件是,公司的gitlab,运维没有关闭ssh的权限获取,或者叫运维开通那个ssh权限,生成的公钥要给运维那边一个!这样设置是可以成功。

//查看有没有配置过密钥
[root@localhost ~]# ll ~/.ssh
total 8
-rw-------. 1 root root 2590 Apr  6 05:43 id_rsa
-rw-r--r--. 1 root root  564 Apr  6 05:43 id_rsa.pub     //有
[root@localhost ~]# cat ~/.ssh/id_rsa.pub       //复制以下
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDEx8assdDrwh59fn4FQWhNCiMU4mOFHCO2xY12r+y7SkDWjVXBLaN72ilBByMMxB53/Wa2p5QcUpK7na0y4LSGsWjnOJdeVUxGhlvxVYmjR+iTcdHrUTt4bjVgDfI89kd4Nk2Ihk4hFw87V44oORSH0XBjuYEOkFu1zek7ULfkTajFvbEQlXYZNYoEwBxtAMQ1cE2mNlqIp9CcUl531kuKQ48nU/ub6/cgPRYdW0iXKvFES3NKyHQr5Z8aodT/Tpab81cNUu0jG1DxVBu4bjAhw9XWNEiyTVXZr1/KyZnOhkaXr31EBOjLwS43DEzockv15YaUn6h1INCamjf6uiwbl9XWByfTG8Tl8iTJz2o0jucQD9NOp5JZABEQVaNVUT5yfKmjJ8HKSca+j6vq4gpZjSSPQ553EE6cK2X9aaMsM4mccxD9wBBoEgf3Sg6y1VJxVfk9UdusTxBdPa51s7YY+B0ECgGuim49+qYEh62mPWbpyUNWnx79ydq2ect1Tn0= your email

在这里插入图片描述

创建组

在这里插入图片描述

在这里插入图片描述

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

创建用户

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

组添加用户

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

项目添加成员

在这里插入图片描述

在这里插入图片描述

项目添加组

在这里插入图片描述

在这里插入图片描述

修改普通用户密码

普通用户登录,要重新改密码,root就不用

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

设置完保存
在这里插入图片描述

改权限角色,让用户可以看的权限
在这里插入图片描述
修改为developer角色,只可以读的权限
在这里插入图片描述

测试一下
在这里插入图片描述

查看,主分支的文件可以
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值