NTP主机怎样配置和部署
NTP主机配置和部署的方法:1、使用cp命令备份ntp主机配置文件;2、使用egrep命令优化配置文件;3、使用vim命令编辑配置文件,包括配置文件文本、允许内网其他机器同步时间、定义使用的上游ntp主机和定义主机时间;4、启动NTP主机;5、测试主机与客户端时间是否是同步。
具体操作以下:
1、备份ntp主机配置文件
cp /etc/ntp.conf /etc/ntp.conf.bak
ll /etc/ntp.conf*
2、精简优化配置文件
egrep -v "^$|#" /etc/ntp.conf.bak >/etc/ntp.conf
3、编辑配置文件
vim /etc/ntp.conf
配置文件文本
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict ⑹ default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ⑹ ::1
允许内网其他机器同步时间
restrict 172.16.1.0 mask 255.255.255.0 nomodify notr
#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
定义使用的上游 ntp主机,将原来的注释
server ntp1.aliyun.com
server time1.aliyun.com
允许上层时间主机主动修改本机时间
restrict time1.aliyun.com nomodify notrap noquery
restrict ntp1.aliyun.com nomodify notrap noquery
外部时间主机不可用时,以本地时间作为时间服务
server 127.127.1.0
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
4、启动NTP主机
Centos6: /etc/init.d/ntpd start centos7: systemctl start ntpd
ntpq -p 显示节点列表
5、客户端时间同步测试
ntpdate 10.0.0.111(ntp主机)
版权声明:xxxxxxxxx;
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态