ntp和chrony

本文介绍了网络时间服务中的ntp和chrony,它们都可以作为客户端和服务器,用于保持系统时间的准确同步。重点讲述了ntp服务的配置,包括作为客户端和服务器的设置,以及ntp服务器使用udp的123端口。此外,还详细讨论了chrony服务,包括客户端和服务器配置,并提到了chrony服务端口。最后,提到了使用timedatectl命令来查看和设置系统时区。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

网络时间服务

网络时间服务:ntp 和 chrony
ntp 和 chrony 既可做客户端也可做服务器,需要时时开启与服务器同步,也需要时时等待客户端的连接,不同与c/s结构,作为客户端也要时时开启,因为需要时时与服务器同步。

ntp服务配置

ntp作为客户端

yum install ntp -y

vim /etc/ntp.conf
	server ntp1.aliyun.com iburst
	server ntp2.aliyun.com iburst

date -s '+10 month'
service ntpd start

在这里插入图片描述
已经经同步
以上是基于centos6

ntp作为服务器

yum install ntp -y
vim /etc/ntp.conf (centos6注释掉以下行)
	#restrict default kod nomodify notrap nopeer noquery
service ntpd start

ntp服务端口
ntp服务端口为 udp 的 123 端口
在这里插入图片描述

chrony 服务

chrony客户端配置

yum install chrony -y
vim /etc/chrony.conf
	server ntp1.aliyun.com iburst
	server ntp2.aliyun.com iburst
	server ntp3.aliyun.com iburst

date -s '-2 year'
systemctl restart chronyd

chrony服务端配置

yum install chrony -y
vim /etc/chrony.conf
	allow 0.0.0.0/0  //允许所有客户端
	local stratum 10 //本机不能与服务器同步了,也允许客户端与本机同步
systemctl start chronyd

chrony服务的端口

在这里插入图片描述# timedatectl 命令
timedatectl list-timezones 查看时区
系统默认的时区
在这里插入图片描述
设置时区

timedatectl set-timezone Africa/Gaborone
ln -s …/usr/share/zoneinfo/Asia/Shanghai /etc/localtime

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值