[英]change the data directory gitlab to store repos elsewhere
my basic disk is full for my gitlab installation, is it possible to move the repositories and their data to some other folder and make sure that the upcoming push's data is sent to those directories? 我的基本磁盘已满,我的gitlab安装,是否可以将存储库及其数据移动到其他文件夹,并确保即将推送的数据被发送到这些目录?
I tried stopping the gitlab and copying over the entire folder, but to no avail. 我试着停止gitlab并复制整个文件夹,但无济于事。 PS - I am not an IT guy, I am just pitching in to see how could we get out of this issue;
PS - 我不是一个IT人员,我只是在投资,看看我们怎么能摆脱这个问题; so please be verbose when answering.
请回答时请详细说明。
Just updating in case people still refer to this. 只是更新以防人们仍然参考这个。 From the GitLab documentation :
从GitLab 文档 :
By default, omnibus-gitlab stores the Git repository data under
/var/opt/gitlab/git-data
.默认情况下,omnibus-gitlab将Git存储库数据存储在
/var/opt/gitlab/git-data
。 The repositories are stored in a subfolderrepositories
.存储库存储在子文件夹
repositories
。 You can change the location of thegit-data
parent directory by adding the following line to/etc/gitlab/gitlab.rb
.您可以通过
/etc/gitlab/gitlab.rb
添加到/etc/gitlab/gitlab.rb
来更改git-data
父目录的位置。git_data_dirs({"default" => "/mnt/nas/git-data"})
Starting from GitLab 8.10 you can also add more than one git data directory by adding the following lines to
/etc/gitlab/gitlab.rb
instead.从GitLab 8.10开始,您还可以通过
/etc/gitlab/gitlab.rb
添加到/etc/gitlab/gitlab.rb
来添加多个git数据目录。git_data_dirs({ "default" => "/var/opt/gitlab/git-data", "alternative" => "/mnt/nas/git-data" })
Note that the target directories and any of its subpaths must not be a symlink.
请注意,目标目录及其任何子路径都不能是符号链接。
Run
sudo gitlab-ctl reconfigure
for the changes to take effect.运行
sudo gitlab-ctl reconfigure
以使更改生效。If you already have existing Git repositories in
/var/opt/gitlab/git-data
you can move them to the new location as follows:如果您已经在
/var/opt/gitlab/git-data
有现有的Git存储库,则可以将它们移动到新位置,如下所示:# Prevent users from writing to the repositories while you move them. sudo gitlab-ctl stop # Note there is _no_ slash behind 'repositories', but there _is_ a # slash behind 'git-data'. sudo rsync -av /var/opt/gitlab/git-data/repositories /mnt/nas/git-data/ # Fix permissions if necessary sudo gitlab-ctl reconfigure # Double-check directory layout in /mnt/nas/git-data. Expected output: # gitlab-satellites repositories sudo ls /mnt/nas/git-data/ # Done! Start GitLab and verify that you can browse through the repositories in # the web interface. sudo gitlab-ctl start
Much easier solution for new installs with the version > 7.14.1 : 对于版本> 7.14.1的新安装,更简单的解决方案:
Open the gitlab.rb configuration file 打开gitlab.rb配置文件
sudo nano /etc/gitlab/gitlab.rb
Search for git_data_dir
, uncomment the line and set your directory here, eg 搜索
git_data_dir
,取消注释该行并在此处设置您的目录,例如
git_data_dir "/storage/data/gitlab/git-data"
Save the file and reconfigure Gitlab: 保存文件并重新配置Gitlab:
sudo gitlab-ctl reconfigure
I just moved my gitlab repositories folder from one directory to another, might be useful for someone (do this quickly at a quiet time or stop gitlab beforehand!) 我只是将我的gitlab存储库文件夹从一个目录移动到另一个目录,可能对某人有用(在安静的时候快速完成或者事先停止gitlab!)
Assuming you have a standard install the steps are 假设您有标准安装步骤
cp -ar SOURCE DESTINATION
cp -ar SOURCE DESTINATION
sudo /etc/init.d/gitlab restart
sudo /etc/init.d/gitlab restart
If you're getting the cannot find repo
error in GitLab after running the above steps. 如果您在运行上述步骤后
cannot find repo
在GitLab中cannot find repo
错误。 Run this command. 运行此命令。
gitlab-rake cache:clear RAILS_ENV=production
This should fix the issue if your pathing is correct. 如果您的路径正确,这应该可以解决问题。
In my case, I needed to move a repository from the default
storage to storage1
就我而言,我需要将存储库从
default
存储移动到storage1
If you load the project's general setting, it show the project number, for example 37
: 如果加载项目的常规设置,则显示项目编号,例如
37
:
sudo gitlab-rails console
irb(main):012:0> p37 = Project.find(37)
irb(main):009:0> p37.repository_storage
=> "default"
irb(main):010:0> p37.repository_storage = 'storage1'
irb(main):011:0> p37.save
=> true
irb(main):012:0> # <ctrl>+d to send EOF and exit
clearing the cache is probably a good idea too 清除缓存也是一个好主意
you need append this small config bellow: 你需要附加这个小配置:
git_data_dirs({
"default" => {
"path" => "/srv/gitlab/git-data"
}
})
And 和
rsync -av /var/opt/gitlab/git-data/* /srv/gitlab/git-data/.
chown -R git:git /srv/gitlab/git-data/
sudo gitlab-ctl reconfigure
Done. 完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.