Gitlab 安装 部署 汉化


什么是Gitlab

Gitlab-logo

私有代码仓库
精细化权限配置,让系统更安全
控制用户/用户组是否可以提交到主分支 (PR Push Request)
它使用Ruby语言写成。后来,一些部分用Go语言重写

Gitlab的下载

各大镜像站
官网

Gitlab 和Github/Gittee

image-20240724145943008

Gitlab 应用场景

1. 开源免费,搭建简单,维护成本低,符合中小公司口味 gogs.io
2. 权限管理,实现代码对部分人可见,安全性高
3. 离线同步

Gitlab 架构

image-20240724150233649

image-20240724150310057

安装要求

#系统要求
Ubuntu (16.04/18.04/20.04)
Debian (9/10)
CentOS (7/8)
openSUSE Leap (15.2)
SUSE Linux Enterprise Server (12 SP2/12 SP5)
Red Hat Enterprise Linux (please use the CentOS 
packages and instructions)
#硬件要求
磁盘
存放代码,比代码空间大 磁盘 sas ssd  

CPU 
4 核心 500用户
8 核心 1000用户

内存
4 G内存 500用户
8 G内存 1000用户

安装Gitlab组件

yum localinstall -y gitlab-ce-15.9.3-ce.0.el7.x86_64.rpm

image-20240724150523024

GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`  
#修改gitlab配置文件设置 gitlab external_url 

(gitlab.oldboylinux.cn server_name)
configuration in /etc/gitlab/gitlab.rb file.  #配置文件的路径和名字
Then, you can start your GitLab instance by running 
the following command:
sudo gitlab-ctl reconfigure     #初始化

配置访问url

vim /etc/gitlab/gitlab.rb
external_url 'http:xxxgit.com'

初始化

#使用gitlab.rb文件生成子配置文件
gitlab-ctl reconfigure 
#重启所有gitlab相关文件.
gitlab-ctl restart

gitlab-ctl 命令

gitlab-ctl status       状态
gitlab-ctl start                启动
gitlab-ctl restart              重启
gitlab-ctl stop                 停止


gitlab-ctl 动作 中间件服务   停止其中一个中间件软件

登录查看

设置 密码 即可

image-20240724151623309

Gitlab忘记root密码怎么办

# 连接终端
[root@gitlab ~]# gitlab-ctl status
# 查询root(id为1)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
# 修改密码
user.password='12345678'
=> "12345678"
# 二次确认密码
user.password_confirmation='12345678'
=> "12345678"
# 保存设置
user.save
Enqueued ActionMailer::DeliveryJob (Job ID: 8257f3b0-a7a7-469c-9501-5f04ad803430)
to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change",
"deliver_now", #<GlobalID:0x00007fa9a1e3d238 @uri=#<URI::GID
gid://gitlab/User/1>>
=> true

汉化Gitlab

# 下载汉化包
wget https://gitlab.com/xhang/gitlab/-/archive/12-3-stable-zh/gitlab-12-3-stablezh.tar.gz
# 解压
tar xf gitlab-v12.3.5-zh.tar.gz
# 查看版本是否匹配
cat VERSION
12.3.5
# 停止所有服务
gitlab-ctl stop
ok: down: gitaly: 0s, normally up
ok: down: gitlab-workhorse: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: nginx: 1s, normally up
ok: down: postgresql: 0s, normally up
ok: down: redis: 0s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up
# 覆盖
[root@gitlab ~]# \cp gitlab-v12.3.5-zh/* /opt/gitlab/embedded/service/gitlabrails/
# # gitlab的重新加载配置
gitlab-ctl reconfigure
# 启动所有服务
gitlab-ctl start