1、查看本机是否安装了ntpdate服务,安装 时间同步软件

​   yum install -y ntpdate

   yum install -y ntp

2、同步时间

​   ntpdate time.nist.gov // 同步时间

​   如果同步不了

​   ntpdate time.nuri.net // 校验时间 系统时间

  ​ 把系统时间写入硬件时间

​   hwclock -w // 写入时间

-----------------------------------------------------------------------

1、修改时区

  命令:tzselect

​   选择 5 亚洲

​   9 中国

​   1 北京

  简单做法:

  cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime // 修改时区为上海

2、集群同步时间:必须是root用户

  1、没有ntp的安装ntp

    rpm -qa | grep ntp // 查看是否安装

  2、修改配置文件

    vim /etc/ntp.conf

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap 为
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#################################################

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

#################################################
增加:
server
127.127.1.0
fudge
127.127.1.0 stratum 10

  3、修改 /etc/sysconfig/ntpd

  加上:SYNC_HWCLOCK=yes

  4、重新启动ntpd,添加开机启动

service ntpd status
service ntpd start
--------------------
添加到开机启动
chkconfig ntpd on

  5、其他机器配置定时任务,10分钟 同步一次

crontab -e  编写定时器同步时间, 意义:每十分钟与node1 同步一次时间。
需要在集群中其他的机器中都编写 crontab -e
*/10 * * * * /ntpdata hadoop01

 

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!