Centos(rocky,red Hat)搭建npt服务,采用阿里ntp时间,保证时间一致性时间

目的:保证分布式环境所有机器的时间具有一致性

1、 安装npt服务

#安装ntp服务

yum install ntp

#开机启动服务

systemctl enable ntpd

#启动服务

systemctl start ntpd

#更改时区

timedatectl set-timezone Asia/Shanghai

2、修改默认配置文件

vim /etc/ntp.conf
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#设置ntp1.aliyun.com可以修改本地系统时间
restrict ntp.aliyun.com nomodify notrap noquery
#设置阿里云NTP服务器
server ntp.aliyun.com
server ntp1.aliyun.com
server ntp2.aliyun.com
server ntp3.aliyun.com
server ntp4.aliyun.com
server ntp5.aliyun.com
server ntp6.aliyun.com
server ntp7.aliyun.com

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst#注释以上默认NTP服务器

3、重启服务

#重启NTP服务

systemctl restart ntpd

4.进行单词时间同步

#单次同步时间
ntpdate ntp.aliyun.com
#启用ntp同步
timedatectl set-ntp yes

5.查看同步状态

ntpq -p #查看NTP服务同步状态,见下面输出代表成功
remote refid st t when poll reach delay offset jitter

==============================================================================

120.25.115.20 10.137.53.7 2 u 9 64 1 47.461 0.578 0.000

猜你喜欢

转载自blog.csdn.net/qq_26408545/article/details/124336535