centos7 NTP详解

1. 基础命令

# 安装
yum -y install ntp ntpdate

# 关闭chronyd
systemctl disable chronyd

# 开启
systemctl start ntpd 

# 开放防火墙端口
firewall-cmd --zone=public --add-port=123/udp --permanent 
firewall-cmd --reload


# 使用中国NTP Server手动同步时间
ntpdate cn.pool.ntp.org

2. 配置服务端

vim /etc/ntp.conf

# 新增

restrict 172.22.10.6 nomodify notrap nopeer noquery //当前节点IP地址

# 授权172.22.10.0网段上所有机器可以从这台机器上查询和时间同步

restrict 172.22.10.0 mask 255.255.255.0 nomodify notrap //集群所在网段、掩码、权限

# 新增本地ntp服务器172.22.10.6,注释掉原有的server 0-n

server 127.127.1.0

fudge 127.127.1.0 stratum 10

interface ignore  wildcard

interface listen  172.22.10.6

interface listen  127.0.0.1

3. 配置客户端

1. 简单版

# 直接添加一行
server 4.centos.pool.ntp.org iburst

2. 详细版(不熟)

1)修改配置文件
vim  /etc/ntp.conf

# 增加
restrict 172.22.10.92 nomodify notrap nopeer noquery //当前节点IP地址
restrict 172.22.10.0 mask 255.255.255.0 nomodify notrap //集群所在网段的网段(Gateway),子网掩码(Genmask)

server 172.22.10.6 iburst //NTP服务器IP地址,可以注释掉别的server或者在需要配置的ntp服务器后添加perfer--优先,提高优先级,如:server 172.22.10.6 perfer iburst

fudge 172.22.10.6 stratum 10 //NTP服务器层级设置


2)预先同步一次时间(先关闭ntpd服务)

# ntpd进程进行同步时,只能同步较小的时间差,为防止时间差别太大,提前使用ntpdate进行一次时间同步

ntpdate 172.22.10.6

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值