ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

离线ntp时间同步安装部署

2021-06-17 09:58:53  阅读:221  来源: 互联网

标签:同步 ntp 离线 notrap restrict etc conf 节点


注:本部署安装不适用于非红帽系统

目录

1.下载包

2.上传&解压

3.安装

4.修改配置文件

5.启动服务

6.测试


部署内网ntp服务是将一个节点时间为参考时间,将其定为master,其余节点为client;手动修改master节点时间为现实时间,client编写crontab定时任务自动同步master节点时间,进而保持集群时间的一致性。

1.下载包

yum install --downloadonly --downloaddir=/tmp ntp

2.上传&解压

上传文件的途径可以有ftp、U盘拷贝等

进入上传节点,开始解压:

tar zxf /绝对路径/ntp.tar.gz -C /希望解压到哪里/

3.安装

安装命令为:

rpm -ivh --force --nodeps /解压路径/*.rpm

4.修改配置文件

修改master节点配置文件,默认地址为:/etc/ntp.conf

执行如下命令:

mv /etc/ntp.conf /etc/ntp.conf.bak

cat>/etc/ntp.conf<<EOF

driftfile /var/lib/ntp/drift

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap  #红色修改为当前IP网段

server 127.127.1.0

fudge 127.127.1.0 stratum 1

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

EOF

 

 

修改client节点配置文件,默认地址为:/etc/ntp.conf

执行如下命令:

mv /etc/ntp.conf /etc/ntp.conf.bak

cat>/etc/ntp.conf<<EOF

driftfile /var/lib/ntp/drift

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

server 192.168.221.131 profer # 红色修改为当前节点IP地址

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

EOF

 

5.启动服务

启动命令:systemctl start ntpd

 

  • 编写crontab

touch /etc/cron.d/ntpd

echo "* */2 * * * root /usr/sbin/ntpdate -u master节点ip >/dev/null 2>&1" > /etc/cron.d/ntpd

6.测试

修改master时间测试client是否可以同步:

 

测试通过!!

标签:同步,ntp,离线,notrap,restrict,etc,conf,节点
来源: https://blog.csdn.net/weixin_39256396/article/details/117981658

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有