۲۴
خرداد
نصب در کلاینت
در سمت کلایت باید سرویس NTP را نصب نمایید:sudo apt-get install ntp
sudo yum install ntp
بعد از نصب در فایل مسیر زیر آدرس سرور را مشخص نمایید:
sudo vim /etc/ntp.conf
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst
بعد از این که تنظیمات انجام شد سرویس را ریست نمایید:
sudo /etc/init.d/ntpd restart
تست کارکرد سرویس
از دستور زیر برای مشاهده کارایی استفاده میکنیم:$ ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
*198.60.22.240 .GPS. 1 u 912 1024 377 0.488 -0.016 0.098
+199.104.120.73 .GPS. 1 u 88 1024 377 0.966 0.014 1.379
-155.98.64.225 .GPS. 1 u 74 1024 377 2.782 0.296 0.158
-137.190.2.4 .GPS. 1 u 1020 1024 377 5.248 0.194 0.371
-131.188.3.221 .DCFp. 1 u 952 1024 377 147.806 -3.160 0.198
-217.34.142.19 .LFa. 1 u 885 1024 377 161.499 -8.044 5.839
-184.22.153.11 .WWVB. 1 u 167 1024 377 65.175 -8.151 0.131
+216.218.192.202 .CDMA. 1 u 66 1024 377 39.293 0.003 0.121
-64.147.116.229 .ACTS. 1 u 62 1024 377 16.606 4.206 0.216
توضیحات موارد بالا
remote- The remote server you wish to synchronize your clock with
refid- The upstream stratum to the remote server. For stratum 1 servers, this will be the stratum 0 source.
st- The stratum level, 0 through 16.
t- The type of connection. Can be "u" for unicast or manycast, "b" for broadcast or multicast, "l" for local reference clock, "s" for symmetric peer, "A" for a manycast server, "B" for a broadcast server, or "M" for a multicast server
when- The last time when the server was queried for the time. Default is seconds, or "m" will be displayed for minutes, "h" for hours and "d" for days.
poll- How often the server is queried for the time, with a minimum of 16 seconds to a maximum of 36 hours. It's also displayed as a value from a power of two. Typically, it's between 64 seconds and 1024 seconds.
reach- This is an 8-bit left shift octal value that shows the success and failure rate of communicating with the remote server. Success means the bit is set, failure means the bit is not set. 377 is the highest value.
delay- This value is displayed in milliseconds, and shows the round trip time (RTT) of your computer communicating with the remote server.
offset- This value is displayed in milliseconds, using root mean squares, and shows how far off your clock is from the reported time the server gave you. It can be positive or negative.
jitter- This number is an absolute value in milliseconds, showing the root mean squared deviation of your offsets.
"." Discarded by table overflow (not used).
"-" Discarded by the cluster algorithm.
"+" Included in the combine algorithm. This is a good candidate if the current server we are synchronizing with is discarded for any reason.
"#" Good remote server to be used as an alternative backup. This is only shown if you have more than 10 remote servers.
"*" The current system peer. The computer is using this remote server as its time source to synchronize the clock
"o" Pulse per second (PPS) peer. This is generally used with GPS time sources, although any time source delivering a PPS will do. This tally code and the previous tally code "*" will not be displayed simultaneously.
IP address- The IP address of the remote peer or server.
.ACST.- NTP manycast server.
.ACTS.- Automated Computer Time Service clock reference from the American National Institute of Standards and Technology.
.AUTH.- Authentication error.
.AUTO.- Autokey sequence error.
.BCST.- NTP broadcast server.
.CHU.- Shortwave radio receiver from station CHU operating out of Ottawa, Ontario, Canada.
.CRYPT.- Autokey protocol error
.DCFx.- LF radio receiver from station DCF77 operating out of Mainflingen, Germany.
.DENY.- Access denied by server.
.GAL.- European Galileo satellite receiver.
.GOES.- American Geostationary Operational Environmental Satellite receiver.
.GPS.- American Global Positioning System receiver.
.HBG.- LF radio receiver from station HBG operating out of Prangins, Switzerland.
.INIT.- Peer association initialized.
.IRIG.- Inter Range Instrumentation Group time code.
.JJY.- LF radio receiver from station JJY operating out of Mount Otakadoya, near Fukushima, and also on Mount Hagane, located on Kyushu Island, Japan.
.LFx.- Generic LF radio receiver.
.LOCL.- The local clock on the host.
.LORC.- LF radio receiver from Long Range Navigation (LORAN-C) radio beacons.
.MCST.- NTP multicast server.
.MSF.- National clock reference from Anthorn Radio Station near Anthorn, Cumbria.
.NIST.- American National Institute of Standards and Technology clock reference.
.PPS.- Pulse per second clock discipline.
.PTB.- Physikalisch-Technische Bundesanstalt clock reference operating out of Brunswick and Berlin, Germany.
.RATE.- NTP polling rate exceeded.
.STEP.- NTP step time change. The offset is less than 1000 millisecends but more than 125 milliseconds.
.TDF.- LF radio receiver from station TéléDiffusion de France operating out of Allouis, France.
.TIME.- NTP association timeout.
.USNO.- United States Naval Observatory clock reference.
.WWV.- HF radio receiver from station WWV operating out of Fort Collins, Colorado, United States.
.WWVB.- LF radio receiver from station WWVB operating out of Fort Collins, Colorado, United States.
.WWVH.- HF radio receiver from station WWVH operating out of Kekaha, on the island of Kauai in the state of Hawaii, United States.
st- The stratum level, 0 through 16.
t- The type of connection. Can be "u" for unicast or manycast, "b" for broadcast or multicast, "l" for local reference clock, "s" for symmetric peer, "A" for a manycast server, "B" for a broadcast server, or "M" for a multicast server
when- The last time when the server was queried for the time. Default is seconds, or "m" will be displayed for minutes, "h" for hours and "d" for days.
poll- How often the server is queried for the time, with a minimum of 16 seconds to a maximum of 36 hours. It's also displayed as a value from a power of two. Typically, it's between 64 seconds and 1024 seconds.
reach- This is an 8-bit left shift octal value that shows the success and failure rate of communicating with the remote server. Success means the bit is set, failure means the bit is not set. 377 is the highest value.
delay- This value is displayed in milliseconds, and shows the round trip time (RTT) of your computer communicating with the remote server.
offset- This value is displayed in milliseconds, using root mean squares, and shows how far off your clock is from the reported time the server gave you. It can be positive or negative.
jitter- This number is an absolute value in milliseconds, showing the root mean squared deviation of your offsets.
علامتهای کناری در remote server:
- Next to the remote server, you'll notice a single character. This character is referred to as the "tally code", and indicates whether or not NTP is or will be using that remote server in order to synchronize your clock. Here are the possible values
- " " Discarded as not valid. Could be that you cannot communicate with the remote machine (it's not online), this time source is a ".LOCL." refid time source, it's a high stratum server, or the remote server is using this computer as an NTP server.
"." Discarded by table overflow (not used).
"-" Discarded by the cluster algorithm.
"+" Included in the combine algorithm. This is a good candidate if the current server we are synchronizing with is discarded for any reason.
"#" Good remote server to be used as an alternative backup. This is only shown if you have more than 10 remote servers.
"*" The current system peer. The computer is using this remote server as its time source to synchronize the clock
"o" Pulse per second (PPS) peer. This is generally used with GPS time sources, although any time source delivering a PPS will do. This tally code and the previous tally code "*" will not be displayed simultaneously.
توضیحات ستون refid:
IP address- The IP address of the remote peer or server.
.ACST.- NTP manycast server.
.ACTS.- Automated Computer Time Service clock reference from the American National Institute of Standards and Technology.
.AUTH.- Authentication error.
.AUTO.- Autokey sequence error.
.BCST.- NTP broadcast server.
.CHU.- Shortwave radio receiver from station CHU operating out of Ottawa, Ontario, Canada.
.CRYPT.- Autokey protocol error
.DCFx.- LF radio receiver from station DCF77 operating out of Mainflingen, Germany.
.DENY.- Access denied by server.
.GAL.- European Galileo satellite receiver.
.GOES.- American Geostationary Operational Environmental Satellite receiver.
.GPS.- American Global Positioning System receiver.
.HBG.- LF radio receiver from station HBG operating out of Prangins, Switzerland.
.INIT.- Peer association initialized.
.IRIG.- Inter Range Instrumentation Group time code.
.JJY.- LF radio receiver from station JJY operating out of Mount Otakadoya, near Fukushima, and also on Mount Hagane, located on Kyushu Island, Japan.
.LFx.- Generic LF radio receiver.
.LOCL.- The local clock on the host.
.LORC.- LF radio receiver from Long Range Navigation (LORAN-C) radio beacons.
.MCST.- NTP multicast server.
.MSF.- National clock reference from Anthorn Radio Station near Anthorn, Cumbria.
.NIST.- American National Institute of Standards and Technology clock reference.
.PPS.- Pulse per second clock discipline.
.PTB.- Physikalisch-Technische Bundesanstalt clock reference operating out of Brunswick and Berlin, Germany.
.RATE.- NTP polling rate exceeded.
.STEP.- NTP step time change. The offset is less than 1000 millisecends but more than 125 milliseconds.
.TDF.- LF radio receiver from station TéléDiffusion de France operating out of Allouis, France.
.TIME.- NTP association timeout.
.USNO.- United States Naval Observatory clock reference.
.WWV.- HF radio receiver from station WWV operating out of Fort Collins, Colorado, United States.
.WWVB.- LF radio receiver from station WWVB operating out of Fort Collins, Colorado, United States.
.WWVH.- HF radio receiver from station WWVH operating out of Kekaha, on the island of Kauai in the state of Hawaii, United States.
دستوری برای چک شدن این که سرور در چه وضعیتی قرار دارد:
sudo yum install ntpدر دستور بالا عبارت last_event اهمیت دارد که آبا سرور در دسترس قرار دارد یا خیر و این که در ستون reach عبارت yes هست یا no (yes یعنی از سرور مورد نظر در حال گرفتن دیتا است)
$ ntpq -c peer -c as -c rl
remote refid st t when poll reach delay offset jitter
==============================================================================
. 10.200.108.62 2 u 20 64 1 0.537 1.660 0.000
. .INIT. 16 u - 64 0 0.000 0.000 0.000
ind assid status conf reach auth condition last_event cnt
===========================================================
1 15488 9024 yes yes none reject reachable 2
2 15489 8011 yes no none reject mobilize 1
associd=0 status=c012 leap_alarm, sync_unspec, 1 event, freq_set,
version="ntpd 4.2.6p5@1.2349-o Fri Jul 22 17:30:51 UTC 2016 (1)",
processor="x86_64", system="Linux/3.16.0-4-amd64", leap=11, stratum=16,
precision=-23, rootdelay=0.000, rootdisp=0.300, refid=INIT,
reftime=00000000.00000000 Mon, Jan 1 1900 3:25:44.000,
clock=dd970af2.38da6724 Sun, Oct 22 2017 15:47:54.222, peer=0, tc=3,
mintc=3, offset=0.000, frequency=5.387, sys_jitter=0.000,
clk_jitter=0.000, clk_wander=0.000
تست دیگری که در سمت کلاینت اطلاعات مفیدی به کاربر میدهد
$ ntpq
ntpq> as
ind assid status conf reach auth condition last_event cnt
===========================================================
1 45592 9444 yes yes none candidate reachable 4
2 45593 962a yes yes none sys.peer sys_peer 2
3 45594 9414 yes yes none candidate reachable 1
ntpq> exit
$