ntp

主要用于做集群的机器日期同步

安装

  • 使用yum安装即可: yum -y install ntpdate ntp

配置

只需要一台配置ntp server即可 其他使用crontab进行定时同步
// 配置时间服务器
# vim /etc/ntp.conf
# 禁止所有机器连接ntp服务器
restrict default ignore
# 允许局域网内的所有机器连接ntp服务器
restrict 192.168.137.0 mask 255.255.255.0 nomodify notrap
# 使用本机作为时间服务器
server 127.127.1.0
// 启动ntp服务器
# service ntpd start
// 设置ntp服务器开机自动启动
# chkconfig ntpd on

使用

集群其它节点通过执行crontab定时任务,每天在指定时间向ntp服务器进行时间同步,方法如下:
// 切换root用户
$ su root
// 执行定时任务,每天00:00向服务器同步时间,并写入日志
# crontab -e配置每天同步即可
0 0 * * * /usr/sbin/ntpdate hadoop-aaa
// 查看任务
# crontab -l