---
title: 配置NTP
description: "Ceph中会自动校验存储节点之间的时间，若不同节点之间时差较大，会有告警，因此需要配置NTP，同步各节点间的时间，提高网络管理效率。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengsdss/ecosystemEnable/Ceph/kunpengcephblock_DG_04_0014.html
sourcePath: /source/zh/kunpengsdss/ecosystemEnable/Ceph/kunpengcephblock_DG_04_0014.html
indexId: a9a762b5e50a4befe1d9006d36a15bd9c9fda43626a9eab4b972593e11f9385876
---
# 配置NTP

Ceph中会自动校验存储节点之间的时间，若不同节点之间时差较大，会有告警，因此需要配置NTP，同步各节点间的时间，提高网络管理效率。

1. 安装NTP服务。

  a. 在所有服务端节点和客户端节点安装NTP。
    1 yum -y install ntp ntpdate

  b. 在所有服务端节点和客户端节点备份旧配置。
    1 cd /etc && mv ntp.conf ntp.conf.bak

  c. 以ceph1为NTP服务端节点，在ceph1新建NTP文件。
    1 vi /etc/ntp.conf

    按“i”进入编辑模式，并新增如下内容作为NTP服务端。 1 2 3 4 5 restrict 127.0.0.1 restrict ::1 restrict 192.168.3.0 mask 255.255.255.0 server 127.127.1.0 fudge 127.127.1.0 stratum 8 其中，“restrict 192.168.3.0 mask 255.255.255.0”是ceph1的网段与掩码。

  d. 在ceph2、ceph3及所有客户端节点新建NTP文件。

    1. 打开文件。
      1 vi /etc/ntp.conf

    2. 按“i”进入编辑模式，新增如下内容：
      1 server 192.168.3.166

    3. 按“Esc”键退出编辑模式，输入:wq!，按enter键保存并退出文件。
2. 启动NTP服务。

  a. 在ceph1节点启动NTP服务，并检查服务状态为 Active。
    1 2 3 systemctl start ntpd systemctl enable ntpd systemctl status ntpd

    ceph1节点启动ntp进程5分钟后，再在其他节点进行时间同步，否则会报错（no server suitable for synchronization found）。

  b. 在除ceph1的所有节点强制同步server（ceph1）时间。
    1 ntpdate ceph1

    在其他节点同步成功显示如下：

    1 15 Oct 14:43:39 ntpdate[32973]: adjust time server 192.168.3.166 offset -0.000034 sec

  c. 在除ceph1的所有节点写入硬件时钟，避免重启后失效。
    1 hwclock -w

  d. 在除ceph1的所有节点安装并启动crontab工具。
    1 2 3 4 yum install -y crontabs chkconfig crond on systemctl start crond crontab -e

  e. 添加以下内容，每隔10分钟自动与ceph1同步时间。
    1 */10 * * * * /usr/sbin/ntpdate 192.168.3.166

    此IP地址为ceph1节点Public Network的IP地址。
