---
title: 如何手工配置 Chrony Server 和 Chrony Client-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于 如何手工配置 Chrony Server 和 Chrony Client相关的常见问题和使用技巧，帮助您快速解决 如何手工配置 Chrony Server 和 Chrony Client的难题。
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

划线反馈

# 如何手工配置 Chrony Server 和 Chrony Client

更新时间：2026-05-07 08:31

适用版本： V1.4.x、V2.1.x、V2.2.x、V3.1.x、V3.2.x、V4.0.x、V4.1.x、V4.2.x 内容类型：How-to  

本文介绍在局域网环境下配置 Chrony Server 和 Chrony Client 的详细步骤。

## 适用版本

OceanBase 所有版本

## 操作步骤

1. 在每一台 Chrony Server 和 Chrony Client 服务器上，停止并禁用 NTP 时钟同步服务。

   ```shell
   systemctl stop ntpd
   systemctl disable ntpd
   mv /etc/ntp.conf /etc/ntp.conf.bak

   ```
 2. 在每一台 Chrony Server 和 Chrony Client 服务器上，安装 Chrony 时钟服务软件包（如果服务器上已经安装了该软件包则可以跳过这一步）。

   ```shell
   yum install chrony -y
   rpm -qa | grep chrony

   ```
 3. 在局域网环境内挑选一台稳定的服务器（比如安装 OAT/OCP 的服务器）作为 Chrony Server 时钟源服务器，配置 `/etc/chrony.conf` 文件如下。

   #### 说明

   在修改 `/etc/chrony.conf` 配置文件之前，建议将原 `/etc/chrony.conf` 文件做一个备份，此命令如下：`cp /etc/chrony.conf /etc/chrony.conf.bak`

   假设这边的 Chrony Server IP 地址为：172.xxx.xxxx.8，局域网网段为：172.xxx.xxxx.0/16。实际配置时需要根据具体环境的 IP 地址做相应的调整。

   ```shell
   server 172.xxx.xxxx.8 minpoll 4 maxpoll 6 iburst
   maxslewrate 500

   # Record the rate at which the system clock gains/losses time.
   driftfile /var/lib/chrony/drift

   # Allow the system clock to be stepped in the first three updates
   # if its offset is larger than 1 second.
   makestep 1.0 3

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

   # 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

   # Allow NTP client access from local network.
   allow 172.xxx.xxxx.0/16

   # Serve time even if not synchronized to a time source.
   local stratum 10

   # 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 tracking

   ```

   参数说明：

      - minpoll：chrony 客户端向时钟源发起时间同步请求的最小时间间隔，单位为秒，默认值：4。
      - maxpoll：chrony 客户端向时钟源发起时间同步请求的最大时间间隔，单位为秒，默认值：6。
      - maxslewrate：用于控制 chrony 客户端时钟的最大调整速率，单位为 PPM （百万分之一），默认值：500。
 4. 启动 Chronyd 服务。

   ```shell
   systemctl start chronyd.service
   systemctl enable chronyd.service
   systemctl status chronyd.service

   ```
 5. 验证时钟服务。

   ```shell
   chronyc -n sources

   ```

   返回结果如下：

   ```shell
   MS Name/IP address       strarum Poll Reach LastRX Last sample
   ==================================================================================
   ^* 172.xxx.xxxx.8              2  4    377      16 -322us [ -340us]   -/-  26ms

   ```

   #### 注意

   此处输出需要包含 `^* xxx.xxx.xxx.xxx` 才表示时间同步服务配置成功。
 6. 在每一台 Chrony Client 服务器上，配置 `/etc/chrony.conf` 文件如下。

   # Record the rate at which the system clock gains/losses time.
   driftfile /var/lib/chrony/drift

   # Allow the system clock to be stepped in the first three updates
   # if its offset is larger than 1 second.
   makestep 1.0 3

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

   # 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

   # 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

   # 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 tracking

   ```
 7. 启动 Chronyd 服务。

   ```
 8. 验证时钟服务。

   ```

   返回结果如下：

   ```shell
   MS Name/IP address         Stratum Poll Reach LastRx Last sample
   ===============================================================================
   ^* 172.xxx.xxxx.8                    2   4   377     3  +2510ns[  -27us] +/-   24ms

   ```

   #### 注意

   此处输出需要包含 `^* xxx.xxx.xxx.xxx` 才表示时间同步服务配置成功。

## 注意事项

- 因为 OBServer 数据库对系统时间服务有强依赖，且 OBServer 默认系统时钟戳都是单调递增的，因此，强烈建议在安装部署 MetaDB/OCP/OceanBase 集群前就将系统时钟同步服务配置到位。
 - 如果 OceanBase 集群已经正在运行了，这个时候需要去调整系统时钟同步服务或者调整系统时间，请在 OceanBase 技术支持人员的指导下进行系统时间调整的操作。默认情况下，OceanBase 是不支持将系统时间调快或者调慢。

上一篇

[LSE 常见问题](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000003810554)

下一篇

[ECOB 安装与配置](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000002894037) ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
