默认情况下GitLab的仓库数据存储在/var/opt/gitlab/git-data目录下repositories子目录里面
[root@izuf6fy69k7l7e20jogcj7z ~]# ll /var/opt/gitlab/git-data/ total 4 drwxrws--- 2 git root 4096 Aug 20 09:28 repositories
通过修改配置文件/etc/gitlab/gitlab.rb来自定义git-data目录
1、首先创建自定义存放目录git-data:mkdir /git-data
[root@izuf6fy69k7l7e20jogcj7z ~]# mkdir /git-data [root@izuf6fy69k7l7e20jogcj7z ~]# ll / total 68 lrwxrwxrwx 1 root root 7 Aug 17 14:17 bin -> usr/bin dr-xr-xr-x. 5 root root 4096 Aug 20 00:48 boot drwxr-xr-x 2 root root 4096 Aug 20 00:38 data drwxr-xr-x 19 root root 2980 Aug 20 01:03 dev drwxr-xr-x. 82 root root 4096 Aug 20 01:02 etc drwxr-xr-x 2 root root 4096 Aug 20 21:59 git-data drwxr-xr-x. 2 root root 4096 Apr 11 12:59 home lrwxrwxrwx 1 root root 7 Aug 17 14:17 lib -> usr/lib lrwxrwxrwx 1 root root 9 Aug 17 14:17 lib64 -> usr/lib64 drwx------. 2 root root 16384 Oct 15 2017 lost+found drwxr-xr-x. 2 root root 4096 Apr 11 12:59 media drwxr-xr-x. 2 root root 4096 Apr 11 12:59 mnt drwxr-xr-x. 3 root root 4096 Aug 19 22:32 opt dr-xr-xr-x 153 root root 0 Aug 20 01:03 proc dr-xr-x---. 6 root root 4096 Aug 20 17:45 root drwxr-xr-x 24 root root 640 Aug 20 13:32 run lrwxrwxrwx 1 root root 8 Aug 17 14:17 sbin -> usr/sbin drwxr-xr-x. 2 root root 4096 Apr 11 12:59 srv dr-xr-xr-x 13 root root 0 Aug 20 09:03 sys drwxrwxrwt. 10 root root 4096 Aug 20 17:46 tmp drwxr-xr-x. 13 root root 4096 Aug 17 14:17 usr drwxr-xr-x. 19 root root 4096 Aug 17 14:17 var
2、配置git-data目录属主和属组为git:chown git.git /git-data/
[root@izuf6fy69k7l7e20jogcj7z ~]# chown git.git /git-data/ [root@izuf6fy69k7l7e20jogcj7z ~]# ll / total 68 lrwxrwxrwx 1 root root 7 Aug 17 14:17 bin -> usr/bin dr-xr-xr-x. 5 root root 4096 Aug 20 00:48 boot drwxr-xr-x 2 root root 4096 Aug 20 00:38 data drwxr-xr-x 19 root root 2980 Aug 20 01:03 dev drwxr-xr-x. 82 root root 4096 Aug 20 01:02 etc drwxr-xr-x 2 git git 4096 Aug 20 21:59 git-data drwxr-xr-x. 2 root root 4096 Apr 11 12:59 home lrwxrwxrwx 1 root root 7 Aug 17 14:17 lib -> usr/lib lrwxrwxrwx 1 root root 9 Aug 17 14:17 lib64 -> usr/lib64 drwx------. 2 root root 16384 Oct 15 2017 lost+found drwxr-xr-x. 2 root root 4096 Apr 11 12:59 media drwxr-xr-x. 2 root root 4096 Apr 11 12:59 mnt drwxr-xr-x. 3 root root 4096 Aug 19 22:32 opt dr-xr-xr-x 153 root root 0 Aug 20 01:03 proc dr-xr-x---. 6 root root 4096 Aug 20 17:45 root drwxr-xr-x 24 root root 640 Aug 20 13:32 run lrwxrwxrwx 1 root root 8 Aug 17 14:17 sbin -> usr/sbin drwxr-xr-x. 2 root root 4096 Apr 11 12:59 srv dr-xr-xr-x 13 root root 0 Aug 20 09:03 sys drwxrwxrwt. 10 root root 4096 Aug 20 17:46 tmp drwxr-xr-x. 13 root root 4096 Aug 17 14:17 usr drwxr-xr-x. 19 root root 4096 Aug 17 14:17 var
3、编辑修改配置文件/etc/gitlab/gitlab.rb中的git_data_dirs参数来自定义仓库路径
###! path that doesn't contain symlinks.** git_data_dirs({ "default" => { "path" => "/git-data" } })
配置后需执行命令gitlab-ctl reconfigure重载配置文件
4、重新配置后GitLab会在自定义仓库目录中自动创建一个repositories目录,表示配置成功。
[root@izuf6fy69k7l7e20jogcj7z ~]# ll /git-data/ total 4 drwxrws--- 2 git root 4096 Aug 20 22:26 repositories