文章目录
安装
参考:https://docs.gitlab.com/omnibus/settings/configuration.html
官方:https://about.gitlab.com/install/#ubuntu
sudo apt-get install -y curl openssh-server ca-certificates
sudo apt-get install -y postfix #选择 Internet Site
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo systemctl enable postfix
sudo systemctl start postfix
sudo apt-get install gitlab-ce #安装可用最新版本
#sudo apt-get install gitlab-ce=11.7.5-ce.0 #指定版本号
#由于版本太低,需要指定源进行下载
#sudo apt-get install gitlab-ce=12.9.2-ce.0 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/bionic/main/g/gitlab-ce/
#指定清华源 apt install gitlab-ce方法
sudo vim /etc/apt/sources.list.d/gitlab-ce.list #写入如下内容
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main
#首先信任 GitLab 的 GPG 公钥:
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
sudo apt update
sudo apt list gitlab-ce -a #查看所有的gilab-ce版本
sudo apt-get install gitlab-ce=12.9.2-ce.0 #指定版本安装
sudo vim /etc/gitlab/gitlab.rb
#配置external_url 通常是本机局域网ip的形式,例如:external_url 'http://192.168.1.106:80'
#设置git-data存储位置
#git_data_dirs({ "default" => { "path" => "/mnt/gitlab/git-data" } }) #添加指定存储位置
sudo gitlab-ctl reconfigure
sudo gitlab-ctl stop
#If you already have existing Git repositories in /var/opt/gitlab/git-data you can move them to the new location as follows:
sudo rsync -av /var/opt/gitlab/git-data/repositories /mnt/nas/git-data/ #同步文件内容
sudo gitlab-ctl upgrade
sudo gitlab-ctl start
#设置下次开机自启动gitlab服务
sudo systemctl enable gitlab-runsvdir.service
sudo systemctl start gitlab-runsvdir.service
错误STDERR: sysctl: cannot open “/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf”:
参考:https://www.jianshu.com/p/134c1107114a
错误1:
resql/.s.PGSQL.5432"? [execute] psql: 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
一般是文件权限问题,只要修改/var/opt/gitlab/postgresql权限
sudo chmod 755 /var/opt/gitlab/postgresql
sudo gitlab-ctl reconfigure
错误2:
storage_directory[/var/opt/gitlab/.ssh](gitlab::gitlab-shell line 38)had an error:Mixlib::shellout::shellcommandfailed:
ruby_block[directory resource: xxx_path]
一般是文件权限问题,只要修改xxx_path权限使git用户有读写权限即可
sudo chown git:root xxx_path
错误4
Gitlab更新后gitlab-ctl reconfigure报错rails_migration[gitlab-rails] (gitlab::database_migrations line 51) had an error
方法: https://yangyq.net/2022/05/gitlab-update-error.html
解决方法:
#重起系统
sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,push_event_payloads,event_id,'[["event_id"]\, ["event_id_convert_to_bigint"]]']
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo