NTP时间同步

2019-01-09  本文已影响0人  章鱼哥小杰

NTPD服务器
Network Time Protocol

作用:为网络中的主机授时,同步的时间在2min-10min,需要看主板上面的硬件的性能

一、时间服务器的重性
ntp 123/udp

二、配置时间服务器

rpm -q ntp

ntp-4.2.4p8-3.el6.x86_64

NTP Server配置示例:

vim /etc/ntp.conf

restrict default nomodify //不允许客户端登录,也不允许客户端修改
server 127.127.1.0 //使用本地的bios时间,自己跟自己同步
fudge 127.127.1.0 stratum 10 //定义级别,范围0-16,越小越精准

注释:时间服务器要读取本地的bios时间,所以会延迟5min左右才能同步成功

systemctl restart ntpd

systemctl enable ntpd

查看server的同步的状态:

ntpstat

unsynchronised
time server re-starting
polling server every 64 s

ntpstat

synchronised to local net at stratum 11
time correct to within 949 ms
polling server every 64 s

三、配置NTP客户端
方法一:

ntpdate -b 172.16.110.1 //手动时间同步 -b加速初始化同步

crontab -e

01 * * * * ntpdate 172.16.110.1

方法二:

vim /etc/ntp.conf //自动同步

server 172.16.110.1
fudge 172.16.110.1 stratum 5

systemctl restart ntpd

systemctl enable ntpd

ntpq -p

 remote           refid               st t when poll reach   delay   offset  jitter

==========================================================================
172.16.110.1 LOCAL(0) 11 u 36 64 3 0.405 0.046 0.022

date //系统时钟

Mon Jan 20 14:44:25 CST 2014

hwclock //主板硬件时钟

Mon 20 Jan 2014 02:44:36 PM CST -0.145485 seconds

hwclock --systohc //将系统时间同步到硬件上

hwclock --hctosys //将硬件时间同步到系统上

上一篇下一篇

猜你喜欢

热点阅读