其他分享
首页 > 其他分享> > 离线ntp时间同步安装部署

离线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

 

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