当前位置:网站首页>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 start
4.1.开机自启动
chkconfig ntpd on
5.查看ntp服务器有无和上层ntp连通
ntpstat
6.客户端服务器也安装ntp服务,同时修改配置文件
7.客户端也需要开机自启动
chkconfig ntpd on
微信扫一扫:关注我个人订阅号“猿小飞”,更多精彩文章在这里及时发布:
边栏推荐
- 用Word写代码
- Database connection operations for MySQL and MyEclipse
- 山东招远通报星童幼儿园食品安全问题最新调查情况
- Cpolar内网穿透的面板功能介绍
- caffe ---make all编辑出错
- 机器学习--朴素贝叶斯(Naive Bayes)
- 备战金三银四:如何成功拿到阿里offer(经历+面试题+如何准备)
- 【原创】JPA中@PrePersist和@PreUpdate的用法
- 学习NET-SNMP之二-----------VisualStudio编译Net-SNMP
- TensorFlow—计算梯度与控制梯度 : tf.gradients和compute_gradients和apply_gradients和clip_by_global_norm控制梯度
猜你喜欢
自从我使用HiFlow场景连接器后,在也不用担心成为“落汤鸡”了
深度学习--生成对抗网络(Generative Adversarial Nets)
对话跨国消费品牌DPO:数据安全合规从何做起?8.11直播见!
在webgis中显示矢量化后的风险防控信息
jmeter BeanShell 后置处理器
【原创】解决阿里云oss-browser.exe双击没反应打不开,提供一种解决方案
强化学习 (Reinforcement Learning)
Transformer+Embedding+Self-Attention原理详解
Since I use the HiFlow scene connector, I don't have to worry about becoming a "dropper" anymore
Oracle数据库常用函数总结
随机推荐
[Original] Usage of @PrePersist and @PreUpdate in JPA
activemq 消息持久化
研发需求的验收标准应该怎么写? | 敏捷实践
Unix Environment Programming Chapter 15 15.9 Shared Storage
WUSTOJ:n个素数构成等差数列
unix环境编程 第十四章 14.8 存储映射I/O
CSDN的markdown编辑器语法完整大全
jvm-类加载系统
ESIM(Enhanced Sequential Inference Model)- 模型详解
解决1.tensorflow运行使用CPU不使用GPU 2.tensorflow环境下的GPU版本号 3.tensorflow和cuda以及cudnn版本对应问题 4.查看cuda和cudnn版本
Solve the ali cloud oss - the original 】 【 exe double-click response can't open, to provide a solution
caffe ---make all编辑出错
15.8 the semaphore Unix environment programming chapter 15
Transformer+Embedding+Self-Attention原理详解
Shell script combat (2nd edition) / People's Posts and Telecommunications Press Script 2 Validate input: letters and numbers only
OpenSSF's open source software risk assessment tool: Scorecards
pip common commands and changing source files
unix系统编程 第十五章 15.2管道
activemq message persistence
百度云大文件网页直接下载