[halo-dev/halo]部署很多次都无法启动成功,试过20多次了,实在解决不了了~

2024-03-25 976 views
7
是什么版本出现了此问题?

最新的2.10版本和2.6都没成功

使用的什么数据库?

MySQL 8.x

使用的哪种方式运行?

Docker Compose

发生了什么? image image
version: "3"

services:
  halo:
    image: halohub/halo:2.6.0
    container_name: halo
    restart: on-failure:3
    depends_on:
      halodb:
        condition: service_healthy
    networks:
      halo_network:
    volumes:
      - /volume1/docker/halo/halo2:/root/.halo2
    ports:
      - "8090:8090"
    command:
      - --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3306/halo
      - --spring.r2dbc.username=root
      # MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
      - --spring.r2dbc.password=*
      - --spring.sql.init.platform=mysql
      # 外部访问地址,请根据实际需要修改
      - --halo.external-url=http://localhost:8090/
      # 初始化的超级管理员用户名
      - --halo.security.initializer.superadminusername=admin
      # 初始化的超级管理员密码
      - --halo.security.initializer.superadminpassword=*

  halodb:
    image: mysql:8.0.31
    container_name: halodb
    restart: on-failure:3
    networks:
      halo_network:
    command: 
      - --default-authentication-plugin=mysql_native_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_general_ci
      - --explicit_defaults_for_timestamp=true
    volumes:
      - /volume1/docker/halo/mysql:/var/lib/mysql
      - /volume1/docker/halo/mysqlBackup:/data/mysqlBackup
    ports:
      - "3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
      interval: 3s
      retries: 5
      start_period: 30s
    environment:
      # 请修改此密码,并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
      - MYSQL_ROOT_PASSWORD=*
      - MYSQL_DATABASE=halo

networks:
  halo_network:

version: "3"

services:
  halo:
    image: halohub/halo:2.10
    container_name: halo
    restart: on-failure:3
    depends_on:
      halodb:
        condition: service_healthy
    networks:
      halo_network:
    volumes:
      - ~/docker/halo/halo2:/root/.halo2
    ports:
      - "8090:8090"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 30s
    command:
      - --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3306/halo
      - --spring.r2dbc.username=itangqiao
      # MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
      - --spring.r2dbc.password=
      - --spring.sql.init.platform=mysql
      # 外部访问地址,请根据实际需要修改
      - --halo.external-url=http://localhost:8090/

  halodb:
    image: mysql:8.1.0
    container_name: halodb
    restart: on-failure:3
    networks:
      halo_network:
    command: 
      - --default-authentication-plugin=caching_sha2_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_general_ci
      - --explicit_defaults_for_timestamp=true
    volumes:
      - ~/docker/halo/mysql:/var/lib/mysql
      - ~/docker/halo/mysqlBackup:/data/mysqlBackup
    ports:
      - "3306:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
      interval: 3s
      retries: 5
      start_period: 30s
    environment:
      # 请修改此密码,并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
      - MYSQL_ROOT_PASSWORD=
      - MYSQL_DATABASE=halo

networks:
  halo_network:

回答

3

建议先不要做任何修改直接按照 halo 官方文档 https://docs.halo.run/getting-started/install/docker-compose 提供的 docker-compose.yaml 文件来运行,建议的步骤:

  1. 创建一个 halo 目录并在内部创建 docker-compose.yaml 文件贴上文档给的内容
  2. 只修改下图中标记 12 的密码部分为相同的值,在将 3 的外部访问地址改为你的域名即可,其他的配置不要改

注意其他的配置不要改

image
5

是的,昨天也就是这样部署的,我现在又试一遍,以下是打印日志

8
halodb容器
2023-11-16 07:52:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.1.0-1.el8 started.
2023-11-16 07:52:16+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-11-16 07:52:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.1.0-1.el8 started.
2023-11-16 07:52:16+00:00 [Note] [Entrypoint]: Initializing database files
2023-11-16T07:52:16.696538Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2023-11-16T07:52:16.698312Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-11-16T07:52:16.698402Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.1.0) initializing of server in progress as process 80
2023-11-16T07:52:16.705325Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-11-16T07:52:17.388919Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-11-16T07:52:18.571467Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2023-11-16T07:52:21.757057Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
2023-11-16 07:52:21+00:00 [Note] [Entrypoint]: Database files initialized
2023-11-16 07:52:21+00:00 [Note] [Entrypoint]: Starting temporary server
2023-11-16T07:52:21.791365Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2023-11-16T07:52:22.016164Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-11-16T07:52:22.017919Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.1.0) starting as process 128
2023-11-16T07:52:22.033091Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-11-16T07:52:22.235851Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-11-16T07:52:22.440423Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-11-16T07:52:22.440455Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-11-16T07:52:22.442452Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-11-16T07:52:22.459182Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.1.0'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.
2023-11-16T07:52:22.459290Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2023-11-16T07:52:22.460825Z 0 [System] [MY-015016] [Server] MySQL Server - end.
2023-11-16 07:52:22+00:00 [Note] [Entrypoint]: Temporary server started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2023-11-16 07:52:24+00:00 [Note] [Entrypoint]: Creating database halo

2023-11-16 07:52:24+00:00 [Note] [Entrypoint]: Stopping temporary server
2023-11-16T07:52:24.608913Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.1.0).
2023-11-16T07:52:26.185967Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.1.0)  MySQL Community Server - GPL.
2023-11-16T07:52:26.194733Z 0 [System] [MY-015016] [Server] MySQL Server - end.
2023-11-16 07:52:26+00:00 [Note] [Entrypoint]: Temporary server stopped

2023-11-16 07:52:26+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.

2023-11-16T07:52:26.620646Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2023-11-16T07:52:26.846813Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-11-16T07:52:26.848589Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.1.0) starting as process 1
2023-11-16T07:52:26.855282Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-11-16T07:52:27.060882Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-11-16T07:52:27.263799Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-11-16T07:52:27.263833Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-11-16T07:52:27.265861Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-11-16T07:52:27.288526Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2023-11-16T07:52:27.288600Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.1.0'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
4
failed: Connection refused: halodb/172.18.0.2:3307

请提供你当前使用的 Docker Compose 文件。

6
compose.yaml 文件
version: "3"

services:
  halo:
    image: halohub/halo:2.10
    container_name: halo
    restart: on-failure:3
    depends_on:
      halodb:
        condition: service_healthy
    networks:
      halo_network:
    volumes:
      - ~/docker/halo/halo2:/root/.halo2
    ports:
      - "8090:8090"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 30s
    command:
      - --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3307/halo
      - --spring.r2dbc.username=root
      # MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
      - --spring.r2dbc.password=马赛克
      - --spring.sql.init.platform=mysql
      # 外部访问地址,请根据实际需要修改
      - --halo.external-url=http://马赛克.top

  halodb:
    image: mysql:8.1.0
    container_name: halodb
    restart: on-failure:3
    networks:
      halo_network:
    command: 
      - --default-authentication-plugin=caching_sha2_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_general_ci
      - --explicit_defaults_for_timestamp=true
    volumes:
      - ~/docker/halo/mysql:/var/lib/mysql
      - ~/docker/halo/mysqlBackup:/data/mysqlBackup
    ports:
      - "3307:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
      interval: 3s
      retries: 5
      start_period: 30s
    environment:
      # 请修改此密码,并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
      - MYSQL_ROOT_PASSWORD=马赛克
      - MYSQL_DATABASE=halo

networks:
  halo_network:
5
version: "3"

services:
  halo:
    image: halohub/halo:2.10
    container_name: halo
    restart: on-failure:3
    depends_on:
      halodb:
        condition: service_healthy
    networks:
      halo_network:
    volumes:
      - ~/docker/halo/halo2:/root/.halo2
    ports:
      - "8090:8090"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 30s
    command:
-      - --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3307/halo
+      - --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3306/halo
      - --spring.r2dbc.username=root
      # MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
      - --spring.r2dbc.password=马赛克
      - --spring.sql.init.platform=mysql
      # 外部访问地址,请根据实际需要修改
      - --halo.external-url=http://马赛克.top

  halodb:
    image: mysql:8.1.0
    container_name: halodb
    restart: on-failure:3
    networks:
      halo_network:
    command: 
      - --default-authentication-plugin=caching_sha2_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_general_ci
      - --explicit_defaults_for_timestamp=true
    volumes:
      - ~/docker/halo/mysql:/var/lib/mysql
      - ~/docker/halo/mysqlBackup:/data/mysqlBackup
    ports:
      - "3307:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
      interval: 3s
      retries: 5
      start_period: 30s
    environment:
      # 请修改此密码,并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
      - MYSQL_ROOT_PASSWORD=马赛克
      - MYSQL_DATABASE=halo

networks:
  halo_network:

其中 r2dbc:pool:mysql://halodb:3307/halo 的网络是相对于容器网络,而不是你在下面配置的 3307,3307 是暴露给宿主机的。

建议先不要做任何修改直接按照 halo 官方文档 docs.halo.run/getting-started/install/docker-compose 提供的 docker-compose.yaml 文件来运行,建议的步骤:

上面都已经这样说了,为什么不这样试试呢?理论上我们文档提供的示例无需修改任何东西也可以正常创建容器,一定要修改的话,你也至少应该知道为什么要改。

此外,在你第一个截图的 MySQL 容器发现了这样的日志:

图片

需要确保你映射的 ~/docker/halo/mysql 目录是干净的。

3

可以了~

回复:
  • 试过原本不动的版本,3306提示已占用,所以才改的~
  • 上面3307也同步改了,是之前很多部署也是同步改的,确实这次不应该修改上面。
  • mysql目录可能是没清干净
总结
  1. 删除了三个目录,重新创建。
  2. 将上面的3307改回3306,下面的暴露保持3307:3306
  3. 云服务修改好,立即部署成功。
  4. 群晖部署遇到了一些问题,halodb容器一直处于不健康状态提示,导致halo容器也启不动。要等这个halodb容器运行十几分钟左右,变为正常。然后手动启动一下halo容器,部署成功。
6

有个小疑问,请问这个备份不在这个文件中里?那在哪里呢?这个文件夹又是怎么利用的?我看了官方文档备份与恢复章节好像也没有说明这个,所以不懂就问~

image
1

系统备份和恢复的文档请看:https://docs.halo.run/user-guide/backup

mysqlBackup 和这个备份功能没有任何关系,只是将 MySQL 容器的备份目录给映射出来而已。