一、设置主节点时间服务器的时区

    二、在每一个节点上检查是否安装时间服务ntp

    三、在主节点上配置时间同步的相关文件

    四、在其他从节点上配置与主节点时间同步的脚本

一、设置主节点时间服务器的时区

1、选择时区(就选到beijing就行)

[root@node001 ~]# tzselect

2、把时区,将cp /usr/share/zoneinfo/Asia/Shanghai设置为到/etc/localtime的链接

[root@node001 ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 二、在每一个节点上检查是否安装时间服务ntp

[root@node001 ~]# rpm -q ntp
ntp-4.2.6p5-15.el6.centos.x86_64

如果没有显示安装,用yum安装
[root@node001 ~]# yum install -y ntp
设置ntpd 开机开启
[root@node001 ~]# chkconfig ntpd on        
查看打开状态             
[root@node001 ~]# chkconfig --list ntpd
ntpd            0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭     
三、在主节点上配置时间同步的相关文件
[root@node001 ~]# vi /etc/ntp.conf   或者   [root@node001 ~]# vim /etc/ntp.conf
下面加中文的为修改的地方!!!

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). driftfile /var/lib/ntp/drift # Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1 # Hosts on local network are less restricted.
restrict 192.168.181.0 mask 255.255.255.0 nomodify notrap  #这里新增内容,更改为自己的网关,我的是181.第一处新增,意思是从IP                                                                                                                                        #地址192.168.181.1-192.168.181.254,默认网关255.255.255.0的服务器                                                                                                                                                                      #都可以使用我们的NTP服务器来同步时间 # 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这里注释掉
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 210.72.145.44 perfer #中国国家受时中心
server 202.112.10.36 #1.cn.pool.ntp.org
server 59.124.196.83                          #这里可有可无,制定ntp服务器的同步时间范围        
server 192.168.217.130 #broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client # Enable public key cryptography.
#crypto includefile /etc/ntp/crypto/pw # Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys # Specify the key identifiers which are trusted.
#trustedkey 4 8 42 # Specify the key identifier to use with the ntpdc utility.
#requestkey 8 # Specify the key identifier to use with the ntpq utility.
#controlkey 8 # Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
server 127.127.1.0  #当服务器与公网失去连接后使用本地时间作为服务的同步时间
fudge 127.127.1.0 stratum 10
 
 
 让硬件时间与系统时间一起同步

[root@node001 ~]# vi /etc/sysconfig/ntpd

增加内容

SYNC_HWCLOCK=yes

重新启动服务
[root@node001 ~]# service ntpd restart
关闭 ntpd:                                                [确定]
正在启动 ntpd:                                            [确定]
 
注意!注意!注意!
其他节点不用开启这个ntpd,只需要安装,然后用插件同步的时候才起作用!!
 
可设置crontab每天和NTP服务器同步一次
[root@node001 ~]#crontab -e
10 23 * * * root (/usr/sbin/ntpdate cn.pool.ntp.org && /sbin/hwclock -w) &> /var/log/ntpdate.log
四、在其他从节点上配置与主节点时间同步的脚本
在其他节点配置 一小时与时间服务器同步一次,这里不知道时间怎么弄的可以查crontab这个命令,很多有解释,请看:
https://www.cnblogs.com/intval/p/5763929.html 

[root@node002 ~]# crontab -e

* */1 * * * /usr/sbin/ntpdate node001

检查是否写成

[root@node002 ~]# crontab -l
* */1 * * * /usr/sbin/ntpdate node001

同样的步骤在其他节点重复

更改一个节点的时间

[root@node002 ~]# date -s "2019-4-29 00:00:00"

十分钟后查看时间检查是否同步

[root@node002 ~]# date

如果现在立即要同步,可以手动同步

[root@node002 ~]#ntpdate node001

Hadoop集群搭建中时间同步步骤的更多相关文章

  1. Hadoop集群搭建安装过程(二)(图文详解---尽情点击!!!)

    Hadoop集群搭建安装过程(二)(配置SSH免密登录)(图文详解---尽情点击!!!) 一.配置ssh无密码访问 ®生成公钥密钥对 1.在每个节点上分别执行: ssh-keygen -t rsa(一 ...

  2. Linux环境下Hadoop集群搭建

    Linux环境下Hadoop集群搭建 前言: 最近来到了武汉大学,在这里开始了我的研究生生涯.昨天通过学长们的耐心培训,了解了Hadoop,Hdfs,Hive,Hbase,MangoDB等等相关的知识 ...

  3. Hadoop学习之路(四)Hadoop集群搭建和简单应用

    概念了解 主从结构:在一个集群中,会有部分节点充当主服务器的角色,其他服务器都是从服务器的角色,当前这种架构模式叫做主从结构. 主从结构分类: 1.一主多从 2.多主多从 Hadoop中的HDFS和Y ...

  4. 三节点Hadoop集群搭建

    1. 基础环境搭建 新建3个CentOS6.5操作系统的虚拟机,命名(可自定)为masternode.slavenode1和slavenode2.该过程参考上一篇博文CentOS6.5安装配置详解 2 ...

  5. 大数据初级笔记二:Hadoop入门之Hadoop集群搭建

    Hadoop集群搭建 把环境全部准备好,包括编程环境. JDK安装 版本要求: 强烈建议使用64位的JDK版本,这样的优势在于JVM的能够访问到的最大内存就不受限制,基于后期可能会学习到Spark技术 ...

  6. Hadoop集群搭建-01前期准备

    Hadoop集群搭建-05安装配置YARN Hadoop集群搭建-04安装配置HDFS  Hadoop集群搭建-03编译安装hadoop Hadoop集群搭建-02安装配置Zookeeper Hado ...

  7. Hadoop 集群搭建和维护文档

    一.前言 -- 基础环境准备 节点名称 IP NN DN JNN ZKFC ZK RM NM Master Worker master1 192.168.8.106 * * * * * * maste ...

  8. Hadoop集群搭建(完全分布式版本) VMWARE虚拟机

    Hadoop集群搭建(完全分布式版本) VMWARE虚拟机 一.准备工作 三台虚拟机:master.node1.node2 时间同步 ntpdate ntp.aliyun.com 调整时区 cp /u ...

  9. Hadoop集群搭建的详细过程

    Hadoop集群搭建 一.准备 三台虚拟机:master01,node1,node2 时间同步 1.date命令查看三台虚拟机时间是否一致 2.不一致时间同步:ntpdate ntp.aliyun.c ...

随机推荐

  1. 手机布局rem的使用(rem)

    最后一堆代码是举例的全码. 一 直接<head>标签里套用以下,其他都不用 <script> document.documentElement.style.fontSize = ...

  2. Javascript 需要注意的细节

    1.使用 === 代替 ==JavaScript 使用2种不同的等值运算符:===|!== 和 ==|!=,在比较操作中使用前者是最佳实践.“如果两边的操作数具有相同的类型和值,===返回true,! ...

  3. plsql Developer 登录oracle出现 initialization error

    plsql Developer 登录oracle出现 initialization error 原因:plsql没有64位的,32位的plsql连接64位的oracle才会报错 解决方案:到oracl ...

  4. DataGuard 配置须知

    风不停,绿树荫,阳光晃眼,天真蓝,我们在奔跑,沿着斜阳,是你喘息,起伏不停...  ——朴树 1.确认primary库处于归档模式 命令:archive log list; 如果没有启用归档,请先将数 ...

  5. OkHttp3几个简单的例子和在子线程更新UI线程的方法

    okHttp用于android的http请求.据说很厉害,我们来一起尝尝鲜.但是使用okHttp也会有一些小坑,后面会讲到如何掉进坑里并爬出来. 首先需要了解一点,这里说的UI线程和主线程是一回事儿. ...

  6. spring配置Bean

    Bean   就是一个类 一下代码都是基于spring之IOC和DI实现案例基础上进行解析 Bean的实例化方式: 1.无参构造 <bean id="UserService" ...

  7. centos修改主机名命令

    centos修改主机名命令   需要修改两处:一处是/etc/sysconfig/network,另一处是/etc/hosts,只修改任一处会导致系统启动异常.首先切换到root用户.    vi / ...

  8. poj 3258 3273

    poj3258 题目  (最大化最小值)(最小值最大化) 题意:牛要到河对岸,在与河岸垂直的一条线上,河中有N块石头,给定河岸宽度L,以及每一块石头离牛所在河岸的距离,现在去掉M块石头,要求去掉M块石 ...

  9. hdu 4882 比赛罚时贪心

    http://acm.hdu.edu.cn/showproblem.php?pid=4882 就是CF的比赛,根据时间的推迟会相应的扣掉题目的分数,每个任务有e,k,e表示完成需要时间,k表示完成后消 ...

  10. PHP后台评论 接口

    /** * 添加评论 * content 评论内容 * addtime 评论时间 * uid 评论作品 */ public function padd(){ $param=input('param.' ...