在CentOS上管理GitLab的存储,主要包括配置存储路径、备份和恢复、优化存储库大小等。以下是详细的管理步骤:
默认存储路径:
/var/opt/gitlab/git-data
目录下,仓库存放在子目录 repositories
里面。自定义存储路径:
/etc/gitlab/gitlab.rb
文件来自定义 git-data
的父目录。例如:git_data_dirs({"default" => {"path" => "/data/gitlab-data"}})
gitlab-ctl reconfigure
使配置生效。手动备份:
gitlab-rake gitlab:backup:create
命令手动创建备份。/var/opt/gitlab/backups
目录下。自动备份:
恢复备份:
gitlab-rake gitlab:backup:restore
命令恢复备份。unicorn
和 sidekiq
)。清理未使用的分支和标签:
git branch -d branch_name
git push origin --delete branch_name
git tag -d tag_name
git push origin --delete tag_name
清理大文件和历史记录:
git filter-repo
或 BFG Repo-Cleaner
清理大文件和历史记录。git filter-repo --path path/to/large/file --invert-paths
使用 Git LFS 管理大文件:
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs track "*.psd"
git add .gitattributes
git commit -m "Track PSD files with Git LFS"
git push origin master
压缩存储库:
git gc
命令压缩存储库:git gc --aggressive --prune=now
监控磁盘空间:
/etc/gitlab/gitlab.rb
:prometheus['storage.tsdb.retention.time'] = "2d"
prometheus['enable'] = false
分布式部署与负载均衡:
通过以上步骤,可以有效地管理CentOS上GitLab的存储,确保系统的性能和稳定性。