离线ntp时间同步安装部署
2021/6/17 10:27:34
本文主要是介绍离线ntp时间同步安装部署,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
注:本部署安装不适用于非红帽系统
目录
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时间同步安装部署的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)
- 2024-05-30【Java】百万数据excel导出功能如何实现
- 2024-05-30我们小公司,哪像华为一样,用得上IPD(集成产品开发)?