美文网首页程序员
gitlab 磁盘空间不足问题处理

gitlab 磁盘空间不足问题处理

作者: 晓明兄 | 来源:发表于2019-10-09 11:32 被阅读0次

    注:一开始没有考虑到把gitlab划分好存储目录,占用系统磁盘,由于gitlab是默认安装的,随着公司代码越来越多,导致gitlab数据目录空间不足.
    由于gitlab通过rpm包安装后,默认存储位置在/var/opt/gitlab/git-data/repositories,通常var分区很小,会打满.

    磁盘空间:

    [root@bogon soft]# df -hT
    Filesystem           Type   Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                         ext4    50G   47G  492M  99% /
    tmpfs                tmpfs  2.9G  784K  2.9G   1% /dev/shm
    /dev/sda1            ext4   477M   41M  411M   9% /boot
    /dev/mapper/VolGroup-lv_home
                         ext4   144G  1.3G  135G   1% /home
    

    可以看出 /home 这个磁盘很大,后面会迁移到 /home 这个磁盘下

    设置存储仓库数据

    默认情况下omnibus-gitlab 将仓库数据存储在 /var/opt/gitlab/git-data目录下,仓库存放在子目录 repositories里面。 以可以通过修改/etc/gitlab/gitlab.rb 的这一行来自定义 git-data 的父目录

    [root@gitlab ~]#  mkdir /home/data/gitlab/git-data   //创建目录
    [root@gitlab ~]#  vim /etc/gitlab/gitlab.rb   //修改默认路径
    # 把注释取消然后指定新的仓库存储位置 
    git_data_dirs({ "default" => { "path" => "/home/data/gitlab/git-data" } })
    

    注: /home/data/gitlab/git-data 这个是手动创建的目录

    使设置生效

    1.没有数据的情况下

    [root@gitlab ~]#  gitlab-ctl stop      //有的需要使用 sudo gitlab-ctl stop
    [root@gitlab ~]# gitlab-ctl reconfigure //使修改生效
    

    2.有数据的情况下

    如果 /var/opt/gitlab/git-data 目录已经存在Git仓库数据, 你可以用下面的命令把数据迁移到新的位置:

    # 准备迁移之前要停止GitLab服务,防止用户写入数据。
    [root@gitlab ~]# gitlab-ctl stop
     
    # 注意 'repositories'后面不带斜杠,而
    # '/home/gitlab-data'后面是有斜杠的。
    [root@gitlab ~]# rsync -av /var/opt/gitlab/git-data/repositories /home/data/gitlab/git-data
     
    # 如果需要修复权限设置,
    # 可运行下面的命令进行修复。
    [root@gitlab ~]# gitlab-ctl reconfigure
     
    # 再次检查下  /home/gitlab-data 的目录. 正常情况应该有下面这个子目录:
    # repositories
    [root@gitlab git-data]# ls /home/data/gitlab/git-data
    repositories
    
    
    # 将 刚刚迁移的包 @hashed 放入到repositories 下
    [root@gitlab git-data]#mv @hashed repositories 
     
    # 完工! 启动GitLab,验证下是否能
    # 通过web访问Git仓库。
    [root@gitlab ~]# gitlab-ctl start
    

    设置存储仓库数据的备用目录

    注意的是:自GitLab 8.10开始,可以通过在/etc/gitlab/gitlab.rb文件中添加下面的几行配置, 来增加多个 git 数据存储目录。

    git_data_dirs({
      "default" => { "path" => "/var/opt/gitlab/git-data" },  //默认存储目录
      "alternative" => { "path" => " /home/gitlab-data" }     //备用存储目录
    })
    

    相关文章

      网友评论

        本文标题:gitlab 磁盘空间不足问题处理

        本文链接:https://www.haomeiwen.com/subject/rswwpctx.html