环境:
Linux: CentOS 8
Java:OpenJDK:11
Docker:20.10.22
Docker Compose:1.26.2
连接外部数据库 MySQL:8.0.26
在使用Docker Compose安装Halo2.3.0
使用指令
docker-compose up -d
docker-compose.yaml:
version: "3"
services:
halo:
#升级改下面halo:2.2.0这个版本号就OK!
image: halohub/halo:2.3.0
container_name: halo
restart: on-failure:3
volumes:
#修改/XXX/XXX/halo/.halo2的路径为本地你找的到的路径。里面会存主题、插件、好像还有文章具体我不是很懂,你能找到的位置就好。
#切记冒号后面的不要动!!!
- /root/halo2/.halo2:/root/.halo2
ports:
- "8091:8091"
command:
#修改ysql://XXX.XXX.XXX.XXX:3306/halodb,这是你外部数据库Mysql的地址,替换数据库IP或者域名都可以!端口号(3306)后面的是数据库名。
- --spring.r2dbc.url=r2dbc:pool:mysql://localhost:3306/halodb
#下面sqlroot是数据库用户名,去你数据库里找。
- --spring.r2dbc.username=root
#下面是数据库密码,不用我多BB了吧!
- --spring.r2dbc.password=**** ****
#这是你用的数据库类型,用的啥就写啥!
- --spring.sql.init.platform=mysql
#域名
- --halo.external-url=https://www.yangnanblog.top.com/
#下面两个是初始管理员账号和密码!!写完记住!
- --halo.security.initializer.superadminusername=YangNaner
- --halo.security.initializer.superadminpassword=997210369yn
访问 8091端口被拒绝
使用指令查看运行日志
docker-compose logs -f
报错:
halo | 2023-03-02T16:39:03.908+08:00 INFO 7 --- [gReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.RoleBinding) synchronizer.
halo | 2023-03-02T16:39:03.924+08:00 INFO 7 --- [tReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.content.Comment) synchronizer.
halo | 2023-03-02T16:39:03.945+08:00 INFO 7 --- [nReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.Plugin) synchronizer.
halo | 2023-03-02T16:39:03.960+08:00 INFO 7 --- [yReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.ReverseProxy) synchronizer.
halo | 2023-03-02T16:39:04.009+08:00 INFO 7 --- [gReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.content.Tag) synchronizer.
halo | 2023-03-02T16:39:04.011+08:00 INFO 7 --- [eReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.content.SinglePage) synchronizer.
halo | 2023-03-02T16:39:04.156+08:00 INFO 7 --- [eReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.Role) synchronizer.
halo | 2023-03-02T16:39:04.157+08:00 INFO 7 --- [yReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.content.Reply) synchronizer.
halo | 2023-03-02T16:39:04.158+08:00 INFO 7 --- [eReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.Theme) synchronizer.
halo | 2023-03-02T16:39:04.174+08:00 INFO 7 --- [gReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.AnnotationSetting) synchronizer.
halo | 2023-03-02T16:39:04.175+08:00 INFO 7 --- [gReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.extension.ConfigMap) synchronizer.
halo | 2023-03-02T16:39:04.188+08:00 INFO 7 --- [yReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.content.Category) synchronizer.
halo | 2023-03-02T16:39:04.188+08:00 INFO 7 --- [tReconciler-t-1] r.h.a.e.controller.RequestSynchronizer : Started request(class run.halo.app.core.extension.content.Post) synchronizer.
halo | 2023-03-02T16:39:04.531+08:00 INFO 7 --- [ task-1] run.halo.app.search.IndicesInitializer : Initialize post indices...
halo | 2023-03-02T16:39:04.794+08:00 INFO 7 --- [ task-1] run.halo.app.search.IndicesInitializer : Initialized post indices. Usage: StopWatch 'PostIndicesWatch': running time = 261968726 ns; [rebuild] took 261968726 ns = 100%
halo | 2023-03-02T16:39:10.565+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-snaphosts,and skipped automatically
halo | 2023-03-02T16:39:10.577+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-categories,and skipped automatically
halo | 2023-03-02T16:39:10.577+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-tags,and skipped automatically
halo | 2023-03-02T16:39:10.923+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-snaphosts,and skipped automatically
halo | 2023-03-02T16:39:12.164+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-snaphosts,and skipped automatically
halo | 2023-03-02T16:39:12.178+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-categories,and skipped automatically
halo | 2023-03-02T16:39:12.179+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-tags,and skipped automatically
halo | 2023-03-02T16:39:12.412+08:00 WARN 7 --- [eReconciler-t-1] r.h.a.c.e.service.DefaultRoleService : Detected a cycle in role dependencies: role-template-view-snaphosts,and skipped automatically
错误可能出现在:
我没有进行数据库初始化,我只创建了halodb数据库,数据库内没有任何数据表。
问题:
我该如何解决并让Docker中的Halo2运行起来?