centos 7 搭建ntp 服务器

restrict 192.168.1.0 netmask 255.255.255.0 nomodify notrap

第一步 安装ntp

yum install ntp

第二步,查找最近的时间同步服务器

http://www.pool.ntp.org/zone/asia

第三部编辑 /etc/ntp.conf

server  127.127.1.0  iburst   # local clock 当外部时间服务器不可用的时候,使用本机时间作为时间服务的标准
fudge 127.127.1.0 stratum 10 #这个值不能太高0-15,太高会报错


第四步

添加允许访问的ip 段

restrict 192.168.1.0 netmask 255.255.255.0 nomodify notrap


第五步 配置防火墙

firewall-cmd --add-service=ntp --permanent
firewall-cmd --reload



第六步 启动ntp 服务

systemctl enable ntpd  开机启动

systemctl start ntpd

sytemctl status ntpd


第七步 验证服务

ntpq -p



date -R



第八步

同步远程时间服务

ntpdate -q  0.ro.pool.ntp.org  1.ro.pool.ntp.org


第九步 在客户端机器同步时间

ntpdate -d -b 192.168.85.20



可能遇到的问题

1 centos stratum 0, precision 0, leap 00, trust 000 no server suitable for synchronization found

这个问题是由于防火墙挡住了ntp 端口,使用上买你的firewall-cmd 命令解决


2 stratum  too high 的问题

在/etc/ntp.conf 中 修改 stratum 的值


NTP开机无法启动的解决方法

这个问题往往是由于npt 服务的123 端口被其他服务占用引起,这个占用服务一般是chronyd

禁用这个服务即可

systemctl disable chronyd




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是在 CentOS 7 上搭建 NTP 服务器的步骤: 1. 安装 NTP:运行以下命令安装 NTP: ``` sudo yum install ntp ``` 2. 配置 NTP:编辑 `/etc/ntp.conf` 文件,配置服务器地址和允许访问的客户端地址。例如,以下是一个示例配置: ``` server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst restrict default nomodify notrap nopeer noquery restrict 127.0.0.1 restrict <客户端IP地址> mask <子网掩码> nomodify notrap ``` 其中,`server` 指定 NTP 服务器地址,`restrict` 用于限制访问控制。 3. 启动 NTP:运行以下命令启动 NTP 服务并设置为开机自启: ``` sudo systemctl start ntpd sudo systemctl enable ntpd ``` 4. 验证 NTP:使用 `ntpq` 命令验证 NTP 是否正常工作。例如,运行以下命令: ``` ntpq -p ``` 如果 NTP 正常工作,将显示类似以下内容的输出: ``` remote refid st t when poll reach delay offset jitter ============================================================================== *ntp1.example.c .GPS. 1 u 154 256 377 0.862 -30.200 1.835 +ntp2.example.c .PPS. 1 u 173 256 377 0.991 -30.230 1.309 -ntp3.example.c .GPS. 1 u 130 256 377 1.003 -29.990 1.935 ``` 其中,`*` 表示当前服务器NTP服务器,`+` 表示当前服务器NTP 辅助服务器,`-` 表示当前服务器NTP 被动服务器。 以上就是在 CentOS 7 上搭建 NTP 服务器的步骤。希望能对你有所帮助。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值