0
点赞
收藏
分享

微信扫一扫

Redis一键巡检脚本

mjjackey 2024-06-06 阅读 12

介绍

NTP是Network Time Protocol(网络时间协议)的简称,它是用来通过互联网或局域网将计算机时钟同步到世界协调时间(UTC)的协议。

安装

# yum安装
yum install -y ntp


# 离线安装
#下载地址:https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm

服务配置

  • 备份
cp /etc/ntp.conf{,.bak}
  • 修改配置文件
cat /etc/ntp.conf


# 有效配置如下
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server 127.127.1.0 iburst   # 添加内容
fudge 127.127.1.0 stratum 10   # 添加内容
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

配置服务

# 启动服务
systemctl start ntpd


# 开机自启
systemctl enable ntpd


# 查看状态
systemctl status ntpd


# 重启服务
systemctl restart ntpd


# 取消开机自启
systemctl disable ntp

注意:ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。

验证

  • 客户端安装ntpdate
  • 执行同步
ntpdate 192.168.1.2
# 根据提示确认是否已经同步完成。

定时同步

  • 配置定时任务
crontab -e
# 配置每小时0分同步一次
0 * * * * /usr/sbin/ntpdate 192.168.1.2

到这里,ntp服务及同步等操作就配置完成了。

分享、在看与点赞
只要你点,我们就是胖友

来自: Centos 7部署NTPicon-default.png?t=N7T8https://mp.weixin.qq.com/s?__biz=Mzk0NTQ3OTk3MQ==&mid=2247486435&idx=1&sn=caa2055af36befbdd4e4bf877fc90bc7&chksm=c31583aff4620ab96d7b8b35ff7caba406397600e852dbeec331d8067e9f1b3b3c028df91867&token=355315523&lang=zh_CN&poc_token=HMR2SWajnnpTkXjQrW8aCiGYd53Z29cZcwAMyxEC

举报

相关推荐

0 条评论