gitlab的部署_暖春忽见的博客-爱代码爱编程
gitlab的部署
GitLab基本介绍
gitlab是利用Ruby on Rails一个开源的版本管理系统,实现一个自托管的Git项目仓库,可以通过web界面进行访问公开的或者私人项目。
于github类似,gitlab能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,他非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单的聊天程序(Wall)进行交流。
它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。
Git的成员
git:是一种版本控制系统,是一个命令,是一种工具。
git LFS:是大文件存储(LFS)用git中的文本指针替换音频样本,视频,数据集和图形等大文件,同时将文件内容存储在远程服务器 上,如此分开后,能加速存取的速度。
gitlib:是用于实现git功能的开发库。
github:是一个基于git实现的在线代码托管仓库,包含一个网站界面,向互联网开放。
gitLab:是一个基于Git实现的在线代码仓库托管软件,你可以用gitlab自己搭建一个类似于Github一样的系统,一般用于在企业、学校等内部网络搭建git私服
Gitlab的服务构成
Nginx:静态web服务器。
gitlab-shell:用于处理Git命令和修改authorized keys列表。
gitlab-workhorse: 轻量级的反向代理服务器。
logrotate:日志文件管理工具。
postgresql:数据库。
redis:缓存数据库。
sidekiq:用于在后台执行队列任务(异步执行)。
unicorn:An HTTP server for Rack applications,GitLab Rails应用是托管在这个服务器上面的。
部署gitlab
//安装git工具
[root@localhost ~]# yum -y install epel-release git
//安装依赖包
[root@localhost ~]# yum -y install curl openssh-server openssh-clients postfix cronie
[root@localhost ~]# yum -y install policycoreutils-python-utils.noarch
//启动postfix服务并设置开机自启
[root@localhost ~]# systemctl restart postfix
[root@localhost ~]# systemctl enable postfix.service
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@localhost ~]#
#安装
[root@localhost src]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm
#在清华软件网站上下gitlab-ce-15.3.3ce.0.el7.x86_64.rpm
[root@localhost src]# rpm -ivh policycoreutils-python-2.5-34.el7.x86_64.r
pm --nodeps
warning: policycoreutils-python-2.5-34.el7.x86_64.rpm: Header V3 RSA/SHA2
56 Signature, key ID f4a80eb5: NOKEY
Verifying... ################################# [
100%]
Preparing... ################################# [
100%]
Updating / installing...
1:policycoreutils-python-2.5-34.el7################################# [
100%]
[root@localhost src]# 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 Signatu
re, key ID f27eab47: NOKEY
Verifying... ################################# [
100%]
Preparing... ################################# [
100%]
Updating / installing...
1:gitlab-ce-15.3.3-ce.0.el7 #################### ( 60%)
37%)
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
[root@localhost src]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.171.137' //这里改成自己服务器的ip
//重载配置文件并重启gitlab
[root@localhost ~]# gitlab-ctl reconfigure //输入这一行的时候需要等待,如果有报错大概率是缺少依赖包直接下就完事。
yum install glibc-common
yum install -y langpacks-zh_CN
source /etc/locale.conf //我暂时就发现这些问题。
[root@localhost ~]# gitlab-ctl restart
[root@localhost src]# gitlab-ctl restart
ok: run: alertmanager: (pid 238210) 1s
ok: run: gitaly: (pid 238277) 1s
ok: run: gitlab-exporter: (pid 238318) 0s
ok: run: gitlab-kas: (pid 238320) 1s
ok: run: gitlab-workhorse: (pid 238358) 0s
...
#这里如果加载不出来,就加个-e的参数应该就可以出来了
[root@localhost src]# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 15.3.3 (c629a47f87f) FOSS
GitLab Shell: 14.10.0
PostgreSQL: 13.6
------------------------------------------------------------[ booted in 28.27s ]
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 = '123456789'
=> "123456789" //密码必须是八位数以上
irb(main):003:0> user.password_confirmation = '123456789'
=> "123456789"
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit //退出
[root@localhost src]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 1024 127.0.0.1:8151 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 128 127.0.0.1:8092 0.0.0.0:*
LISTEN 0 511 0.0.0.0:8060
...