centos7中安装 ntp时间同步服务器

发布时间 2023-08-04 21:46:55作者: 小鲨鱼2018

 

001、查看ntp服务状态

[root@PC1 home]# cat /etc/redhat-release  ## 系统版本
CentOS Linux release 7.6.1810 (Core)

 

002、启动ntp服务

[root@PC1 home]# systemctl start ntpd    ## 没有安装ntpd服务
Failed to start ntpd.service: Unit not found.

 

003、使用yum安装ntp

[root@PC1 home]# yum -y install ntp    ## yum安装ntp

 

004、使用date查看当前时间(异常)

[root@PC1 home]# date
Sat Aug  5 05:27:20 CST 2023

 

005、启动ntp时间同步功能

[root@PC1 home]# systemctl start ntpd
[root@PC1 home]# systemctl status ntpd    ## 已经启动

 

006、使用date查看当前时间

[root@PC1 home]# date         ## 时间已经自动同步
Fri Aug  4 21:40:44 CST 2023

 

007、设置ntpd服务开机自动启动

[root@PC1 home]# systemctl enable ntpd     ## 设置开启自动启动
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

 。