记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

What is Chronyd Service

In CentOS/RHEL 7 and 8, the operating system’s time is set on every boot based on the hardware clock, which is a small-battery driven clock located on the motherboard of your computer. Often, this clock is too inaccurate or has not been set right, therefore it’s better to get your system time from a reliable source over the Internet (that uses real atomic time). The chrony daemon, chronyd, sets and maintains system time through a process of synchronization with a remote server using the NTP protocol for communication.

In this post, we will learn to enable debug mode for chronyd service, which comes in very handy while troubleshooting any chronyd related issues. The configuration file used by chronyd service is /etc/sysconfig/chronyd.

1. Edit the configuration file /etc/sysconfig/chronyd as a root user:

# vi /etc/sysconfig/chronyd

2. Add or Modify below line.

OPTIONS="-dd"

3. Copy /lib/systemd/system/chronyd.service to /etc/systemd/system/:

# cp /lib/systemd/system/chronyd.service /etc/systemd/system/

4. Edit the file /etc/systemd/system/chronyd.service and change Type=forking to Type=simple:

# cat /etc/systemd/system/chronyd.service
[Unit]
Description=NTP client/server
Documentation=man:chronyd(8) man:chrony.conf(5)
After=ntpdate.service sntp.service ntpd.service
Conflicts=ntpd.service systemd-timesyncd.service
ConditionCapability=CAP_SYS_TIME

[Service]
Type=simple
PIDFile=/run/chrony/chronyd.pid
EnvironmentFile=-/etc/sysconfig/chronyd
ExecStart=/usr/sbin/chronyd $OPTIONS
ExecStartPost=/usr/libexec/chrony-helper update-daemon
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=full

[Install]
WantedBy=multi-user.target

5. Restart chronyd service using systemctl:

# systemctl restart chronyd

6. Now the logs of chronyd will be much more verbose when checked for the status of chronyd and also /var/log/messages or journalctl command output would show more verbose logs.

Before:

Jun 03 18:21:47 geeklab.localdomain systemd[1]: Starting NTP client/server...
Jun 03 18:21:47 geeklab.localdomain systemd[1]: chronyd.service: Can't open PID file /run/chrony/chronyd.pid (yet?) after start-post: No such file or directory
Jun 03 18:21:47 geeklab.localdomain chronyd[14780]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Jun 03 18:21:47 geeklab.localdomain chronyd[14780]: Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift
Jun 03 18:21:47 geeklab.localdomain chronyd[14780]: Using right/UTC timezone to obtain leap second data
Jun 03 18:21:47 geeklab.localdomain systemd[1]: Started NTP client/server.

After:

Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_io_linux.c:811:(NIO_Linux_ProcessMessage) Received 110 (48) bytes from error queue for 2402:>
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_core.c:2234:(update_tx_timestamp) Updated TX timestamp delay=0.000018729
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_core.c:1176:(transmit_timeout) Transmit timeout for [106.10.186.200:123]
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_io.c:906:(NIO_SendPacket) Sent 48 bytes to 106.10.186.200:123 from [UNSPEC] fd 13
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_io_linux.c:811:(NIO_Linux_ProcessMessage) Received 90 (48) bytes from error queue for 106.10>
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_core.c:2234:(update_tx_timestamp) Updated TX timestamp delay=0.000033359
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_core.c:1176:(transmit_timeout) Transmit timeout for [2606:4700:f1::1:123]
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_io.c:906:(NIO_SendPacket) Sent 48 bytes to 2606:4700:f1::1:123 from [UNSPEC] fd 14
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_io_linux.c:811:(NIO_Linux_ProcessMessage) Received 110 (48) bytes from error queue for 2606:>
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_core.c:2234:(update_tx_timestamp) Updated TX timestamp delay=0.000019594



转载请标明出处【How to Enable Debug Mode for Chronyd Service in CentOS/RHEL 8】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论