NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议。
以下是Centos7中主从的安装配置操作过程
安装ntp
# yum install ntp -y
启动服务
# systemctl start ntpd.service
查看启动状态
# systemctl status ntpd.service
开机自启
# systemctl enable ntpd.service
配置文件
# vim /etc/ntp.conf
以下是配置文件中需要修改的内容
– master –
# the administrative functions.
restrict 192.168.11.125 nomodify notrap nopeer noquery
# Hosts on local network are less restricted.
restrict 192.168.11.0 mask 255.255.255.0 nomodify notrap
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
#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
– slave –
# the administrative functions.
restrict 192.168.11.126 nomodify notrap nopeer noquery
# Hosts on local network are less restricted.
restrict 192.168.11.0 mask 255.255.255.0 nomodify notrap
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 192.168.11.125
Fudge 192.168.11.125 stratum 10
#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
查看主从状态
$ ntpq -p
– master –
remote refid st t when poll reach delay offset jitter
=================================================================
*LOCAL(0) .LOCL. 5 l 18 64 7 0.000 0.000 0.000
– slave –
remote refid st t when poll reach delay offset jitter
========================================================================
192.168.11.125 LOCAL(0) 6 u 37 64 1 0.758 -281.00 0.000