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 

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

相关内容

热门资讯

最新开挂!微信微乐小程序游戏辅... 最新开挂!微信微乐小程序游戏辅助脚本,微信小程序辅助器免费版在进入微信微乐小程序游戏辅助脚本软件靠谱...
最新透视挂!微乐小程序免费黑科... 最新透视挂!微乐小程序免费黑科技,微信小程序微乐房间有技巧吗1、微乐小程序免费黑科技透视辅助软件激活...
最新辅助!微信微乐小程序修改器... 最新辅助!微信微乐小程序修改器,微乐陕西小程序破解器下载1、微信微乐小程序修改器脚本辅助下载、微信微...
最新透视挂!微信微乐小程序有挂... 最新透视挂!微信微乐小程序有挂黑科技,微乐家乡麻将辅助1、下载好微信微乐小程序有挂黑科技脚本下载之后...
最新开挂!微乐家乡麻将自建房辅... 最新开挂!微乐家乡麻将自建房辅助app,微乐小程序自建房辅助下载1、打开软件启动之后找到中间准星的标...
最新透视挂!微乐小程序辅助工具... 最新透视挂!微乐小程序辅助工具,如何下载微乐自建房黑科技入口1、首先打开微乐小程序辅助工具辅助器下载...
最新开挂!微乐家乡麻将自建房开... 最新开挂!微乐家乡麻将自建房开挂,微信小程序微乐房间的挂多少钱一、微乐家乡麻将自建房开挂可以开透视的...
最新辅助!微信微乐辅助免费,微... 最新辅助!微信微乐辅助免费,微乐小程序自建房透视免费1、游戏颠覆性的策略玩法,独创攻略技巧玩法,可透...
最新透视挂!小程序微乐游戏辅助... 最新透视挂!小程序微乐游戏辅助器,微乐自建房脚本入口1、下载好小程序微乐游戏辅助器透视辅助下载之后点...
最新辅助!微信微乐小程序辅助器... 最新辅助!微信微乐小程序辅助器免费安装,微乐小程序免费黑科技在线下载1、金币登录送、破产送、升级送、...