Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The hosts synchronize the time with both NTP and PTP. This is done by the timemaster service during the network configuration section. (see see Network architecture section section).
Three tools are used:

  • chrony synchronize the system clock with NTP. The NTP server can be configured to be on the local network or on the internet.

  • ptp4l synchronize the hardware clock (PHC) with PTP.

  • phc2sys synchronize hardware and system clocks.

Image Added

To see the status of the clocks and the delay with the references, use the command

Code Block
chronyc sources

Logs of timemaster service are also useful to spot any errors:

Code Block
systemctl status timemaster

Virtual machine synchronization

...

  • Load the kernel module ptp_kvm, either automatically at boot or manually.
    This will create the a ptp device in /dev/ptp0 device, which is the PTP clock. To determine which device is the one created by ptp_kvm, simply check that the file /sys/class/ptp/ptp*/clock_name does indeed say "KVM virtual PTP". 
    In this example, our ptp_kvm device is ptp0.

  • Synchronize the system clock with the PTP clock.

This canbe done with the toolphc2sys from the linuxptp package :

Code Block
phc2sys -s /dev/ptp0 -c CLOCK_REALTIME -O 0 -m -q

This command can be put in a systemd service to automatically synchronize the clocks at the start of the VM.

This can also be done inside the chrony configuration file with the command

Code Block
refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0

Grand master simulation

Warning: This section is for test only. It is not intended to be used in a real environment.

...

Code Block
[Global]
slaveOnly                0
gmCapable 1

domainNumber             0

# Announce interval: 1s
logAnnounceInterval      0

# Sync interval: 1 s
logSyncInterval          0

# Pdelay interval: 1 s
logMinPdelayReqInterval  0

# Announce receipt time-out: 3 s (fixed)
announceReceiptTimeout   3

priority1                128
priority2                128
# Default clock class : any specialised clock will be better (ie a GPS Grand Master Clock)
#clockClass              192
network_transport        L2
delay_mechanism          P2P
clockClass 248
clockAccuracy 0xFE
offsetScaledLogVariance 0xFFFF


Info

The PTP clock created by ptp4l will not be synchronized with the current time. So even if your cluster machines are synchronized with each other, the date will be random.
To synchronize the PTP clock with the current time, type this command on the machine that simulate the grand master clock

phc_ctl <ptp_interface> set

Troubleshooting

rogue peer delay response

...