Article Title: system time synchronization and ntp service provision. Linux is a technology channel of the IT lab in China. Some basic classification computers, such as desktop applications, Linux system management, kernel research, embedded systems, and open-source systems, will experience errors soon if they are left blank.
This error is reflected in the time stamp of the email sending time, and in the posting time of your forum post. At least I have encountered this problem.
An ntp (network time protocol) server is deployed on the network to provide the current time. We can synchronize the local time with the ntp server time.
The purpose is as follows:
1. Use ntpdate for time correction at startup.
2. during startup, the time correction is performed through ntpd, and the time correction is performed for each client computer at the same time.
3. If the ntp server cannot be found, use local time and synchronize the client.
There are more than 100 ntp servers around the world. Find the one closest to you from the address below.
Http://www.eecis.udel.edu /~ Mills/ntp/clock1a.html I selected two
Clock.nc.fukuoka-u.ac.jp 133.100.9.2.
Clock.tl.fukuoka-u.ac.jp 133.100.11.8.
Steps:
FreeBSD has two standard ntp programs, one of which is ntpdate.
Ntpdate obtains the time point from the ntp server and adjusts the local time point.
# Ntpdate clock.nc.fukuoka-u.ac.jp
9 Oct 18:12:23 ntpdate: step time server 133.100.9.2 offset-19.112674 error of about 19 seconds
Automatic Setting
# Grep ntpdate/etc/defaults/rc. conf>/etc/rc. conf
# Vi/etc/rc. conf
Ntpdate_enable = "YES" # Run ntpdate to sync time on boot (or NO ).
Ntpdate_program = "ntpdate" # path to ntpdate, if you want a different one.
Ntpdate_flags = "clock.nc.fukuoka-u.ac.jp" # Flags to ntpdate (if enabled). Run after restart, of course, the setting is not complete, do not have to rush to start
Another standard ntp program of FreeBSD, ntp
The ntp program provides time points to other PCs while obtaining ntp time points.
Add the ntp. conf file:
I chose two ntp servers for the standard time.
Clock.nc.fukuoka-u.ac.jp 133.100.9.2.
Clock.tl.fukuoka-u.ac.jp 133.100.11.8.
At the same time, it is no problem to specify multiple servers. The system will automatically select a trusted server.
Here, we will directly specify an IP address to avoid extra DNS packet transmission.
Server line server 127.127.1.0 is the address used in local time reference. Then, use fudge to specify the class number as 5 to reduce its priority.
Then, use restrict to specify the corresponding rules for each IP address.
Finally, specify the drift document storage address for wavelength correction. The specific meaning of this command line is unclear. However, if not, the time correction will be slow.
# Vi/etc/ntp. conf
Server 133.100.9.2 # clock.nc.fukuoka-u.ac.jp
Server 133.100.11.8 # clock.tl.fukuoka-u.ac.jp
Server 127.127.1.0
Fudge 127.127.0.1 stratum 5
Restrict default ignore
Restrict 127.0.0.0 mask 255.0.0.0
Restrict 192.168.1.0 mask limit 255.0 noquery nopeer notrust
Restrict 133.100.9.2 noquery
Restrict 133.100.11.8 noquery
Driftfile/etc/ntpd. drift start test
# Ntpd-p/var/run/ntpd. pid
# Tail/var/log/messages
Oct 9 16:46:56 chiwawa ntpd [89409]: ntpd 4.1.0-a Thu Apr 3 08:26:24 GMT 2003 (1)
Oct 9 16:46:56 chiwawa ntpd [89409]: kernel time discipline status 2040
......
Oct 9 16:50:10 chiwawa ntpd [89409]: time set-0.189546 s. You can see similar results.
Run the test
Use the ntpq command to run ntpd.
# Ntpq-p
Remote refid st t when poll reach delay offset jitter
========================================================== ==============================================
* Clock. nc. fukuok. GPS. 1 u 43 64 37 19.067-6.884 10.339
+ Clock. tl. fukuok. GPS. 1 u 36 64 35 19.670-3.259 2.341
LOCAL (0) LOCAL (0) 5 l 45 64 37 0.000 0.000 it takes some time to complete the calibration at the specified time after startup. * Is the first alternate, and + is the second.
After the local time correction is completed, the time correction service can be provided for other PCs.
Automatic Start setting
After completing the preceding settings and confirming that the operation is correct:
# Grep ntpd/etc/defaults/rc. conf>/etc/rc. conf
# Vi/etc/rc. conf
Xntpd_enable = "YES" # Run ntpd Network Time Protocol (or NO ).
Xntpd_program = "ntpd" # path to ntpd, if you want a different one.
Xntpd_flags = "-p/var/run/ntpd. pid" # Flags to ntpd (if enabled ).
Append the above three lines to rc. conf and modify them.
Client PC settings:
UNIX OS
# Vi/etc/ntp. conf
Server [local ntp server IP address] prefer
Driftfile/etc/ntpd. drift
Or append the following content to crontab, so that it is automatically updated every hour.
# Vi/etc/crontab
0 ***** root ntpdate [ntp server IP]>/dev/null 2> & 1
Of course, your host is actually a client, which can also be used. Windows
Seiko's website has downloaded software, but it is Japanese.
Http://www.seiko-p.co.jp/systems/down/time.html
Windows2000 comes with the sntp function. Please study it yourself. BBSURL:
Http://chiwawa.plala.jp/discuz/viewthread.php? Tid = 1027
Link: http://cnfug.org/journal/systems/2004/000038.html