gitlab 使用 备份 恢复 优化

gitlab常用命令

查看运行状态
gitlab-ctl status

启动
gitlab-ctl start

停止
gitlab-ctl stop

重启
gitlab-ctl restart

查看版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

重载配置
gitlab-ctl reconfigure

 

gitlab备份

备份命令

gitlab-rake gitlab:backup:create

打开 /etc/gitlab/gitlab.rb配置文件查看备份参数  默认参数添加#注释状态 可以去掉#自行修改

gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"   # 默认备份文件存在位置

gitlab_rails['backup_keep_time'] = 604800                    #默认备份文件保存时间  7天

可以设置定时任务进行自动备份或者编写脚本实现定时本地备份并同步到其他机器实现备份冗余提高安全性

0 4 * * * root gitlab-rake gitlab:backup:create CRON=1

 

gitlab恢复

首先停止数据传输连接服务

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

恢复数据

gitlab-rake gitlab:backup:restore BACKUP=具体要恢复的文件名

gitlab-ctl restart

 

如果是恢复到新的机器上需要将 gitlab.rb 和 gitlab-secrets.json 手动复制到相应路径下

 

 

gitlab.rb路径:/etc/gitlab/gitlab.rb

gitlab-secrets.json路径:/etc/gitlab/gitlab-secrets.json

 

 

gitlab占用内存过大优化参数

#进程超时时间
unicorn['worker_timeout'] = 60
#进程数
unicorn['worker_processes'] = 10
#进程最小内存 200M
unicorn['worker_memory_limit_min'] = "200 * 1 << 20"
#进程最大内存 300M
unicorn['worker_memory_limit_max'] = "300 * 1 << 20"
#并发数
sidekiq['concurrency'] = 16
#数据库缓存
postgresql['shared_buffers'] = "256MB"
#数据库并发数
postgresql['max_worker_processes'] = 8

转载 https://www.cnblogs.com/jxd283465/p/11525629.html

posted @ 2022-03-31 10:47  45645+56  阅读(329)  评论(0)    收藏  举报