# 所有节点安装ntp
yum install -y ntp
# 查看ntp状态
service ntpd status
# 配置ntpd
vim /etc/ntp.conf
// master节点配置(ntp.conf)
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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
server ntp.aliyun.com
//slaves节点配置
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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
# 指向master节点
server master
#启动
service ntpd restart
#设置开机自启
chkconfig ntpd on
#设置同步时间
ntpdate -u ntp.aliyun.com
//修改时区
timedatectl set-timezone Asia/Shanghai
# 系统时间同步到硬件
hwclock --systohc
# 添加定时任务
crontab -e
*/10 * * * * /usr/sbin/ntpdate ntp.aliyun.com