NTP服务器搭建

ntpd服务安装
[root@hps-1 custom]# yum install -y ntp
如果安装失败存在如下冲突:

请先卸载系统自带ntpdate,重新再执行安装即可:
[root@RQH-TEST-01 yum.repos.d]# yum remove ntpdate -y
[root@hps-1 custom]# yum install -y ntp

修改配置文件,添加并确保以下内容未被注释即可
[root@hps-1 custom]# grep -v ^# /etc/ntp.conf |grep -v ^$

[root@hps-1 custom]# vim /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 10.1.245.0 mask 255.255.255.0 nomodify notrap
server 127.127.1.0
fudge 127.127.1.0 stratum 8
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
注意:红色加粗部分,需要修改为NTP服务器网段地址、子网掩码。

设置随机启动并启动ntp服务
[root@hps-1 ~]# systemctl enable ntpd
[root@hps-1 ~]# systemctl start ntpd
[root@hps-1 ~]# systemctl status ntpd
验证:
在已经安装ntpdate服务的其他服务器(假设NTP服务器IP为10.1.245.105)上执行:
[root@hps-2 ~]#ntpdate 10.1.245.105
结果类似如下内容表明同步成功。

注:
由于NTP Server自身或与其他NTP Server的同步大概需要5分钟左右,因此请在ntp服务启动五分钟后执行以上验证操作。
如果其他服务器上的时间与NTP Server上的相差很大的话,必须先手动在其他服务器上修改时间后才能同步成功。修改方法为:
[root@hps-1 ~]# date -s “YYYY-MM-DD HH:MM:SS”
[root@hps-1 ~]# hwclock -w

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值