以下是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']
参数自动清理过期备份。