以下是CentOS上GitLab数据库的管理技巧:
yum install -y postgresql-server postgresql-contrib命令安装,初始化数据库后启动服务并设置为开机自启。/etc/gitlab/gitlab.rb,设置db_host、db_port、db_user、db_password和db_name等参数,确保与PostgreSQL配置一致,然后执行sudo gitlab-ctl reconfigure使配置生效。pg_dump -U postgres gitlabhq_production | gzip > /backup/gitlabhq_production.gz命令备份数据库,同时备份/etc/gitlab/gitlab.rb和/etc/gitlab/gitlab-secrets.json配置文件。crontab -e中。gunzip /backup/gitlabhq_production.gz解压备份文件,再通过pg_restore -U postgres gitlabhq_production恢复数据库。max_connections(根据并发用户数设置)、shared_buffers(设置为内存的25%-40%)、work_mem等参数,提升数据库性能。gitlab_rails['backup_keep_time']参数自动清理过期备份。