The importance of time is self-evident. For some applications, such as kerberos and oraclerac, the system clock needs to be synchronized, while the computer is based on the internal time of the BIOS. Due to the problems of the internal chip of the BIOS, sometimes there may be a difference in BIOS time and UTC time, and in order to avoid the long-run time deviation of the host, ntp should be born. The importance of the master time in this article is self-evident. For some applications, such as kerberos and oracle rac, the system clock needs to be synchronized, while the computer is based on the internal time of the BIOS, due to the internal chip problem of the BIOS, sometimes the BIOS time is different from the UTC time. To avoid the Time deviation caused by the long run of the host time, ntp should be born. This article mainly summarizes the configuration and use of ntp.
1 utc When calculating the time, the most accurate calculation should be the physical Clock calculated using the "Atomic shock period" (Atomic Clock, also known as the Atomic Clock ), this is also defined as the standard Time (International Atomic Time ). We often see Coordinat in UTC.EdThe Universal Time (Standard Time) is usedAtomic ClockThe correct time defined by the benchmark. The UTC Standard Time is mainly the GMT Time Zone! Therefore, the time difference between local time and UTC time is the time difference between local time and GMT time. 2 NTP protocol Network Time ProtoCol) Is a time synchronization protocol that provides services for computer clock over the Internet. It provides a synchronization time mechanism that can adjust time allocation at the speed of light on a large and complex Internet. It uses a time server in a distributed subnet that can return a time design and perform self-organized operations and hierarchical management configuration, the logical clock in the subnet is synchronized to the National Standard Time in wired or wireless mode. In addition, the server can re-allocate the standard time by selecting the algorithm and the time background program through the local route. The Design of NTP brings three products-clock offset, time delay, and difference, all of which are associated with the specified reference clock. The Time Offset indicates the number of deviations generated when the local clock is adjusted to the same as the reference clock. The time delay indicates the delay time when the message is sent to the reference clock within the specified time; the difference represents the maximum deviation from the local clock of the reference clock. Because most server time servers synchronize data through other peer-to-peer time servers, each of these three products has two components: one is determined by peer-to-peer, this part is relative to the reference source of the original standard time; the second is the part measured by the host, which is relative to the peer. Each part is maintained independently in the protocol, which makes error control and subnet management easy. They not only provide precise measurement of the Offset and delay, but also provide a clear maximum error range, so that the user interface can not only determine the time, but also determine the accuracy of the time. NTP is derived from the time protocol and ICMP time sign messages, but its design emphasizes both accuracy and robustness, even when used on multiple gateways, poor latency, and unreliable networks. The latest version is NTPv3, which is compatible with previous versions. 3. Install and set the NTP server 3.1 check required packages [Root @ rhel ~] # Rpm-qa |GrepNtp-main software of ntp, including configuration files and execution files. Ntp-4.2.4p8-2.el6.i686 NtpDate-4.2.4p8-2. el6.i686 Fontpackages-FileSystem-1.41-1.1.el6.noarch [Root @ rhel ~] # Rpm-qa | grep tzdata --TimeZone data mainly provides the display format corresponding to each time zone. Tzdata-java-2010l-1.el6.noarch Tzdata-2010l-1.el6.noarch [Root @ rhel ~] # 3.2 configuration file (1)/etc/ntp. conf The main configuration file of ntp daemon. Different versions may be placed in different directories. RedHat 6 is placed in the/etc directory. You can use loCatE. Root @ rhel ~] #LocateNtp. conf /Etc/. ntp. conf. swp /Etc/ntp. conf /Usr/share/man/man5/ntp.conf.5.gz /Usr/share/system-config-date/ntp. conf. templat (2)/Etc/sysconfig/clock
The default color display time in the configuration file included in the file is read at each opening opportunity. Save the ZONE file as/etc/localtime, which can be seen from the content of the next two files. [Root @ rhel Asia] #Less/Etc/sysconfig/clock # The time zone of the system is defined by the contents of/etc/localtime. # This file is onlyEvalUation by system-config-date, do not rely on its # Contents eLsEwhere. ZONE = "Asia/Shanghai" (END)
(3)/usr/share/zoneinfo directory
Provided by linux, www. linuxIdC.com specifies the time setting files for various major time zones, such as shanghai.
Root @ rhel Asia] #Pwd
/Usr/share/zoneinfo/Asia
[Root @ rhel Asia] # ls-al Shanghai
-Rw-r --. 3 root 405 Aug 31 2010 Shanghai
[Root @ rhel Asia] # sTrIngs Shanghai TZif2
P ~ H
! Iap "^ J
#) Cp $ Gg
TZif2
! Iap
#) Cp
CST-8 (4) [root @ rhel Asia] # strings/etc/localtime TZif2
P ~ H
! Iap "^ J
#) Cp $ Gg
TZif2
! Iap
#) Cp
CST-8
(5)/bin/date
(6)/sbin/hWcLock
Because biso time and system time are separated, after the system time is adjusted by dateCommandWrite the modified time to the bios.
[Root @ rhel Asia] #WhereisHwclock
Hwclock:/sbin/hwclock/usr/share/man/man8/hwclock.8.gz
[Root @ rhel Asia] # hwclock
Sat 17 Sep 2011 06:50:23 pm cst-0.229942 seconds
(7)/usr/sbin/ntpd
Server daemon
(8)/usr/sbin/ntpdate
The client is used to connect to the ntp server.
[Root @ rhel Asia] # ntpdate 0.pool.ntp.org
17 Sep 19:20:32 ntpdate [1, 16649]: step time server 115.181.34.4 offSet6404.317378 sec
(9)/usr/sbin/ntptrace 3.3/etc/ntp. conf configuration file
[Root @ rhel ~] # Less/etc/ntp. conf
#MoreInfoRmAtion about this file, see the man pages
# Ntp. conf (5), ntp_acc (5), ntp_auth (5), ntp_clock (5), ntp_misc (5), ntp_mon (5 ).
Driftfile/var/lib/ntp/drift
# Permit time syNcHronization with our time source, but do not
# Permit the source to query or modify the service on this system.
Restrict default kod nomodify notrap nopeer noquery
Restrict-6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This cocould
# Be tightened as well, but to do so wocould effect some
# The administrative functions.
Restrict 127.0.0.1
Restrict-6: 1
# Hosts on local network are less restricted.
# Restrict 192.168.1.0 mask limit 255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please considerJoinIng the pool (http://www.pool.ntp.org/join.html ).
Server 0.rhel.pool.ntp.org iburst
Server 2.rhel.pool.ntp.org iburst
# Undisciplined Local Clock. This is a fake driver intended for backup
# And when no outside sourceSyncHronized time is available.
# Server 127.127.1.0 # local clock
# Fudge 127.127.1.0 stratum 10
# Enable public key cryptography.
# Crypto
Includefile/etc/ntp/crypto/pw
# Key file containing the keys and key identifiers uSedWhen operating
# With encryption Ric key cryptography.
Keys/etc/ntp/keys
# Specify the key identifier to use with the ntpdc utility.
# Requestkey 8
# Specify the key identifier to use with the ntpq utility.
# Controlkey 8
# Enable writingStatIstics records.
# Statistics clockstats cryptostats loopstats peerstats
Server 0.pool.ntp.org iburst
(END)
Note: Driftfile/Var/lib/ntp/drift# Because the ntp server time is calculated based on the vibration frequency of the bios chip, it is not exactly the same as the ntp server on the upper layer. The error of the two frequencies is recorded in this file.
Ps: it must be a complete path. It cannot be a linked file. You must set the ntp permission to write data. The value unit is one second (ppm ).
[Root @ rhel ntp] # less drift
-395.982
Restrict[Ip] mask [netmask_ip] [parameter]
Parameter parameters mainly include:
Ignore: deny all types of NTP connections.
Nomodify: The time parameter of the ntp server cannot be changed.
Noquery: when ntp is not provided.
Notrap: remote event logging is not supported.
Notrust: rejects unauthenticated clients.
The ip segment does not contain any parameter. By default, this parameter indicates "this ip address or CIDR block is not restricted ".
ServerIp or hostname [prefer] of the ntp server on the upper layer.
[Root @ rhel ntp] # vim/etc/sysconfig/ntpd
# Drop root to id 'ntp: ntp 'by default.
OPTIONS = "-u ntp: ntp-p/var/run/ntpd. pid-g" SYNC_HWCLOCK = yes # time when the BIOS is synchronized.
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