两台初始化完成的ECS模板机(4U4G 100GB)
服务端配置
1.安装ntp
yum -y install ntp
2.启动
systemctl start ntpd
3.设置开机自启
systemctl enable ntpd
4.查看状态
systemctl status ntpd
5.修改配置文件(添加注释,外部时间不可用时,以本地时间作为时间服务。)
vim /etc/ntp.conf
调整如下:
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10
6.保存并重启
systemctl restart ntpd
7.检查同步
ntpq -p
8.查看系统时间
date
客户端
9.客户端不能安装ntp服务,如果安装了ntp和ntpdate会占用一个端口号
yum install ntpdate -y
10.修改客户端时间
date -s 3:30
11.手动同步时间验证
ntpdate 192.168.40.132
12.在客户端增加计划任务并记录日志
crontab -e
*/1 * * * * /usr/sbin/ntpdate 192.168.40.132 >> /root/cron.log
13.查看定时任务
crontab -l