Spring Quartz Scheduler 在 ECS 集群中不工作
Spring Quartz Scheduler not working in ECS Cluster
我正在使用 Spring Boot(2.2.7.RELEASE)、Quartz Scheduler(2.3.2) 开发调度应用程序)。根据负载,应用程序部署在 AWS ECS 集群中,运行 部署在多个 EC2 实例中。我正在使用 AWS RDS Mysql 数据库并创建了所需的石英表。我为石英使用了以下属性文件。
quartz.properties-
org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.threadPriority = 5
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000
应用程序启动日志 -
2020-10-13 23:33:02.853 INFO 938 --- [ main] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.2 created.
2020-10-13 23:33:02.856 INFO 938 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : Using db table-based data access locking (synchronization).
2020-10-13 23:33:02.858 INFO 938 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : JobStoreCMT initialized.
2020-10-13 23:33:02.859 INFO 938 --- [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.2) 'quartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore'
- which supports persistence. and is not clustered.
问题是多个 EC2 实例同时选择同一个作业。因为得到了错误的结果。
有人可以让我知道我在这里缺少什么吗?我需要在这里做什么才能让它在 ECS 集群中工作。每次 Spring 应用程序开始运行时,都会显示日志消息 未聚集。
已解决。我已将以下配置详细信息添加到 application.properties
文件并删除了 quartz.properties
文件
spring.quartz.job-store-type = jdbc
spring.quartz.properties.org.quartz.scheduler.instanceName = MyClusteredScheduler
spring.quartz.properties.org.quartz.jobStore.isClustered = true
spring.quartz.properties.org.quartz.scheduler.instanceId = AUTO
spring.quartz.properties.org.quartz.jobStore.useProperties = true
spring.quartz.properties.org.quartz.jobStore.tablePrefix = QRTZ_
spring.quartz.properties.org.quartz.jobStore.isClustered = true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval = 20000
现在批处理作业在 ECS 中运行良好,一次只有一个作业在 ECS 集群中 运行。
我正在使用 Spring Boot(2.2.7.RELEASE)、Quartz Scheduler(2.3.2) 开发调度应用程序)。根据负载,应用程序部署在 AWS ECS 集群中,运行 部署在多个 EC2 实例中。我正在使用 AWS RDS Mysql 数据库并创建了所需的石英表。我为石英使用了以下属性文件。
quartz.properties-
org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.threadPriority = 5
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000
应用程序启动日志 -
2020-10-13 23:33:02.853 INFO 938 --- [ main] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.2 created.
2020-10-13 23:33:02.856 INFO 938 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : Using db table-based data access locking (synchronization).
2020-10-13 23:33:02.858 INFO 938 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : JobStoreCMT initialized.
2020-10-13 23:33:02.859 INFO 938 --- [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.2) 'quartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore'
- which supports persistence. and is not clustered.
问题是多个 EC2 实例同时选择同一个作业。因为得到了错误的结果。
有人可以让我知道我在这里缺少什么吗?我需要在这里做什么才能让它在 ECS 集群中工作。每次 Spring 应用程序开始运行时,都会显示日志消息 未聚集。
已解决。我已将以下配置详细信息添加到 application.properties
文件并删除了 quartz.properties
文件
spring.quartz.job-store-type = jdbc
spring.quartz.properties.org.quartz.scheduler.instanceName = MyClusteredScheduler
spring.quartz.properties.org.quartz.jobStore.isClustered = true
spring.quartz.properties.org.quartz.scheduler.instanceId = AUTO
spring.quartz.properties.org.quartz.jobStore.useProperties = true
spring.quartz.properties.org.quartz.jobStore.tablePrefix = QRTZ_
spring.quartz.properties.org.quartz.jobStore.isClustered = true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval = 20000
现在批处理作业在 ECS 中运行良好,一次只有一个作业在 ECS 集群中 运行。