集群时间同步设置

1、环境准备

1)timedatectl查看时间各种状态:

[ptxbd@ptx-bigdata2 etc]$ timedatectl
      Local time: Thu 2020-03-12 13:00:55 UTC
  Universal time: Thu 2020-03-12 13:00:55 UTC
        RTC time: Thu 2020-03-12 13:00:45
       Time zone: UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

2)timedatectl list-timezones: 列出所有时区
3)timedatectl set-local-rtc 1 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间
4)timedatectl set-timezone Asia/Shanghai 设置系统时区为上海

[ptxbd@ptx-bigdata2 ~]$ sudo timedatectl set-timezone Asia/Shanghai
[ptxbd@ptx-bigdata2 ~]$ timedatectl
      Local time: Thu 2020-03-12 21:06:37 CST
  Universal time: Thu 2020-03-12 13:06:37 UTC
        RTC time: Thu 2020-03-12 13:06:28
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

2.设置NTP

模式:主从 主和互联网同步时间,从节点与主节点同步

1)所有节点都需要安装 ntp,如果没有 ntp 先安装 ntp,一般集群无法连接外网,可以先完成配置本地源的操作

yum install -y ntp

2)在 主节点修改 ntp.conf 输入 vi /etc/ntp.conf ,注释其他时间服务器,添加为本机

[ptxbd@ptx-bigdata1 ~]$ sudo vi /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum8

3)在其他节点(ptx-bigdata[2-5])修改 ntp.conf 文件 输入 vi /etc/ntp.conf 在26 行添加 server ptx-bigdata1 iburst,注释其他时间服务器

[ptxbd@ptx-bigdata2 ~]$ sudo vi /etc/ntp.conf
server ptx-bigdata1 iburst

4)在所有节点启动 ntp 服务

sudo systemctl start ntpd 
sudo systemctl enable ntpd

5)验证是否成功设置开机自启动

sudo systemctl list-unit-files |grep enabled | grep ntpd 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值