网络时间服务与chrony

防火墙iptable、selinux、时间同步 是配置主机的基础

初始化:

  1. 关闭SELinux
  2. 关闭iptables,firewalld
  3. 配置chrony

时间同步

NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms

时间同步实现工具

  • ntp:精度在局域网内可达0.1ms,在互联网上精度在1-50ms,但是同步时间长,逐渐同步

  • chrony:实现NTP协议的软件,在互联网同步两台机器之间的精度在几毫秒,在LAN中,精度为几十微秒。CentOS7后系统自带

  • 两者本质既是客户端也是服务器,客户端持续运行

clock与date命令的区别:
  • clock是显示硬件时间

  • data是显示操作系统时间,在没有配置网络时间的情况下,data会读取硬件时间

NTP

ntp stratum levels

NTP服务是利用NTP协议提供时间同步服务的

NTP服务安装

yum install ntp -y

NTP配置

备份配置文件

[root@localhost ~]#cp /etc/ntp.conf{,.bak}
[root@localhost ~]#ls /etc/ntp.conf*
/etc/ntp.conf  /etc/ntp.conf.bak

查看配置文件

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
# 不允许其他主机查询我的主机时间并修改
# restrict default nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1

# Hosts on local network are less restricted.
# 允许内网其他机器同步时间
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 指定互联网上时间服务器进行时间同步服务,iburst提高时间同步效率
# 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

# 其他主机和此主机时间同步,可以将IP设置为该主机IP

# 自己指定同步阿
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值