当前位置:网站首页>Quartz分布式实现
Quartz分布式实现
2022-08-09 10:45:00 【猿小飞】
1.项目背景
以前项目都是单体项目,在线上环境发布的时候,都是单机版。后来使用的用户越来越多了。就需要做负载了。因为项目在实际使用的过程中,使用到了定时任务。所以就引入了Quartz框架。
2.出现的问题
2.1.时间不同步的问题
[2021-12-14 11:24:45,956 WARN ] [QuartzScheduler_devScheduler_1-localhost.localdomain1639452248424_ClusterManager] (org.springframework.scheduling.quartz.LocalDataSourceJobStore:?) - This scheduler instance (localhost.localdomain1639452248424) is still active but was recovered by another instance in the cluster. This may cause inconsistent behavior.

当我们应用服务器,出现时间不步的时候,另外一台服务器就会报上面这个错误。
注意了,这个错误出现的频率和你定时事务触发的时间有关,比如你的定时任务是1分钟触发一次,这个错误就会一分钟出现一次。
2.1.1.如何解决这个问题--ntp服务
1.安装 ntp服务进行多台服务器时间同步
rpm -qa|grep ntp
使用该命令,来查询是否已经安装了ntp服务。
ntp基础概念:ntp的基础知识 - 90swj - 博客园
2.如果没有安装,则可以通过yun命令进行安装
yum -y install ntp
安装成功后,会在/etc目录下,会有ntp.conf配置文件。
![]()
3.修改配置信息,新增这样的信息:
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap代表允许192.168网段的服务器与此服务器进行时间同步。
参数说明:
用restrict控管权限
nomodify – 用户端不能更改ntp服务器的时间参数
noquery – 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap – 不提供trap远端登陆restrict 192.168.1.129 nomodify notrap nopeer noquery //当前节点IP地址
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap //集群所在网段的网关(Gateway),子网掩码修改前:

主节点:

fudge 127.127.1.0 stratum 10 的含义?
fudge 127.127.1.0 stratum 10通常上面还有一行不能少server 127.127.1.0 意思
是当没有时间同步来源的时候以自身的硬件时钟为准,这里的stratum是代表层级,默认是10。特别注意:这里如果把server都屏蔽掉,运行一段时间后,他不和外部的网络时间同步,也会出现自己跑快的现象。所以解决方法是,我们可以连一下 阿里云的授时网站:
# 国家授时中心
210.72.145.44
# 阿里云
ntp.aliyun.com
s1a.time.edu.cn 北京邮电大学
s1b.time.edu.cn 清华大学
s1c.time.edu.cn 北京大学
s1d.time.edu.cn 东南大学
s1e.time.edu.cn 清华大学
s2a.time.edu.cn 清华大学
s2b.time.edu.cn 清华大学
s2c.time.edu.cn 北京邮电大学
s2d.time.edu.cn 西南地区网络中心
s2e.time.edu.cn 西北地区网络中心
s2f.time.edu.cn 东北地区网络中心
s2g.time.edu.cn 华东南地区网络中心
s2h.time.edu.cn 四川大学网络管理中心
s2j.time.edu.cn 大连理工大学网络中心
s2k.time.edu.cn CERNET桂林主节点
s2m.time.edu.cn 北京大学
ntp.sjtu.edu.cn 202.120.2.101 上海交通大学实际最后我修改的配置文件为:

4.启动服务
service ntpd start4.1.开机自启动
chkconfig ntpd on
5.查看ntp服务器有无和上层ntp连通
ntpstat
6.客户端服务器也安装ntp服务,同时修改配置文件

7.客户端也需要开机自启动
chkconfig ntpd on
微信扫一扫:关注我个人订阅号“猿小飞”,更多精彩文章在这里及时发布:
边栏推荐
- Electron application development best practices
- Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)
- 如何在gazebo进行 joint的转动控制
- Probably 95% of the people are still making PyTorch mistakes
- MNIST机器学习入门
- Oracle数据库常用函数总结
- centos7.5 设置Mysql开机自启动
- 10000以内素数表(代码块)
- Unix Environment Programming Chapter 14 14.8 Memory Mapped I/O
- OpenGL 2.0编程例子
猜你喜欢

史上最小白之《Word2vec》详解

shell脚本实战(第2版)/人民邮电出版社 脚本2 验证输入:仅限字母和数字

想了解API接口,这一篇就够了

CSDN的markdown编辑器语法完整大全

深度学习--神经网络(基础讲解)

OneNote 教程,如何在 OneNote 中搜索和查找笔记?

编解码(seq2seq)+注意机制(attention) 详细讲解

2022年台湾省矢量数据(点线面)及数字高程数据下载

Shell script combat (2nd edition) / People's Posts and Telecommunications Press Script 1 Find programs in the PATH

The common problems in laptops, continuously updated
随机推荐
源代码阅读器项目
Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)
TELNET协议相关RFC
numpy库中的函数 bincount() where() diag() all()
实测办公场景下,国产远程控制软件的表现力如何?(技术解析)
力扣(LeetCode)220. 存在重复元素 III(2022.08.08)
How to quickly get through the mirror release process?
pytorch widedeep文档
Unix Environment Programming Chapter 15 15.9 Shared Storage
String类型的字符串对象转实体类和String类型的Array转List
unix环境编程 第十五章 15.5FIFO
Unix Environment Programming Chapter 15 15.7 Message Queuing
kubernetes中不可见的OOM
百度云大文件网页直接下载
The common problems in laptops, continuously updated
caffe ---make all编辑出错
2022年台湾省矢量数据(点线面)及数字高程数据下载
unix环境编程 第十五章 15.7消息队列
使用cpolar远程连接群晖NAS(创建临时链接)
AQS同步组件-FutureTask解析和用例