centos

GitLab在CentOS上的数据库选择与配置

小樊
42
2025-08-06 11:55:25
栏目: 智能运维

一、数据库选择

二、配置步骤(以PostgreSQL为例)

  1. 安装数据库

    sudo yum install -y postgresql-server
    sudo postgresql-setup initdb
    sudo systemctl start postgresql
    sudo systemctl enable postgresql
    
  2. 创建数据库和用户

    sudo -u postgres psql
    CREATE DATABASE gitlabhq_production;
    CREATE USER gitlab WITH PASSWORD 'your_password';
    GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production TO gitlab;
    \q
    
  3. 配置GitLab连接
    编辑 /etc/gitlab/gitlab.rb

    gitlab_rails['db_adapter'] = 'postgresql'
    gitlab_rails['db_host'] = 'localhost'
    gitlab_rails['db_port'] = 5432
    gitlab_rails['db_user'] = 'gitlab'
    gitlab_rails['db_password'] = 'your_password'
    gitlab_rails['db_name'] = 'gitlabhq_production'
    
  4. 重启GitLab

    sudo gitlab-ctl reconfigure
    sudo gitlab-ctl restart
    

三、注意事项

0
看了该问题的人还看了