vim /etc/chrony.conf # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). pool 2.centos.pool.ntp.org iburst ###指定时间服务器的地址,可以使用pool开始也可以使用server开始,iburst可以加速初始同步,perfer表示优先 # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift #用来记录时间差异,由于chrony是通过BIOS判断时间的,他会用这个时间与上层时间服务器进行对比,将差异记录下来 # Allow the system clock to be stepped in the first three updates # if its offset is larger than 1 second. makestep 1.0 3 #让chrony可以根据需求逐步进行时间的调整,避免在某些情况下时间差异较大,导致调整时间耗时过长,以上的设置表示在误差时间大于1.0秒的话,前三次使用update更新时间是使用step(分阶段)而不是slew(微调),如果最后一个值是负数的话,如-1则表示随时步进 # Enable kernel synchronization of the real-time clock (RTC). rtcsync #启用内核模式,在内核模式中,系统时间每11分钟会同步到实时时钟(RTC) # Enable hardware timestamping on all interfaces that support it. #hwtimestamp * # 通过使用hwtimestamp指令启用硬件时间戳 # Increase the minimum number of selectable sources required to adjust # the system clock. #minsources 2
# Allow NTP client access from local network. #allow 192.168.0.0/16 #允许同步的网段 # Serve time even if not synchronized to a time source. #local stratum 10 #即时自己未能通过网络时间服务器同步时间,也允许将本地时间作为标准时间同步给其他客户端 # Specify file containing keys for NTP authentication. keyfile /etc/chrony.keys #验证的秘钥文件 # Get TAI-UTC offset and leap seconds from the system tz database. leapsectz right/UTC #从system tz数据库中获取TAI(国际原子时)和UTC(协调世界时)之间的时间偏移及闰秒 # Specify directory for log files. logdir /var/log/chrony #日志文件的位置 # Select which information is logged. #log measurements statistics tracking