2使用ntp配置时间同步
集群时间同步(主节点)
1) rpm -qa |grep ntpd 》》没有安装则需要安装此服务 》》yum install ntp
2) vi /etc/ntp.conf
去掉这个注释,将地址改成网段地址
restrict 192.168.80.0 mask 255.255.255.0 nomodify notrap(ip改成自己主节点的ip)
注释掉这几个
#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
fudge 127.127.1.0 stratum 10
3) vi /etc/sysconfig/ntpd 加入下面一句话,用于配置boot时间和系统时间同步
SYNC_HWCLOCK=yes
4) 启动ntpd服务器
sudo service ntpd start
sudo service ntpd status
chkconfig ntpd on
chkconfig --list |grep ntpd
?
客户机配置(从节点)
使用ntpdate? master(主节点的ip) 即可同步
用定时任务自动同步ntp时间?
crontab -e
?
00 1 * * * root /usr/sbin/ntpdate 10.205.246.11 >> /root/ntpdate.log 2>&1
这样,每天 1:00 Linux 系统就会自动的进行网络时间校准。