Table of Content

Weight: 3

Description: Candidates should be able to properly maintain the system time and synchronize the clock via NTP.

Key Knowledge Areas:

  • Set the system date and time
  • Set the hardware clock to the correct time in UTC
  • Configure the correct timezone
  • Basic NTP configuration
  • Knowledge of using the pool.ntp.org service
  • Awareness of the ntpq command

Terms and Utilities:

/usr/share/zoneinfo/
/etc/timezone
/etc/localtime
/etc/ntp.conf
date
hwclock
ntpd
ntpdate
pool.ntp.org

NTP

1st layer is stratum 1 provider, get time update from atoomic clock service
stratum 2 get time from stratum 1 via public
to protect stratun 2 overloaded, install stratum 3 on local network

NTP supports up to 256 strata layers

adjust ways

  • slewing, time diff small, adjust less often than it would
  • stepping, time diff large up to 17 mins , adjust more often
  • if time diff larger than 17 mins, insane time, will get average time from other providers

jitter – average deviation between time on local host and time provider

quartz crystal clock drift – slight deviation in frequency due to temperature or manufacturing inconsistencies
/var/lib/ntp/drift/ntp.drift file config # cannot find in new Linux ??

Stepping – More regular than usual updates to local system time
Jitter – The amount of time by which a clock tends to deviate from the provider time between updates
Stratum(layer) – An indication of how close to the atomic clock a server is in NTP hierarchy
Insane time – A time from a provider that’s rejected because it is too different from the local time
Stewing – Less frequent updates than usual to local system time
Drift(offset) – the gradual deviation of a lock from actual time

ntp install

[root@dclab-centos7 etc]# ntpdate -h
ntpdate: unknown option -h
usage: ntpdate [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] [-U username] server ...

ntpdate - set the date and time via NTP
The functionality of this program is now available in the ntpd program. See the -q command line option in the ntpd

replaced by ntptimeset # cannot find in new Linux ??

after config /ntp.conf , need to run ntptimeset to sync with external time server

ntptimeset

then restart ntp

/etc/init.d/ntp-server restart

restart ntp in systemctl

systemctl list-units |grep -i ntp
ntp.service loaded active running LSB: Start NTP daemon
systemctl restart ntp.service
systemctl status ntp.service

start/enable ntp service

systemctl start ntp.service
systemctl enable ntp.service

ntpq

ntpq -p

ntptrace
localhost: stratum 16, offset 0.000000, synch distance 0.000000

timezone

1) global change

root@dclab:/etc/fonts/conf.d# ls -l /etc/localtime
-rw-r--r-- 1 root root 2845 Sep 13 05:56 /etc/localtime

root@dclab:/etc/fonts/conf.d# date
Mon Nov 16 14:41:08 PST 2015

root@dclab:/etc/fonts/conf.d# cd /etc
root@dclab:/etc# ls -ltr localtime
-rw-r--r-- 1 root root 2845 Sep 13 05:56 localtime
root@dclab:/etc# rm localtime
root@dclab:/etc# ln -s /usr/share/zoneinfo/Canada/Eastern localtime
root@dclab:/etc# date
Mon Nov 16 17:43:22 EST 2015

/etc/timezone
America/Los_Angeles

2) user session change

root@dclab:/etc# export TZ=:/usr/share/zoneinfo/Europe/London
root@dclab:/etc# date
Mon Nov 16 22:46:25 GMT 2015

change Local

root@dclab:/etc# env |grep LANG
LANG=en_US.UTF-8

$ iconv -f iso-8859-1 -t UTF-8 umlautfile.txt > umlautfile-utf8.txt

quiz

what changes do you need to make /etc/ntp.conf to config an NTP client ?

V Config local loopback address
V identify one or more local or remtoe time provider servers
X Enable sharing with NTP servers using nopeer and noquery options
X Restrict access to server so that it cannot be modified by external users

Yo've finished configing an NTP client and now want to perform a once-off sync to prevent NTP from rejecting time provided by public time providers. You have already turned off the ntpd.

ntpdate 192.168.15.0

type command you use to access options for choosing a new time zone.

tzselect

You have opened /etc/sysconfig/clock file and want to config system time setting.
Disable the use of UTC

UTC=false

You want to config system clock settings, identify command you use to set system date to Nov 30 2016 and time to 12:34:00
date 113012342016 V  MMDDhhmmYYYY
date 123411302016
date 301120161234

Complete command to sync system clock to hardware clock, display in UTC
/sbin/hwclock --ssytohc --utc

What is stratum 2 NTP server?
X A server on a local network, configed to publish correct time to network clients
V A server that gets time updates from a major time provider
X A server that publishes time that is more than 17 mins off the actual time
X An NTP server that's protected from modification by external users

Which steps do you take to config a Linux system as an NTP client?
V identify NTP servers that should be queried for time updates
X Enable sharing with NTP servers using nopeer and noquery options
V confg Linux to use its own internal clock if external time servers aren't available
X use ntpq -p to view status of ntpd daemon

date

root@dclab-u1504s:/etc# date
Mon Nov 16 10:45:39 EST 2015
root@dclab-u1504s:/etc# date 112214472015
Sun Nov 22 14:47:00 EST 2015