集群时间同步

配置时间服务器
环境配置:
centos 7.3
10.0.0.4 server
10.0.0.5 client

时间

一:修改时间,并设置成24小时的格式

   a,  用date命令查看当前系统时间
  (EDT:指美国东部夏令时间,波士顿、纽约市、华盛顿哥伦比亚特区,
  这个时区跟北京时区(CST)有12小时的时差,晚12小时。)
  b,  通过tzselect 设置北京时间
  c,然后执行一下两条命令:
  rm   /etc/localtime
  ln  -sf   /usr/share/zoneinfo/Asia/Shanghai   /etc/localtime
  d:同步网络事间
     1,安装ntpdate工具
         yum -y install ntp  ntpdate
      2,设置系统时间与网络时间同步
        ntpdate   cn.pool.ntp.org 
      3,将系统时间写入硬件时间
        hwclock   --systohc

二 : 搭建ntp服务器

a, yum -y install ntp
b, 配置npt服务 /etc/ntp.conf
第15行添加:
restrict 10.0.0.0 mask 255.255.255.0
在第26行,设置服务器为自己:
server 127.127.1.0
fudge 127.127.1.0 stratum 11

c, 启动ntp服务并设置开机启动

     A:systemctl   restart   ntpd  

上边重启服务
B : systemctl enable ntpd

三: 同步时间的客户端

1, 安装chrony
yum -y install chrony
2, 配置/etc/chrony.conf
server 10.0.0.4
3, 启 动/开机启动chronyd
systemctl restart chronyd
4, 查看同步状态,显示NTPsynchrond:yes表示同步成功,时间同步可能需要一到两分钟。
timedatectl status
防火墙设置,打开udp123端口
firewall-cmd --permanent --add-port=123/udp
firewall-cmd --reload
查看防火墙已打开的端口:
iptables -L -n
查看状态: ntpq -p

四:另提供阿里的时间服务器

阿里云提供了7个NTP时间服务器也就是Internet时间同步服务器地址

ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com

五:集群的时间同步(连接外网)

yum  -y  install ntpdate
timedatectl set-timezone Asia/Shanghai
ln  -sf   /usr/share/zoneinfo/Asia/Shanghai   /etc/localtime
timedatectl set-local-rtc 0
crontab -e
$# 00 * * * *   /usr/sbin/ntpdate ntp1.aliyun.com 
$# 整时同步更新时间

由于centos 系统自带有chrond 服务,可以这样

echo "server    ntp1.aliyun.com iburst     iburst " >>  /etc/chrony.conf
systemctl restart chronyd
chronyc  -a makestep
chronyc sources -v
crontab -e 
00 * * * * /usr/bin/chronyc -a makestep
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值