极狐GitLab如何配置使用独立数据库?

GitLab 是一个全球知名的一体化 DevOps 平台,很多人都通过私有化部署 GitLab 来进行源代码托管。极狐GitLabhttps://gitlab.cn/install?channel=content\&utm_source=csdn 是 GitLab 在中国的发行版,专门为中国程序员服务。可以一键式部署极狐GitLab。

极狐GitLab 在 5 月 28 日正式发布了 AI 产品驭码CodeRider。现已开启免费试用,登录官网:https://coderider.gitlab.cn/ 即可申请试用。

更多关于极狐GitLabhttps://gitlab.cn 或者 DevOps 的最佳实践,可以关注文末的极狐GitLab 公众号。

学习极狐GitLab 的相关资料:

  1. 极狐GitLab 官网https://gitlab.cn
  2. 极狐GitLab 官网文档https://docs.gitlab.cn
  3. 极狐GitLab 论坛https://forum.gitlab.cn/
  4. 极狐GitLab 安装配置https://gitlab.cn/install
  5. 极狐GitLab 资源中心https://resources.gitlab.cn/
  6. AI 产品驭码CodeRiderhttps://coderider.gitlab.cn/

搜索【极狐GitLab】公众号,后台输入加群 ,备注gitlab,即可加入官方微信技术交流群。

配置使用极狐独立数据库 (BASIC SELF)

本指南记录了如何配置启用极狐独立数据库。

要使用极狐独立数据库,你需要将极狐GitLab 实例配置为使用多数据库支持。

注意事项

极狐独立数据库目前仅支持 Linux 安装包,暂不支持其他如 Docker 等方式的极狐GitLab。

基于 Linux 安装包的配置步骤

  1. 如果是全新安装,请先按照安装方法让极狐GitLab 实例启动运行起来。

  2. 创建配置的备份:

    sudo cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.org

  3. 编辑 /etc/gitlab/gitlab.rb 并保存更改。

    Gitlab JH database settings

    gitlab_rails['databases']['jh']['enable'] = true
    gitlab_rails['databases']['jh']['db_database'] = "gitlabhq_production_jh"
    gitlab_rails['databases']['jh']['db_database_tasks'] = true
    gitlab_rails['databases']['jh']['db_migrations_paths'] = "jh/db/migrate"
    gitlab_rails['databases']['jh']['db_schema_migrations_path'] = "jh/db/schema_migrations"

  4. 设置数据库权限:

    sudo su - gitlab-psql
    /bin/bash
    psql -h /var/opt/gitlab/postgresql -d template1

    在 psql 内执行

    ALTER USER gitlab CREATEDB;

  5. 运行 sudo gitlab-ctl reconfigure 命令

  6. 运行迁移脚本:

    步骤一

    sudo gitlab-rails db:create:jh

    步骤二

    sudo gitlab-rails db:migrate:jh

  7. 检查数据库,确认极狐独立数据库(gitlabhq_production_jh)已经被正确创建好:

    sudo gitlab-psql -c 'select version()'

    PostgreSQL 13.11 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0, 64-bit
    (1 row)

    sudo gitlab-psql -c 'SELECT pg_database.datname as "dbname", pg_database_size(pg_database.datname)/1024/1024 AS size_in_mb FROM pg_database ORDER by size_in_mb DESC'

    在输出列表中应该能看到 gitlabhq_production_jh 出现

    复制代码
          dbname         | size_in_mb

    ------------------------+------------
    gitlabhq_production | 71
    gitlabhq_production_jh | 7

  8. 运行sudo gitlab-ctl restart重启极狐GitLab 实例。

此时,极狐GitLab 实例应该启动并正常运行,且已同时支持主数据库和极狐独立数据库。

极狐独立数据库的备份和恢复

目前暂时不支持gitlab-backup的备份方式。可以使用 PostgreSQL 的工具来进行备份和恢复。

备份极狐独立数据库
复制代码
sudo su - gitlab-psql

$ pg_dump -h /var/opt/gitlab/postgresql -d gitlabhq_production_jh -f /path/to/backup/jhdb_bak.sql
恢复极狐独立数据库
复制代码
sudo su - gitlab-psql

$ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production_jh < /path/to/backup/jhdb_bak.sql
相关推荐
czhaii5 分钟前
STC ai助手单片机工程项目创建实例
数据库·mongodb
山峰哥21 分钟前
数据库性能救星:Explain执行计划深度拆解
服务器·开发语言·数据库·sql·启发式算法
oradh1 小时前
Oracle 11g rac IP地址修改(public ip、vip、scan ip、priviate ip)
数据库·tcp/ip·oracle·rac ip地址修改
YOU OU1 小时前
Redis哨兵 & 集群
数据库·redis·sentinel
小罗水1 小时前
第8章 文档解析与文本切片
数据库·spring·spring cloud·微服务
瞬间&永恒~2 小时前
【MySQL】 主从复制多拓扑搭建实验
运维·数据库·mysql·云原生
han_hanker2 小时前
sql语法 DECODE, CASE ... WHEN
数据库·sql·oracle
井川廊咏2 小时前
vi 删除指定范围的行,不用再反复按 dd
数据库·mysql
龙智DevSecOps解决方案3 小时前
ITSM选型指南 | Jira Service Management Standard vs Cloud Premium 版本对比与升级指导
atlassian·devops·aiops·jira·itsm·智能运维
z落落3 小时前
StudentInfo表 分页、增删改 存储过程+C# WinForm 存储过程实现分页和增删改查
数据库·sql·mysql