Bookmark this page

Guided Exercise: Configuring NTP with Chrony

In this exercise, you will adjust the time zone on a server and ensure that its system clock is synchronized with an NTP time source, using Chrony.

Outcomes

Students should be able to configure the servera system to use the time zone appropriate for Haiti and configure chronyd on servera to use the NTP server running on classroom.example.com as the time source.

Log in to workstation as student using student as the password. On workstation, run the lab core-chrony start command to verify that the environment is ready and to prepare the systems for the exercise.

[student@workstation ~]$ lab core-chrony start
  1. Your servera machine has been relocated to Haiti. Set the appropriate time zone and verify your work.

    1. Log in to servera then become the root user.

      [student@workstation ~]$ ssh servera
      [student@servera ~]$ sudo -i
      [root@servera ~]# 
    2. Identify the correct time zone for Haiti.

      [root@servera ~]# tzselect
      Please identify a location so that time zone rules can be set correctly.
      Please select a continent, ocean, "coord", or "TZ".
       1) Africa
       2) Americas
      ...output omitted...
      #? 2
      Please select a country whose clocks agree with yours.
      ...output omitted...
      10) Canada            28) Haiti              46) Suriname
      11) Caribbean NL      29) Honduras           47) Trinidad & Tobago
      ...output omitted...
      #? 28
      
      The following information has been given:
      
        Haiti
      
      Therefore TZ='America/Port-au-Prince' will be used.
      Selected time is now:  Fri Feb 15 01:24:44 EST 2019.
      Universal Time is now: Fri Feb 15 06:24:44 UTC 2019.
      Is the above information OK?
      1) Yes
      2) No
      #? 1
      
      You can make this change permanent for yourself by appending the line
        TZ='America/Port-au-Prince'; export TZ
      to the file '.profile' in your home directory; then log out and log in again.
      
      Here is that TZ value again, this time on standard output so that you
      can use the /usr/bin/tzselect command in shell scripts:
      America/Port-au-Prince
    3. Change the time zone to America/Port-au-Prince.

      [root@servera ~]# timedatectl set-timezone America/Port-au-Prince
    4. Retrieve the time zone set on servera to verify your work.

      [root@servera ~]# timedatectl
                     Local time: Fri 2019-02-15 01:45:31 EST
                 Universal time: Fri 2019-02-15 06:45:31 UTC
                       RTC time: Fri 2019-02-15 06:47:25
                      Time zone: America/Port-au-Prince (EST, -0500)
      System clock synchronized: no
                    NTP service: inactive
                RTC in local TZ: no
  2. Enable NTP synchronization on the servera system and use classroom.example.com as the time source.

    1. Configure chronyd to synchronize the time on servera with classroom.example.com. Edit /etc/chrony.conf to include the following configuration file excerpt:

      # Use public servers from the pool.ntp.org project.
      # Please consider joining the pool (http://www.pool.ntp.org/join.html).
      # pool 2.rhel.pool.ntp.org iburst
      server classroom.example.com iburst
      ...output omitted...
    2. Start and enable the chronyd service, turning on the NTP synchronization on servera.

      [root@servera ~]# timedatectl set-ntp true
  3. Confirm that the clock on servera is synchronized with classroom.example.com.

    1. Verify the clock synchronization status.

      [root@servera ~]# timedatectl
      ...output omitted...
      System clock synchronized: yes
      ...output omitted...
      
    2. Confirm that classroom.example.com is the time source for the clock synchronization on servera.

      [root@servera ~]# chronyc sources -v
      210 Number of sources = 1
      
        .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
       / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
      | /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
      ||                                                 .- xxxx [ yyyy ] +/- zzzz
      ||                                                /   xxxx = adjusted offset,
      ||         Log2(Polling interval) -.             |    yyyy = measured offset,
      ||                                  \            |    zzzz = estimated error.
      ||                                   |           |
      MS Name/IP address         Stratum Poll Reach LastRx Last sample
      ===============================================================================
      ^* classroom.example.com         8   6    37    51   -25ns[-703us] +/-  128us
    3. Log off from servera.

      [root@servera ~]# exit
      [student@servera ~]$ exit
      [student@workstation ~]$ 

Finish

On workstation, run lab core-chrony finish to clean up any resources created for this exercise.

[student@workstation ~]$ lab core-chrony finish

This concludes the guided exercise.

Revision: rh354-8.0-0e36520