本篇博客主要记录如何部署一台NTP服务器,用于内网时间同步。
时间服务器对于集群内部节点之间的协同工做,有着十分重要的意义。node
注:有关时区,时间的问题,参见博客《Linux系统的时间和时区.md》vim
本篇博客采用YUM的方式,安装NTP服务。bash
注:有关NTP协议和服务详解,参见博客《NTP时间服务器.md》
虚拟机console上执行yum -y install ntp
,即可安装ntp和ntpdate软件包。服务器
本篇博客主要将虚拟机console配置为内网NTP服务器。url
编辑配置文件
vim /etc/ntp.conf,将其内容修改以下:rest
driftfile /var/lib/ntp/drift restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap restrict 127.0.0.1 server 127.127.1.0 iburst fudge 127.127.1.0 straum 2 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys
注:有关NTP配置详解,参见《NTP配置文件详解.md》code
启动服务并设置开机启动
虚拟机console执行命令:service ntpd start && chkconfig ntpd on
server
netstat -tupln | grep ntp
ntpq -p
ntpstat
虚拟机node11,执行命令:yum -y install ntpdate
;而后执行:ntpdate 192.168.80.8
,将时间同步与console一致对象
通常状况下,能够经过ntpd服务来同步时间,即把node11的ntpd服务地址,指向console便可。
可是大多数状况下,但愿经过定时任务来同步节点时间。好比每小时都更新同步时间。如此,即可在console作定时任务,将各个节点时间同步。
本篇博客操做以下:blog
#!/bin/bash /usr/local/globle/softs/tools/pdsh/2.26/bin/pdsh -a ntpdate 192.168.80.8
*/10 * * * * /usr/local/globle/softs/tools/pdsh/2.26/bin/pdsh -a ntpdate 192.168.80.8 >/dev/null 2>&1
注:定时任务的任何信息,都须要写绝对路径,如可执行程序路径,文件对象的绝对路径。不然会发生各类意想不到的问题!