Linux CentOS7 搭建ntp时间同步服务器

前提条件:ntp服务器需要与集群在同一网段内,也就是同一VMent中,并且关闭防火墙!! 关闭selinux
1.which ntpd(查看是否安装ntp)
which chronyd(查看是否安装chrony)
2.修改ntp配置文件
vim /etc/ntp.conf
有这样几行
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
以上全部注释掉,然后改为自己的配置为:
server 127.127.1.0 iburst (这一行是固定地,作用是:使用当前主机作为时间同步的服务器)
fudge 127.127.1.0 stratum 8(这一行表示当前服务器在整个互联网时间同步服务器层级中处于第八层,数字越小层级越高)
然后还有这样两行
# Hosts on local network are less restricted. (这行表示限制网段的意思)
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap(这行是限制网段的格式)
添加一行,其中的ip为你的主机ip网段,nomodify表示不允许你修改此网段:
restrict 192.168.66.0 mask 255.255.255.0 nomodify
保存退出
重启ntp systemctl restart ntpd
3.配置网卡ip
vim /etc/sysconfig/network-scripts/ifcfg-ens33
添加两行
IPADDR=192.168.xxx.xxx (自己向设置的ip地址。但是不可在dhcp服务器自动分配的ip范围内)
PREFIX=24(子网掩码)
修改一行
PROXY_METHOD="none" 或者="static"
如果是克隆的,把UUID那一行删除
保存退出
4.重启网卡
systemctl restart network
5.测试
用同一网段的虚拟机测试输入
ntpdate 192.168.124.117(服务端ip)

猜你喜欢

转载自www.cnblogs.com/w321696722/p/13191537.html
今日推荐