Ntp时间同步

虚机有三台:bigdata111、bigdata112、bigdata113,需将112和113的linux系统时间向111同步

rpm包下载:
链接:https://pan.baidu.com/s/1bonvucrHBwkncj_2D9eBNg
提取码:n4td

1)所有机器root用户安装ntp服务命令

#server安装
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
#slave安装
rpm -ivh ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm

2)111主服务器切root修改ntp配置文件(根据服务器ip设置)

vi /etc/ntp.conf

清空所有,添加以下内容:
# 记录和上级时间服务器的时间差异
driftfile /var/lib/ntp/drift
# ntp 日志
logfile /var/log/ntp.log
# 日志级别 all event info
logconfig all
# 同意上层时间server主动改动本机时间
restrict default nomodify notrap nopeer noquery
# 允许本机地址的一切操作
restrict 127.0.0.1
restrict ::1
# 允许网段内客户端连接此服务器同步时间,但是拒绝让他们修改服务器上的时间
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# 利用 server 设定上层 NTP 服务器,可设置多个。prefer 表示优先
# 国家授时中心
server 210.72.145.44 prefer
# 阿里云
server ntp.aliyun.com prefer

includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

# 外部时间server不可用时,以本地时间作为时间服务
server 127.127.1.0
fudge 127.127.1.0 stratum 10

3)修改111主服务器ntpd文件

vi /etc/sysconfig/ntpd

添加:
SYNC_HWCLOCK=yes

4)启动111主服务器ntpd服务

service ntpd status
service ntpd restart

5)设置111主服务器ntpd服务开机启动,其他服务器不设置

chkconfig ntpd on
systemctl enable ntpd

6)其他服务器使用root用户配置定时任务

crontab -e

*/10 * * * * /usr/sbin/ntpdate bigdata111
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

衡超越爱学习~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值