系列文章目录

centos7配置静态网络常见问题归纳_centos7网络问题

centos7克隆虚拟机完成后的的一些配置介绍

虚拟机centos7配置Hadoop单节点伪分布配置教程

卸载centos7自带的jdk的操作步骤

centos7配置zookeeper本地模式与集群模式的详细教程

文章目录

一、集群时间同步

二、配置时间同步具体实操

1.    时间服务器配置(必须root用户)

(1)检查ntp是否安装

(2)修改ntp配置文件

(3)修改/etc/sysconfig/ntpd 文件

(4)重新启动ntpd服务

(5)设置ntpd服务开机启动

2.    其他机器配置(必须root用户)

(1)在其他机器配置10分钟与时间服务器同步一次

(2)修改任意机器时间

(3)十分钟后查看机器是否与时间服务器同步


前言

本文主要介绍centos7虚拟机里面配置集群时间同步的操作步骤

一、集群时间同步

时间同步的方式:找一个机器,作为时间服务器,所有的机器与这台集群时间进行定时的同步,比如,每隔十分钟,同步一次时间。

vm虚拟机 centos同步系统时间_vm虚拟机 centos同步系统时间

二、配置时间同步具体实操

1.    时间服务器配置(必须root用户)

(1)检查ntp是否安装

[root@hadoop102 桌面]# rpm -qa|grep ntp

ntp-4.2.6p5-10.el6.centos.x86_64

fontpackages-filesystem-1.41-1.1.el6.noarch

ntpdate-4.2.6p5-10.el6.centos.x86_64

vm虚拟机 centos同步系统时间_vm虚拟机 centos同步系统时间_02

(2)修改ntp配置文件

[root@hadoop102 桌面]# vi /etc/ntp.conf

修改内容如下

a)修改1(授权192.168.1.0-192.168.1.255网段上的所有机器可以从这台机器上查询和同步时间)

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap为

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

vm虚拟机 centos同步系统时间_linux_03

 b)修改2(集群在局域网中,不使用其他互联网上的时间) 

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 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

vm虚拟机 centos同步系统时间_centos_04

c)添加3(当该节点丢失网络连接,依然可以采用本地时间作为时间服务器为集群中的其他节点提供时间同步)

server 127.127.1.0

fudge 127.127.1.0 stratum 10

vm虚拟机 centos同步系统时间_linux_05

(3)修改/etc/sysconfig/ntpd 文件

[root@hadoop102 桌面]# vim /etc/sysconfig/ntpd

增加内容如下(让硬件时间与系统时间一起同步)

SYNC_HWCLOCK=yes

vm虚拟机 centos同步系统时间_vm虚拟机 centos同步系统时间_06

(4)重新启动ntpd服务

[root@hadoop102 桌面]# service ntpd status

ntpd 已停

vm虚拟机 centos同步系统时间_vm虚拟机 centos同步系统时间_07

 

[root@hadoop102 桌面]# service ntpd start

正在启动 ntpd:                                            [确定]

vm虚拟机 centos同步系统时间_linux_08

 

(5)设置ntpd服务开机启动

[root@hadoop102 桌面]# chkconfig ntpd on

vm虚拟机 centos同步系统时间_vm虚拟机 centos同步系统时间_09

 

2.    其他机器配置(必须root用户)

(1)在其他机器配置10分钟与时间服务器同步一次

[root@hadoop103桌面]# crontab -e

编写定时任务如下:

*/10 * * * * /usr/sbin/ntpdate hadoop102

vm虚拟机 centos同步系统时间_linux_10

 

(2)修改任意机器时间

[root@hadoop103桌面]# date -s "2017-9-11 11:11:11"

vm虚拟机 centos同步系统时间_vm虚拟机 centos同步系统时间_11

 

(3)十分钟后查看机器是否与时间服务器同步

[root@hadoop103桌面]# date

说明:测试的时候可以将10分钟调整为1分钟,节省时间。

vm虚拟机 centos同步系统时间_linux_12

vm虚拟机 centos同步系统时间_linux_13

可以看到时间同步为当天的时间了

 总结

以上就是今天的内容,本文主要介绍centos7配置时间同步的具体配置

最后欢迎大家点赞👍,收藏⭐,转发🚀,
如有问题、建议,请您在评论区留言💬哦。