CentOS7下安装GitLab


一、下载地址

Gitlab下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

二、安装

1.配置 yum 源

vi /etc/yum.repos.d/gitlab-ce.repo

复制以下内容:

[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

2.更新本地 yum 缓存

yum makecache

3.安装 GitLab 社区版

自动安装最新版:

yum install gitlab-ce

或下载安装包安装:

rpm -ivh gitlab-ce-15.4.2-ce.0.el7.x86_64.rpm

4.初始化

gitlab-ctl reconfigure

5.修改端口

vi /etc/gitlab/gitlab.rb
nginx['listen_port'] = 8000
vi  /var/opt/gitlab/nginx/conf/gitlab-http.conf
server {
  listen *:80;
  server_name 192.168.1.60;

修改完成后,执行:

gitlab-ctl reconfigure
gitlab-ctl restart

6.修改外部链接

vi /etc/gitlab/gitlab.rb
external_url 'http://gitlab.example.com'

改为:

external_url '192.168.1.60'

7.查看版本号

cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

8.登录

打开浏览器,输入 “http:/192.168.1.60”,进入登录页面:
在这里插入图片描述
默认账户名是 root,密码存放在配置文件:

/etc/gitlab/initial_root_password

该文件将在首次执行 reconfigure 后 24 小时自动删除,文件内容如下:

# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: /XhuNwa6xVjEMYmPthcOFUiaub/8bAWHn2C1jOFjrwI=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

三、备份和恢复

1.备份

修改gitlab的备份路径:

vi /etc/gitlab/gitlab.rb
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"

重启gitlab服务:

gitlab-ctl restart

备份命令:

gitlab-rake gitlab:backup:create

2.恢复

为保证数据的一致性先停止数据连接服务:

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

恢复(注意:不用带_gitlab_backup.tar后缀):

gitlab-rake gitlab:backup:restore BACKUP=/var/opt/gitlab/backups/1575249855

启动刚才停的服务:

gitlab-ctl start unicorn
gitlab-ctl start sidekiq

或重启gitlab服务:

gitlab-ctl restart

四、卸载及重装

1.卸载

(1)停服务

gitlab-ctl stop

(2)卸载

yum remove gitlab-ce

rpm -qa|grep gitlab
rpm -e rpm -e gitlab-ce-15.4.2-ce.0.el7.x86_64.rpm

(3)杀进程

ps -ef|grep gitlab
kill xxx

(4)删文件

rm -rf /opt/gitlab/
rm -rf /var/log/gitlab/
rm -rf /var/opt/gitlab/

find / -name *gitlab*|xargs rm -rf

2.重装问题

(1)postgre 问题

卸载后重装,有时会报 postgre 错误:

data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0

解决方法:
删除 postgre 相关目录后再重新安装:

rm -rf /opt/gitlab/
rm -rf /var/log/gitlab/
rm -rf /var/opt/gitlab/

find / -name *gitlab*|xargs rm -rf

(2)Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received ‘255’

执行 gitlab-ctl reconfigure 还可能出现以下错误:

Running handlers:
There was an error running gitlab-ctl reconfigure:

gitlab_sysctl[kernel.shmmax] (postgresql::enable line 67) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[load sysctl conf kernel.shmmax] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/resources/gitlab_sysctl.rb line 46) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '255'
---- Begin output of sysctl -e --system ----
STDOUT: * Applying /usr/lib/sysctl.d/00-system.conf ...
* Applying /usr/lib/sysctl.d/10-default-yama-scope.conf ...
kernel.yama.ptrace_scope = 0
* Applying /usr/lib/sysctl.d/50-default.conf ...
kernel.sysrq = 16
kernel.core_uses_pid = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.promote_secondaries = 1
net.ipv4.conf.all.promote_secondaries = 1
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
* Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf ...
* Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.shmall.conf ...
* Applying /etc/sysctl.d/90-omnibus-gitlab-kernel.shmmax.conf ...
kernel.shmmax = 17179869184
* Applying /etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf ...
* Applying /etc/sysctl.d/99-sysctl.conf ...
* Applying /etc/sysctl.conf ...
STDERR: sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf": No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.shmall.conf": No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf": No such file or directory
---- End output of sysctl -e --system ----
Ran sysctl -e --system returned 255

解决方法:

touch /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
touch /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf

(3)Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received ‘1’

继续报错:

Running handlers:
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 54) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20221013-16235-vjrh02" ----
STDOUT: rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:48:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
STDERR: 
---- End output of "bash"  "/tmp/chef-script20221013-16235-vjrh02" ----
Ran "bash"  "/tmp/chef-script20221013-16235-vjrh02" returned 1

解决方法:

gitlab-ctl stop
chmod 0755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir
#重启
gitlab-ctl reconfigure
gitlab-ctl restart

(4)ruby_block[wait for redis service socket] action run

执行 gitlab reconfigure 卡在 ruby_block[wait for redis service socket] action run。
解决方法:
执行命令:

systemctl start gitlab-runsvdir
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奔跑吧邓邓子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值