gitab
gitab
二、gitlab部署
注意!!!在部署之前要确保环境为纯洁环境,内存尽量给多一些
需要满足cpu:2核 内存:8g (最低配置)
//配置yum源
//关闭防火墙和selinux
//时钟同步
//安装git
[root@ws ~]# yum -y install git//安装依赖包
[root@ws ~]#  yum -y install curl openssh-server openssh-clients postfix cronie  perl//启动postfix服务并设置开机自启
[root@ws ~]# systemctl restart postfix
[root@ws ~]# systemctl enable postfix//下载gitlab的rpm包
[root@ws ~]# cd /usr/src/
[root@ws src]# ls
debug  kernels
[root@ws src]# rz -E
rz waiting to receive.
[root@ws src]# ls
debug  gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm  kernels
[root@ws src]# rpm -qa|grep policy
policycoreutils-2.5-29.el7.x86_64
selinux-policy-targeted-3.13.1-229.el7.noarch
selinux-policy-3.13.1-229.el7.noarch
checkpolicy-2.5-8.el7.x86_64
policycoreutils-python-2.5-29.el7.x86_64//安装gitlab
[root@ws src]# rpm -ivh gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm 
警告:gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...1:gitlab-ce-15.3.3-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 reconfigureFor a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.mdHelp 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-3//修改配置文件
[root@ws src]# vim /etc/gitlab/gitlab.rb 
......  //此处为省略内容
external_url 'http://192.168.110.10'     //将此处设为gitlab的服务器ip地址亦或域名
......  //此处为省略内容
//重载配置文件并重启gitlab
[root@ws src]# gitlab-ctl reconfigure
[root@ws src]# gitlab-ctl restart//查看当前的gitlab版本
[root@ws src]#  head -1 /opt/gitlab/version-manifest.txt 
gitlab-ce 15.3.3
//破解管理员密码
[root@ws src]#  gitlab-rails console -e production
--------------------------------------------------------------------------------Ruby:         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]GitLab:       15.3.3 (c629a47f87f) FOSSGitLab Shell: 14.10.0PostgreSQL:   13.6
-----------------------------------------------------------[ booted in 103.81s ]
Loading production environment (Rails 6.1.6.1)
irb(main):001:0> user = User.where(id:1).first
=> #<User id:1 @root>
irb(main):002:0>  user.password = 'redhat123!'  
=> "redhat123!"
irb(main):003:0> user.password_confirmation = 'redhat123!'
=> "redhat123!"
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit
三、gitlab管理
在浏览器中使用gitlab服务器的ip访问,
192.168.110.10
用户名为root   默认管理员为root
密码为刚刚设置的密码
四、汉化
用户旁边下拉箭头—preferences—localization—language–选择简体中文–保存更改
五、关闭注册功能
由于我们gitlab是私有仓库,一般用户都是由管理员创建和分派的,所以我们需要关闭注册
管理员—设置–通用–注册限制—把已启用注册功能的勾去掉–保存更改
gitlab常用管理操作
项目管理(通常只是创建新项目)
创建成员组(针对某个项目创建一个成员组)
用户管理(此用户乃gitlab用户而非系统用户)
来了新员工,为其添加gitlab用户
员工离职,将其gitlab用户禁用或者删除
1、创建项目
2、在Linux中使用git clone git@192.168.110.10:gitlab-instance-5dba1a04/linux.git 克隆到本地
3、切换到项目中  cd   linux/
4、配置邮件账户和账户
[root@ws ~]# git config --global user.email "root@example.com"
[root@ws ~]# git config --global user.name "root"
5、测试验证
[root@ws ~]# git clone git@192.168.110.10:gitlab-instance-4752bf49/test.git
正克隆到 'test'...
The authenticity of host '192.168.110.10 (192.168.110.10)' can't be established.
ECDSA key fingerprint is SHA256:ns26rOoUG181jGScbaJaHhHwWsVuzNSM8JHsnTQoRgg.
ECDSA key fingerprint is MD5:69:c8:73:82:90:f8:0b:71:cb:ce:ae:22:c1:0b:86:ca.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.110.10' (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
接收对象中: 100% (3/3), done.
[root@ws ~]# ls
anaconda-ks.cfg  initial-setup-ks.cfg  test  公共  模板  视频  图片  文档  下载  音乐  桌面
[root@ws ~]# cd test/
[root@ws test]# ls
README.md
[root@ws test]# touch file1
[root@ws test]# ls
file1  README.md
[root@ws test]# git add file1
[root@ws test]# git commit -m "add file1"
[main 85b036f] add file11 file changed, 0 insertions(+), 0 deletions(-)create mode 100644 file1
[root@ws test]# git push 
warning: push.default 未设置,它的默认值将会在 Git 2.0 由 'matching'
修改为 'simple'。若要不再显示本信息并在其默认值改变后维持当前使用习惯,
进行如下设置:git config --global push.default matching若要不再显示本信息并从现在开始采用新的使用习惯,设置:git config --global push.default simple参见 'git help config' 并查找 'push.default' 以获取更多信息。
('simple' 模式由 Git 1.7.11 版本引入。如果您有时要使用老版本的 Git,
为保持兼容,请用 'current' 代替 'simple' 模式)Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 262 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.110.10:gitlab-instance-4752bf49/test.gitc74fa06..85b036f  main -> main
[root@ws test]# touch file2
[root@ws test]# touch file3
[root@ws test]# ls
file1  file2  file3  README.md
[root@ws test]# git add .     // . 代表所有文件
[root@ws test]# git commit -m "add file"
[main 67b3f05] add file2 files changed, 0 insertions(+), 0 deletions(-)create mode 100644 file2create mode 100644 file3
[root@ws test]# git push
warning: push.default 未设置,它的默认值将会在 Git 2.0 由 'matching'
修改为 'simple'。若要不再显示本信息并在其默认值改变后维持当前使用习惯,
进行如下设置:git config --global push.default matching若要不再显示本信息并从现在开始采用新的使用习惯,设置:git config --global push.default simple参见 'git help config' 并查找 'push.default' 以获取更多信息。
('simple' 模式由 Git 1.7.11 版本引入。如果您有时要使用老版本的 Git,
为保持兼容,请用 'current' 代替 'simple' 模式)Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 260 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@192.168.110.10:gitlab-instance-4752bf49/test.git85b036f..67b3f05  main -> main6、创建分支
[root@ws test]# git branch ws
[root@ws test]# git push origin ws 
Total 0 (delta 0), reused 0 (delta 0)
remote: 
remote: To create a merge request for ws, visit:
remote:   http://192.168.110.10/gitlab-instance-4752bf49/test/-/merge_requests/new?merge_request%5Bsource_branch%5D=ws
remote: 
To git@192.168.110.10:gitlab-instance-4752bf49/test.git* [new branch]      ws -> ws
[root@ws test]# git checkout ws
切换到分支 'ws'
[root@ws test]# touch file5 
[root@ws test]# git add file5
[root@ws test]# git commit -m "add file5"
[ws 7ae04b1] add file51 file changed, 0 insertions(+), 0 deletions(-)create mode 100644 file5
[root@ws test]# git push origin ws
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 226 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: 
remote: To create a merge request for ws, visit:
remote:   http://192.168.110.10/gitlab-instance-4752bf49/test/-/merge_requests/new?merge_request%5Bsource_branch%5D=ws
remote: 
To git@192.168.110.10:gitlab-instance-4752bf49/test.git67b3f05..7ae04b1  ws -> ws