最近经常遇到各服务器时间不同步导致一些故障,现在需要自己搭建一台时间服务器来调整

升级安装ntp时间包
# yum -y install ntp
具体配置修改了,这里我再查看配置文件,让注销的不显示
# grep -v "^#" >/etc/ntp.conf

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1
restrict 192.168.10.0   mask 255.255.255.0    #这行是新添加的,让这个地址的能使用时间服务器,相当于acl控制
restrict -6 ::1

server ntp.fudan.edu.cn prefer #新添加了一个优先,prefer是表示优先的意思
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org

server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

启动服务

service ntpd start

netstat -tlunp

查看123udp端口是否启动起来,现在我们可以登陆客户机器同步了

[root@localhost ~]# ntpdate 192.168.10.231

16 Jun 18:25:53 ntpdate[10535]: step time server 192.168.10.231 offset 1538.540766 sec