【MogDB】将流行的博客系统Halo后端的数据库设置为MogDB

前言

本人的个人博客站点(https://www.darkathena.top )基于Halo博客系统搭建,该博客系统后端可以配置多种数据库,默认为H2,但是最新版已不建议使用H2,而是建议使用mysql/postgresql等数据库。经验证,MogDB数据库也可以作为Halo博客系统的后端数据库。

一、数据库部分

  1. 安装MogDB数据库 (可参考MogDB官方文档)
  2. 修改参数 password_encryption_type=0 ,并添加pg_hba规则 host all all 0.0.0.0/0 md5
  3. 重启数据库
  4. create database halo dbcompatibility ='PG';\c halo
  5. create user halo password 'Halo@123' ;

二、Halo部分

  1. 在服务器创建目录

    mkdir ~/halo
    cd ~/halo

  2. 编写docker-compose.yaml 文件

    version: "3"

    services:
    halo:
    image: halohub/halo:2.12
    container_name: halo
    restart: on-failure:3
    network_mode: "host"
    volumes:
    - ./halo2:/root/.halo2
    privileged: true
    command:
    # 修改为已有的 MogDB 配置
    - --spring.r2dbc.url=r2dbc:pool:postgres://xxx.xxx.xxx.xxx:26000/halo
    - --spring.r2dbc.username=halo
    - --spring.r2dbc.password=Halo@123
    - --spring.sql.init.platform=postgresql
    # 外部访问地址,请根据实际需要修改
    - --halo.external-url=http://localhost:8090/
    # 端口号 默认8090
    - --server.port=8090

  3. 启动

    docker-compose up -d

    [root@ky10-sp3 halo]# docker-compose up -d
    Pulling halo (halohub/halo:2.12)...
    2.12: Pulling from halohub/halo
    d66d6a6a3687: Pull complete
    24423a8d55e9: Pull complete
    51b8de3144a9: Pull complete
    bb0bc9f7ff27: Pull complete
    a7a446bd5cd4: Pull complete
    96e53ae71134: Pull complete
    c14dd449d82c: Pull complete
    4f4fb700ef54: Pull complete
    d703f5e167f0: Pull complete
    dd90520fbfa2: Pull complete
    Digest: sha256:e143e13a2338801b77fecb127a0f4ec7b37bedb79152af62a5e076cdd9eff7bf
    Status: Downloaded newer image for halohub/halo:2.12
    Creating halo ... done

  4. 查看启动日志

    docker-compose logs -f

    [root@ky10-sp3 halo]# docker-compose logs -f
    Attaching to halo
    halo |
    halo | __ __ __
    halo | / / / /___ / /__
    halo | / // / __ `/ / __
    halo | / __ / /
    / / / // /
    halo | /
    / //_,//____/
    halo |
    halo | Version: 2.12.3
    halo | 2024-02-21T19:32:57.067+08:00 INFO 8 --- [ main] run.halo.app.Application : Starting Application v2.12.3 using Java 21.0.2 with PID 8 (/application/BOOT-INF/classes started by root in /application)
    halo | 2024-02-21T19:32:57.071+08:00 INFO 8 --- [ main] run.halo.app.Application : No active profile set, falling back to 1 default profile: "default"
    halo | 2024-02-21T19:32:57.428+08:00 WARN 8 --- [ main] o.s.c.a.AnnotationBeanNameGenerator : Support for convention-based stereotype names is deprecated and will be removed in a future version of the framework. Please annotate the 'value' attribute in @run.halo.app.theme.finders.Finder with @AliasFor(annotation=Component.class) to declare an explicit alias for @Component's 'value' attribute.
    halo | 2024-02-21T19:32:59.353+08:00 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
    halo | 2024-02-21T19:32:59.356+08:00 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data R2DBC repositories in DEFAULT mode.
    halo | 2024-02-21T19:33:00.909+08:00 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1535 ms. Found 1 R2DBC repository interface.
    halo | 2024-02-21T19:33:05.332+08:00 INFO 8 --- [ main] org.pf4j.DefaultPluginStatusProvider : Enabled plugins: []
    halo | 2024-02-21T19:33:05.334+08:00 INFO 8 --- [ main] org.pf4j.DefaultPluginStatusProvider : Disabled plugins: []
    halo | 2024-02-21T19:33:05.339+08:00 INFO 8 --- [ main] org.pf4j.DefaultPluginManager : PF4J version 3.10.0 in 'deployment' mode
    ......
    ......
    halo | 2024-02-21T19:33:17.855+08:00 INFO 8 --- [rReconciler-t-1] r.h.a.e.controller.DefaultController : Controller worker run.halo.app.core.extension.reconciler.AuthProviderReconciler-worker-1 started
    halo | 2024-02-21T19:33:17.857+08:00 INFO 8 --- [rReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Starting request(auth.halo.run/v1alpha1/AuthProvider) synchronizer...
    halo | 2024-02-21T19:33:17.858+08:00 INFO 8 --- [rReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(auth.halo.run/v1alpha1/AuthProvider) synchronizer.
    halo | 2024-02-21T19:33:17.863+08:00 INFO 8 --- [eReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(v1alpha1/Role) synchronizer.
    halo | 2024-02-21T19:33:18.545+08:00 INFO 8 --- [ main] r.h.app.infra.DefaultThemeInitializer : Initialized default theme: Theme(super=AbstractExtension(apiVersion=theme.halo.run/v1alpha1, kind=Theme, metadata=Metadata(name=theme-earth, generateName=null, labels=null, annotations={store.halo.run/app-id=app-KgWqR}, version=0, creationTimestamp=2024-02-21T11:33:18.296538316Z, deletionTimestamp=null, finalizers=null)), spec=Theme.ThemeSpec(displayName=Earth, author=Theme.Author(name=halo-dev, website=https://halo.run), description=Default theme for Halo 2.0, logo=https://halo.run/logo, website=https://github.com/halo-dev/theme-earth, homepage=https://github.com/halo-dev/theme-earth, repo=https://github.com/halo-dev/theme-earth.git, version=1.7.1, require=>=2.8.0, requires=>=2.8.0, settingName=theme-earth-setting, configMapName=theme-earth-configMap, license=null, customTemplates=null), status=null)

三、完成

  1. 打开halo ,进行初始化设置
    http://xxx.xxx.xxx.xxx:8090/

四、相关链接

  1. Halo官网 https://www.halo.run/
  2. Halo安装文档 https://docs.halo.run/getting-started/install/docker-compose
  3. MogDB官网 https://mogdb.io/
  4. MogDB安装文档(PTK) https://docs.mogdb.io/zh/ptk/v1.1/quick-start
相关推荐
激动的兔子2 分钟前
mysqldump使用cmd窗口和powersell窗口导出sql中文乱码的问题
数据库·mysql·mariadb
Mr数据杨16 分钟前
练习题 - Django 4.x Overviewses 框架概述
数据库·sqlite
就这个java爽!27 分钟前
超详细的XML介绍【附带dom4j操作XML】
xml·java·开发语言·数据库·青少年编程·eclipse
_.Switch33 分钟前
Python Web 架构设计与性能优化
开发语言·前端·数据库·后端·python·架构·log4j
Shall#37 分钟前
Innodb存储架构
数据库·mysql·架构
SelectDB技术团队1 小时前
Apache Doris 2.1.6 版本正式发布
大数据·数据库·数据仓库·开源·doris
不会八股文1 小时前
达梦数据库导入xml迁移到达梦数据库大文件导致中断问题解决方案记录?
xml·数据库
拜见老天師1 小时前
SpringBoot中对数据库连接配置信息进行加密处理
数据库·spring boot·后端
萌新小码农‍1 小时前
汽车美容服务管理系统的数据库设计与数据操作
数据库·汽车
x66ccff1 小时前
【linux】快速列出 systemctl 特定名的服务
linux·服务器·数据库