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 

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

相关内容

热门资讯

实测交流透视挂!宝玛大厅ai智... 实测交流透视挂!宝玛大厅ai智能透视挂教程,宝玛大厅破解软件经验(本来有挂辅助)1、每一步都需要思考...
总算了解辅助器!朱雀吴江三缺一... 总算了解辅助器!朱雀吴江三缺一ai智能透视辅助挂技巧,朱雀吴江三缺一好像是有挂(有辅助挂细节)朱雀吴...
今日公布透视!九五至尊大厅ai... 今日公布透视!九五至尊大厅ai智能透视插件,九五至尊大厅有没有透视挂窍门(切实有挂技术)1、在九五至...
玩家必看科普开挂!聚闲麻将ai... 玩家必看科普开挂!聚闲麻将ai智能透视辅助挂软件,聚闲麻将总是真的有挂(有辅助挂方式)聚闲麻将能透视...
据报道开挂!旅游娱乐ai智能开... 据报道开挂!旅游娱乐ai智能开挂工具,旅游娱乐辅助工具演示(一直有挂教学)1、全新机制【旅游娱乐ai...
一分钟揭秘开挂!决胜朋来麻将a... 一分钟揭秘开挂!决胜朋来麻将ai智能透视辅助挂教程,决胜朋来麻将真是真的是有挂(有辅助挂总结)1、首...
如何分辨真伪透视!红牛ai智能... 如何分辨真伪透视!红牛ai智能透视攻略,红牛是不是有挂经验(真是有挂技术)1、操作简单,无需红牛手机...
2分钟细说辅助器!江湖大庆麻将... 2分钟细说辅助器!江湖大庆麻将ai智能透视辅助挂攻略,江湖大庆麻将竟然是真的有挂(有辅助挂头条)1、...
总算清楚透视挂!老夫子厅ai智... 总算清楚透视挂!老夫子厅ai智能透视挂技巧,老夫子厅怎么开挂课程(好像发现有挂)老夫子厅破解侠是真的...
解密关于辅助!菜鸟麻将ai智能... 解密关于辅助!菜鸟麻将ai智能透视辅助挂脚本,菜鸟麻将总是存在有挂(有辅助挂存在)1、用户打开应用后...