ntp-redhat 同步时间配置

1. 选作一个机器作为ntp 服务端,例如 ip 为192.168.0.1

1)安装 ntp服务

yum install ntp

2) 修改ntp.conf 文件

vi /etc/ntp.conf

注释掉 #restrict 127.0.0.1

#restrict -6 ::1

#server 0.rhel.pool.ntp.org iburst

添加 server 192.168.0.1 iburst

server 127.127.1.0

fudge 127.127.1.0 stratum

3)保证防火墙关闭,或者放开端口 udp 123 ,启动ntp

systemctl start ntpd

systemctl enable ntpd

systemctl status ntpd

4) ntpq -p 确定ntp是否正常

2. 安装客户端

1)yum -y install chrony(ps.该服务在Redhat7以上默认有)

2)vim /etc/chrony.conf

server 192.168.0.1 iburst

3) systemctl enable chronyd

4)systemctl restart chronyd.service

5) timedatectl 即可同步时间

ps.也可以手动同步时间:ntpdate -u 192.168.0.1 将其加入到定时任务中

timedatectl set-ntp true (开启同步)

猜你喜欢

转载自www.cnblogs.com/zyj-share/p/9549968.html