在CentOS8中默认不再支持ntpd软件包,也无法通过官方软件仓库安装, CentOS8上使用Chrony配置NTP服务器,用于同步时间。 它有两个程序,chrony和chronyd, chronyd是守护进程 ,chrony是一个命令行界面程序,可以用来监控chronyd的性能,并修改各种操作参数。
timedatectl –help
timedatectl [OPTIONS…] COMMAND …
Query or change system time and date settings.
-h –help Show this help message
–version Show package version
–no-pager Do not pipe output into a pager
–no-ask-password Do not prompt for password
-H –host=[USER@]HOST Operate on remote host
-M –machine=CONTAINER Operate on local container
–adjust-system-clock Adjust system clock when changing local RTC mode
–monitor Monitor status of systemd-timesyncd
-p –property=NAME Show only properties by this name
-a –all Show all properties, including empty ones
–value When showing properties, only print the value
Commands:
status Show current time settings
show Show properties of systemd-timedated
set-time TIME Set system time
set-timezone ZONE Set system time zone
list-timezones Show known time zones
set-local-rtc BOOL Control whether RTC is in local time
set-ntp BOOL Enable or disable network time synchronization
systemd-timesyncd Commands:
timesync-status Show status of systemd-timesyncd
show-timesync Show properties of systemd-timesyncd
chrony启动更新
使用chrony作为时间同步服务器相比之前配置也更简单,修改时区后操作以下四步即可。
1、修改配置文件 vi /etc/chrony.conf ,将 allow 172.16.1.0/24 // 172.16.1.0/24 为允许同步时间的网段。
2、 systemctl start chronyd #默认没有启动chronyd
3、 timedatectl set-ntp true #设置开始同步时间
4、firewall-cmd –add-service=ntp –permanent #防火墙放行