1、rpm -qa | grep ntp 查看服务是否已安装
2、如果没有安装(主机)
1>搜索:yum list | grep ntp
2>安装(主机)
yum -y install ntp.x86_64(小编这里是ntp.x86_64)
3、配置时间服务器
vi /etc/ntp.conf
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# 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 127.127.1.0(本地模式)
4、安装ntp客户端(有的跳过)(子机)
yum -y install ntpdate.x86_64
5、自动同步(子机)
crontab -e
*/1 * * * * /usr/sbin/ntpdate hadoop1 >> /dev/null
#一分钟同步一次,hadoop1改为自己校准时间的主机
6、开机启动(子机)
chkconfig ntpd on
如果自动同步失败
查看日志
cat /var/spool/mail/root