ntp网络时间服务器(网络时钟同步)客户端与服务器端设置方法说明

ntp网络时间服务器(网络时钟同步)客户端与服务器端设置方法说明
更多资料参考——安徽京准——ahjzsz.COM
为了让文件上的时间戳保持一致,我们需要对服务器进行ntp时间同步。
ntp服务器分服务器端以及客户端(C-S)

操作步骤
1 准备工作
两个节点都需要执行
首先安装ntp

yum install ntp
安装完毕之后,启动服务

systemctl start ntpd.service
设置开机自启动

systemctl enable ntpd.service
服务器端设置:
ntp服务端设置
第一台服务器192.168.0.104,作为ntpserver,将他设置为同步外网时间(ntpd服务开启默认就同步了)。
但是得设置允许内网网段可以连接它,将它作为内网的时间同步服务器,所以需要一个简单配置。
修改/etc/ntp.conf文件,添加如下信息,表示允许210网段来同步此服务器

vim /etc/ntp.conf
restrict 192.168.0.0 mask 255.255.255.0 #添加此行

设置后,重启ntpd服务,用ntpstat来检查效果【大概几秒钟就可以看到效果】

systemctl restart ntpd
ntpstat
ntp客户端设置
192.168.0.107 作为ntpclient,将他设置为同步上面的ntpserver,同样需要一个简单配置,分别在两个节点上做如下配置!
修改/etc/ntp.conf文件,注释掉外网时间服务器,添加本地服务器即可

vim /etc/ntp.conf
server 192.168.0.104 #添加此行

server 0.centos.pool.ntp.org iburst #以下四行注释掉
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
设置后,重启ntpd服务,用ntpstat来检查效果【大概需要等十五分钟,看到效果】

systemctl restart ntpd
ntpstat

作者:Firetheworld
链接:https://www.jianshu.com/p/594a02194034
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

发布了22 篇原创文章 · 获赞 2 · 访问量 4386

猜你喜欢

转载自blog.csdn.net/weixin_44990608/article/details/103783708