Gitlab的安装

52 阅读2分钟

安装和配置必要的依赖项

yum install dnf

sudo dnf install -y curl policycoreutils openssh-server

#将SSH服务设置成开机自启动
sudo systemctl enable sshd
sudo systemctl start sshd

#安装防火墙
yum install firewalld systemd -y
# Check if opening the firewall is needed with: sudo systemctl status firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

#安装Postfix以发送通知邮件
sudo dnf install postfix
#将postfix服务设置成开机自启动
sudo systemctl enable postfix
#启动postfix
sudo systemctl start postfix

下载并安装软件包

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://git.vliao7.com:8099/" dnf install -y gitlab-ee

配置

vim  /etc/gitlab/gitlab.rb

加载配置

gitlab-ctl reconfigure

重启

gitlab-ctl restart

初始账户: root 密码:5iveL!fe

日志

#查看所有的logs; 按 Ctrl-C 退出
sudo gitlab-ctl tail
#拉取某个指定的日志文件
sudo gitlab-ctl tail nginx/gitlab_error.log

/var/log/gitlab

#gitlab-rails
production.log:其作用是记录gitlab的每次请求的具体信息,包括请求的URL、ip地址、请求类型、以及此次请求所涉及的具体代码、SQL请求以及SQL请求消耗的时间。
application.log:其作用是记录创建用户、创建项目、移动项目等日志。
githost.log:此日志的作用是记录对gitlab服务器的错误请求日志。
sidekiq.log:gitlab中可能存在一些任务需要运行很长时间,因此会选择将这些任务在后台执行,sidekiq.log文件就是用来记录这一类任务的处理信息,此日志文件是一个软连接文件。
#gitlab-shell
gitlab-shell.log:此日志文件位于/home/gitlab/logs/gitlab-shell中,该日志文件的作用是记录执行gitlab命令以及为项目添加ssh权限的日志文件
unicorn/stderr.log:此日志文件位于/home/gitlab/logs/unicorn,该日志文件的作用是记录gitlab的web服务器的相关记录。
repochec.log:此日志文件位于/home/gitlab/logs/prometheus

Gitlab定时自动备份

0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create

gitlab修改备份路径:
修改/etc/gitlab/gitlab.rb文件
gitlab_rails['backup_path'] = '/mnt/backups'

Gitlab恢复

# 停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
# 从1393513186编号备份中恢复
gitlab-rake gitlab:backup:restore BACKUP=1393513186
# 启动Gitlab
sudo gitlab-ctl start

Gitlab迁移
把备份文件拷贝到gitlab的备份目录下,根据上面gitlab恢复步骤即可。

设置简体中文

Gitlab迁移

注意要是同版本

把备份文件拷贝到gitlab的备份目录下,根据上面gitlab恢复步骤即可。

Gitlab更换代码URL

vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

host: 192.168.1.108

gitlab-ctl restart

卸载

sudo gitlab-ctl stop
find / -name gitlab|xargs rm -rfv

Gitlab502

Note that on a single-core server it may take up to a minute to restart Unicorn and Sidekiq. Your GitLab instance will give a 502 error until Unicorn is up again.

It is also possible to start, stop or restart individual components.

sudo gitlab-ctl restart sidekiq 
Unicorn supports zero-downtime reloads. These can be triggered as follows:

sudo gitlab-ctl hup unicorn 
Note that you cannot use a Unicorn reload to update the Ruby runtime.

先等等看,有时候只是启动比较慢 。