ntp时间同步

发布时间 2023-09-14 20:03:10作者: yipianchuyun

1、检查系统是否安装了NTP包(linux系统一般自带NTP4.2)
没有安装我们直接使用yum命令在线安装:
yum install ntp

systemctl enable ntpd 开机启动ntp

systemctl start ntpd 启动服务

systemctl stop ntpd 停止服务

systemctl status ntpd 查看服务状态


2、NTP服务端配置文件编辑
vim /etc/ntp.conf
添加服务器NTP服务器IP

server 10.0.50.28 prefer
首选内网NTP服务器,以下是几个国内的NTP服务器
ntp.neu.edu.cn
ntp.aliyun.com
ntp.ntsc.ac.cn

3、启动NTP时间服务器

service ntpd start

4、设置NTP开机自动启动

chkconfig ntpd on

5、查看NTP是否正常运行

netstat -tlunp | grep ntp

6、手工同步一次时间

/usr/sbin/ntpdate 10.0.50.28

7、查看时间同步结果

ntpstat

8、观察时间同步状况

ntpq -p