NTP configuration practices

Source: Internet
Author: User

Objective

NTP, Network Time Protocol, is a protocol that is used to synchronize the time of each computer in a network. The consistency and accuracy of time is important, whether it is a private computer or a server cluster that is built at work. In this paper, our company's NTP configuration practice process as an example, the process itself is not complex, the principle part please refer to the extended reading.

Time synchronization is really important.

Update history

June 26, 2015-First draft

Read the original-http://wsgzao.github.io/post/ntp/

Extended Reading

    • ntp-http://www.ntp.org/
    • NTP Server-http://vbird.dic.ksu.edu.tw/linux_server/0440ntp.php
Prepare to check if NTP is installed

If the NTP service is missing, please download the appropriate version of your system from the official

#检查rpm包 rpm -qa | grep ntpntp-4.2.4p8-1.16.1yast2-ntp-client-2.17.14-1.10.14
Manual modification Time

Select the correct time zone and control error within 5 minutes

#查看当前时间Date -Years AMonth ADay Friday -: -: ACstfri June -  -:Wuyi:Panax NotoginsengCst -#手动修改时间 (Month/day/year: minutes: seconds)Date- S "1/1/09 00:01" theYears onMonth onDay Thursdayxx: on:xxCst#手动修改分秒Date- S  +: +
NTP Configure NTP server-side configuration

Service-time Source Select Shanghai Jiaotong University Network Center NTP server address

#NTP服务端系统版本11112
#编辑ntp配置文件202.120.2.101 prefer#server ntp.sjtu.edu.cn#加入自动启动chkconfig ntp on#启动ntp服务service ntp startservice ntp statusservice ntp stop

The complete /etc/ntp.conf configuration file is as follows

################################################################################# #/etc/ntp.conf### # Sample NTP configuration file.# # See package ' Ntp-doc ' for documentation, MINI-HOWTO and FAQs.# # Copyright (c) 1998 S.U.S.E GmbH Fuerth, Germany.### # Author:michael Andres, <[email protected]># # Michael Skibbe, <[email protected]>##################################################################################### # Radio and Modem Clocks by convention has addresses in the# # form 127.127.T.U, where T is the clock type and u are a unit# # number in the range 0-3.### # of these clocks require support in the form of a# # Serial port or special bus peripheral. The particular# # Device is normally specified by adding a soft link# #/dev/device-u to the particular hardware device involved,# # where u correspond to the unit number above.## # # Generic DCF77 clock on serial port (Conrad DCF77)# # ADDRESS:127.127.8.U# # Serial Port:/dev/refclock-u##  # # (Create soft link/dev/refclock-0 to the particular ttys?)### server 127.127.8.0 mode 5 preferServer202.120.2.101Prefer### # undisciplined Local Clock. This was a fake driver intended for backup# # And when no outside source of synchronized time is available.##Server127.127.1.0 # Local Clock (LCL)Fudge127.127.1.0StratumTen# LCL is unsynchronized### # ADD external Servers using# # # RCNTP addserver <yourserver>## ### # Miscellaneous Stuff##Driftfile/var/lib/ntp/drift/ntp.drift# Path for drift fileLogfile/var/log/ntp# alternate log file# logconfig =syncstatus + sysevents# logconfig =all# statsdir/tmp/# directory for statistics files# filegen Peerstats file peerstats type Day enable# filegen Loopstats file loopstats type Day enable# filegen Clockstats file clockstats type Day enable## Authentication Stuff#Keys/etc/ntp.keys# Path for keys fileTrustedkey1                     # define trusted keysRequestkey1                     # Key (7) for accessing server variables# Controlkey # key (6) for accessing server variables
NTP Client Configuration

If no special requirements, the general use of Crontab scheduled task synchronization time

1.crontab Scheduled Task mode configuration

-e00 * * * /usr/sbin/sntp -P no -r  172.16.0.3;hwclock -w

2. Real-time synchronization in service process mode

#编辑客户端配置文件198.16.2.135#启动服务chkconfig ntp onservice ntp restart#如果相差时间较长,请先手动同步198.16.2.135198.16.2.135
Check NTP synchronization Status

NTP protocol for UDP port is 123,offset time offset in milliseconds, note Firewall control policy

#查看服务连接和监听ntp:~# NETSTAT-TLUNP | grep ntpUdp0      0 198.17.1.224:123        0.0.0.0:*28916/NTPD UDP0      0 198.16.2.224:123        0.0.0.0:*28916/NTPD UDP0      0 127.0.0.2:123           0.0.0.0:*28916/NTPD UDP0      0 127.0.0.1:123           0.0.0.0:*28916/NTPD UDP0      0 0.0.0.0:123             0.0.0.0:*28916/NTPD UDP0      0::1:123:::*28916/NTPD UDP0      0FE80:: -: AboutFF:FEB9:123:::*28916/NTPD UDP0      0FE80:: -: AboutFF:FEB9:123:::*28916/NTPD UDP0      0:::123:::*28916/ntpd#查看网络中的NTP服务器, showing the relationship between the client and each serverntp:~# ntpq-pRemote refID St T when poll reach delay offset jitter================================================= =============================*202.120.2.101   202.118.1.81     3U5 1024x768  377  265.748-2.819  16.138LOCAL (0)        . Locl.TenL the    -  377    0.000    0.000   0.001

NTP configuration practices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.