NTP服务器的搭建
NTP服务 (C/S 架构)
- 它是通过网络在计算机系统之间进行时钟同步的网络协议
- 关闭防火墙和selinux(服务端)
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
- 下载软件
yum install ntp ntpdate -y
systemctl start ntpd
- 修改配置
vim /etc/ntp.conf(配置文件可以全部删掉,只要下面三行)
restrict default nomodify //不允许客户端登入,也不容许客户端修改
server 127.127.1.0 //使用本地的bios时间,自己跟自己同步
fudge 127.127.1.0 stratum 10 //定义级别,范围0-16,越小越精准
- 这个时候可以看一下自己的时间
date
- 关闭防火墙和selinux(客户端)
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
- 改一下自己的时间
date -s "1998-10-5 13:14:00"
- 安装软件
yum -y install nfs-utils
systemctl start ntpd
- 手动同步时间
ntpdate -b 192.168.40.133 //手动同步时间 -b加速初始化同步
定时任务:
crontab -e
00 00 1 * * ntpdate -b 192.178.40.133 //* * * * * 分时日月周