时间服务器操作(Chrony)

服务器端配置安装ntp流程

安装chrony服务
yum -y install chrony
查看是否安装成功
rpm -qa | grep chrony
结果:chrony-3.4-1.el7.x86_64
启动
systemctl start chronyd
配置文件解释

配置文件默认位置
/etc/chrony.conf
chrony.conf默认配置
Chrony的配置⽂件是vim /etc/chrony.conf

使⽤ pool.ntp.org 项⽬中的公共服务器。以server开,理论上想添加多少时间服务器都

可以。

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

注意:⼀般使⽤AD域控服务器时间同步 ,作者修改如下
server 192.168.0.33 iburst

根据实际时间计算出服务器增减时间的⽐率,然后记录到⼀个⽂件中,在系统重启后为

系统做出最佳时间补偿调整。

Record the rate at which the system clock gains/losses time.

driftfile /var/lib/chrony/drift

如果系统时钟的偏移量⼤于1秒,则允许系统时钟在前三次更新中步进。

Allow the system clock to be stepped in the first three updates if its offset is larger

than 1 second.
makestep 1.0 3

启⽤实时时钟(RTC)的内核同步。

Enable kernel synchronization of the real-time clock (RTC).

rtcsync

通过使⽤ hwtimestamp 指令启⽤硬件时间戳

Enable hardware timestamping on all interfaces that support it.

hwtimestamp *

Increase the minimum number of selectable sources required to adjust the system

clock.

minsources 2

指定 NTP 客户端地址,以允许或拒绝连接到扮演时钟服务器的机器

Allow NTP client access from local network.

allow 192.168.0.0/16

Serve time even if not synchronized to a time source.

local stratum 10

指定包含 NTP ⾝份验证密钥的⽂件。

Specify file containing keys for NTP authentication.

keyfile /etc/chrony.keys

指定⽇志⽂件的⽬录。

Specify directory for log files.

logdir /var/log/chrony

选择⽇志⽂件要记录的信息。

Select which information is logged.

log measurements statistics trackin

客户端时间同步

客户端检查是否安装
rpm -qa | grep chrony
结果:chrony-3.4-1.el7.x86_64
修改vim /etc/chrony.conf
注意:使⽤主机IP服务器时间同步 修改如下
server 192.168.0.8 iburst
设置为开机自启动,重启服务
systemctl enable chronyd
systemctl restart chronyd
查看时间同步状态
timedatectl status
查看 ntp_servers 是否在线
chronyc activity -v
查看 ntp 详细信息
chronyc tracking -v
强制同步下系统时钟
chronyc -a makestep
常见时区

(1)UTC 整个地球分为⼆⼗四时区,每个时区都有⾃⼰的本地时间。在国际⽆线电通信场合,为了统⼀起⻅,使⽤⼀个统⼀的时间,称为通⽤协调时(UTC, Universal TimeCoordinated)。
(2)GMT 格林威治标准时间 (Greenwich Mean Time)指位于英国伦敦郊区的格林尼治天⽂台的标准时间,因为本初⼦午线被定义在通过那⾥的经线。(UTC与GMT时间基本相同)
(3)CST 中国标准时间 (China Standard Time) GMT + 8 = UTC + 8 = CST
(4)DST夏令时(Daylight Saving Time) 指在夏天太阳升起的⽐较早时,将时间拨快⼀⼩时,以提早⽇光的使⽤。(中国不使⽤)
常见互联网授时中心

210.72.145.44 国家授时中⼼
ntp.aliyun.com 阿⾥云
s1a.time.edu.cn 北京邮电⼤学
s1b.time.edu.cn 清华⼤学
s1c.time.edu.cn 北京⼤学
s1d.time.edu.cn 东南⼤学
s1e.time.edu.cn 清华⼤学
s2a.time.edu.cn 清华⼤学
s2b.time.edu.cn 清华⼤学
s2c.time.edu.cn 北京邮电⼤学
s2d.time.edu.cn ⻄南地区⽹络中⼼
s2e.time.edu.cn ⻄北地区⽹络中⼼
s2f.time.edu.cn 东北地区⽹络中⼼
s2g.time.edu.cn 华东南地区⽹络中⼼
s2h.time.edu.cn 四川⼤学⽹络管理中⼼
s2j.time.edu.cn ⼤连理⼯⼤学⽹络中⼼
s2k.time.edu.cn CERNET桂林主节点
s2m.time.edu.cn 北京⼤学
ntp.sjtu.edu.cn 202.120.2.101 上海交通⼤学

posted @ 2023-11-10 12:07  ylman  阅读(323)  评论(0)    收藏  举报