Gitlab下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
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
yum makecache
自动安装最新版:
yum install gitlab-ce
或下载安装包安装:
rpm -ivh gitlab-ce-15.4.2-ce.0.el7.x86_64.rpm
gitlab-ctl reconfigure
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
vi /etc/gitlab/gitlab.rb
external_url 'http://gitlab.example.com'
改为:
external_url '192.168.1.60'
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
打开浏览器,输入 “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.
修改gitlab的备份路径:
vi /etc/gitlab/gitlab.rb
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
重启gitlab服务:
gitlab-ctl restart
备份命令:
gitlab-rake gitlab:backup:create
为保证数据的一致性先停止数据连接服务:
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
gitlab-ctl stop
yum remove gitlab-ce
或
rpm -qa|grep gitlab
rpm -e rpm -e gitlab-ce-15.4.2-ce.0.el7.x86_64.rpm
ps -ef|grep gitlab
kill xxx
rm -rf /opt/gitlab/
rm -rf /var/log/gitlab/
rm -rf /var/opt/gitlab/
或
find / -name *gitlab*|xargs rm -rf
卸载后重装,有时会报 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
执行 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
继续报错:
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 `'
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
执行 gitlab reconfigure 卡在 ruby_block[wait for redis service socket] action run。
解决方法:
执行命令:
systemctl start gitlab-runsvdir