Linux Centos7 服务器局域网集群使用 NTP 同步时间
创始人
2025-01-18 15:02:45
0
  1. 服务器环境:Centos7

    IP域名
    192.168.1.101node1
    192.168.1.102node2
    192.168.1.103node3
  2. 下载 ntp 依赖包

    包名驱动网站下载百度云下载
    autogen-liboptsautogen-libopts-5.18-5.el7.x86_64.rpm提取码:1234 autogen-libopts-5.18-5.el7.x86_64.rpm
    ntpdatentpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm提取码:1234 ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm
    ntpntp-4.2.6p5-29.el7.centos.2.x86_64.rpm提取码:1234 ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
  3. 安装RPM包
    在101、102、103 每台服务器安装ntp相关依赖包

    rpm -i autogen-libopts-5.18-5.el7.x86_64.rpm rpm -i ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm rpm -i ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm 
  4. 启动ntp服务
    在101、102、103 每台服务器 启动ntp

    # 启动 ntp 服务 systemctl start  ntpd # ntp 开机自启 systemctl enable  ntpd  # ntp 服务状态 systemctl status ntpd 
  5. 配置时钟服务器(192.168.1.101)
    编辑 /etc/ntp.conf 文件

    vim /etc/ntp.conf 

    修改以下内容

    restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # 这里局域网使用回环地址作为时钟源,如果可以连接互联网可以添加外部时钟源 server 127.127.1.0 # local clock # 填入回环地址,设置时间服务器的层级 stratum 0~15  ,0:表示顶级 , 10:通常用于给局域网主机提供时间服务 fudge 127.127.1.0 stratum 10  # 注释以下内容 #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 服务

    systemctl restart ntpd 
  6. 配置时钟客户端(192.168.1.102、192.168.1.103)
    编辑 /etc/ntp.conf 文件

    vim /etc/ntp.conf 

    修改以下内容

    restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap  # 首选192.168.1.101 作为时钟源 server 192.168.1.101 prefer  # 时钟源地址     fudge 192.168.1.101 stratum 10  # 注释以下内容 #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 服务

    systemctl restart ntpd 
  7. 查看NTP同步情况

    ntpstat 命令

    [root@localhost ~]# ntpstat synchronised to NTP server (192.168.1.101) at stratum 12    time correct to within 69 ms    polling server every 1024 s 

    ntpq -p 检查

    [root@localhost ~]# ntpq -p      remote           refid      st t when poll reach   delay   offset  jitter ============================================================================== 192.168.1.101   LOCAL(0)        11 u   28   64    1    0.147  -72137.   0.000 

    此处看到与源时钟时间差较大(offset ),建议等待5-10分钟查看

    [root@localhost ~]# ntpq -p      remote           refid      st t when poll reach   delay   offset  jitter ============================================================================== 192.168.1.101   LOCAL(0)        11 u   54   64  377    0.125   -0.022   0.098 

    可以看到时间已同步相差无几。

相关内容

热门资讯

今年以来!老k麻将有挂吗,家乡... 今年以来!老k麻将有挂吗,家乡大二辅助,扑克教程(总是存在有挂)-哔哩哔哩老k麻将有挂吗辅助器中分为...
在玩家背景下!丫丫陕西打锅子辅... 在玩家背景下!丫丫陕西打锅子辅助,微信小程序雀神挂件,微扑克教程(切实真的有挂)-哔哩哔哩1、微信小...
现有关情况通报如下!同城游破解... 现有关情况通报如下!同城游破解版下载,海盗来了辅助器无限炮,攻略教程(一直真的有挂)-哔哩哔哩1、该...
这一现象值得深思!潮汕掌上辅助... 这一现象值得深思!潮汕掌上辅助挂定制交易平台,兴动互娱辅助工具,透明挂教程(切实真的是有挂)-哔哩哔...
连日来!新518互游脚本下载,... 连日来!新518互游脚本下载,多乐辅助,微扑克教程(好像真的有挂)-哔哩哔哩运新518互游脚本下载辅...
近日!四川辅助工具,潮汕掌上娱... 近日!四川辅助工具,潮汕掌上娱有破解版吗,德州教程(其实有挂)-哔哩哔哩1、近日!四川辅助工具,潮汕...
今天下午!大唐撸麻雀辅助码,福... 今天下午!大唐撸麻雀辅助码,福建天天开心辅助软件大全,科技教程(本来是有挂)-哔哩哔哩1、打开软件启...
据目击者称!福州十八扑外卦,新... 据目击者称!福州十八扑外卦,新畅游互娱辅助,技巧教程(确实是有挂)-哔哩哔哩新畅游互娱辅助是一种具有...
出乎意料的是!欢聚水鱼智能辅助... 出乎意料的是!欢聚水鱼智能辅助教程,博雅红河西元红河挂,教你教程(都是有挂)-哔哩哔哩欢聚水鱼智能辅...
最终!约战竞技场辅助器,邳州友... 最终!约战竞技场辅助器,邳州友友有没有辅助软件,wpk教程(都是真的有挂)-哔哩哔哩1、每一步都需要...