Context
Aerospike recommends synchronized time across nodes in a cluster in order to make sure objects expiration is handled consistently. Also time synchronization is required when using Cross datacenter replication to ensure proper replication of expirable data. In addition, log analysis and error debugging is less error prone when server clocks are aligned. Consider configuring NTP to start automatically on distributions that do not enable NTP by default.Method
1. Install NTP
Ubuntu and Debian systems
sudo apt install ntp
Centos and RHEL systems
yum -y install ntp
RHEL 8 on AWS
sudo yum -y install ntpstat sudo ntpstat start ntp
2. Start and enable the service
sudo ntpd start ntp sudo ntpd enable ntp sudo ntp status ntp
3. Edit config file with local time servers:
vi /etc/ntp.conf
Or use ntpdate to configure using centos.pool.ntp.org or your local time servers.
sudo ntpdate -u -s 0.centos.pool.ntp.org 1.centos.pool.ntp.org 2.centos.pool.ntp.org
4. Reload the service:
sudo systemctl reload ntp.service or sudo systemctl restart ntp
5. Check the ntpd status:
sudo ntpq -p or sudo timedatectl
6. Also, consider update the hardware clock:
hwclock -w
Notes
Reference
- https://help.ubuntu.com/lts/serverguide/NTP.html
- https://www.server-world.info/en/note?os=CentOS_7&p=ntp
NTPD can adjust your clock in slow increments if it's off, clock skewing. The idea behind that is that slow steps won't cause issues with software timers, strange gaps in log files etc. The maximum slew rate possible is limited to 500 parts-per-million (PPM) by the Unix kernel. As a result, the clock can take 2000s for each second the clock is outside the acceptable range.
According to the manual page ntpd won't work if your clock is more then 1000 seconds off.
Since slewing the clock to adjust it by 1000 seconds will take at least 3 weeks and during that time all date/timestamps are still off, that might not seem too unreasonable.
The ntpdate command has a -b switch to simply adjust the time without slewing. This is useful in cases where the the local system clock deviates too much from the "correct" time.