750  
   0
centos下配置网络时间协议(NTP)的方法
作者:1325于 2020年04月22日 发布在分类 / 经典配置 / 经典配置 下,并于 2020年04月22日 编辑
NTP 网络时间协议

一、功能需求

当多台服务器之间对时间有一致性要求时,需要配置NTP。

二、环境介绍

本案例是在Centos7 上操作,请根据自己操作系统的发行版本安装和配置NTP。

三、配置步骤

1,在主节点上

1)  安装软件包

  [root@host1 ~]# yum install chrony -y

2)  编辑/etc/chrony.conf文件,按照实际环境的要求,对下面的部分进行添加,修改或者删除:

 [root@host1 ~]# vi /etc/chrony.conf

#  vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server host1 iburst
allow 172.0.0.0/16

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



说明:

   使用NTP服务器的主机名或者IP地址替换host1。配置支持设置多个  server  

   如有必要,将172.0.0.0/16修改成你实际环境中的子网.


3)  启动NTP服务,并将NTP服务设置为开机自启动

[root@host1 ~]# systemctl enable chronyd.service

[root@host1 ~]# systemctl start chronyd.service

       2,在其他节点上      

1)  安装软件包

  [root@host2 ~]# yum install chrony -y

2)  编辑/etc/chrony.conf 文件并注释除``server`` 值外的所有内容。修改它引用主节点:

[root@compute ~]# vi /etc/chrony.conf

#  vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server host1 iburst

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


     3)  启动 NTP 服务,并将 NTP 服务设置为开机自启动


[root@host2 ~]# systemctl enable chronyd.service

[root@host2 ~]# systemctl start chronyd.service
       3,验证操作     


 1)  在主节点

[root@host1 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? host1                    0  10     0     -     +0ns[   +0ns] +/-    0ns
 2)  在其他节点



[root@host2 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? host1                    0  10     0     -     +0ns[   +0ns] +/-    0ns


四、配置关键点

五、风险提示





 知识评论当前评论数0

 推荐知识


 访问权限

创建人 1325
文档编辑权限 创建者私有
文档阅读权限 来自分类
分类阅读权限 所有人
分类编辑权限 技术服务部  : 机构     渠道合作伙伴  : 机构     系统管理员 : 人员     
分类审核权限 审核小组  : 岗位    
分类预览权限 审核小组 : 岗位    
分类下载权限 技术服务部  : 机构    
 历史版本

修改日期 修改人 备注
2020-04-22 15:03:51[当前版本] 1325 CREAT

 目录
    宏杉案例知识库-V4.0.1