Introduction à NTP
NTP est un protocole de synchronisation de l'heure du réseau, qui est un protocole utilisé pour synchroniser l'heure de chaque ordinateur du réseau.
Préparez deux tests d'environnement centos7
Un serveur (136) Un client (137)
![Insérez la description de l'image ici](https://img-blog.csdnimg.cn/20201013160124314.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1EyNzQ5NDg0NTE=,size_16,color_FFFFFF,t_70#pic_center)
1. Désactivez le pare-feu setenforce
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
2. Installez et configurez le service ntp côté serveur
[root@localhost ~]# yum -y install ntp
[root@localhost ~]# vim /etc/ntp.conf
![5NDg0NTE =, taille_16, couleur_FFFFFF, t_70 # pic_center)](https://img-blog.csdnimg.cn/20201013162248136.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1EyNzQ5NDg0NTE=,size_16,color_FFFFFF,t_70#pic_center)
3. Commencez à afficher ntp
[root@localhost ~]# systemctl start ntpd
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 5 l 4 64 1 0.000 0.000 0.000
114.118.7.161 123.139.33.3 2 u 3 64 1 80.643 271.746 0.000
203.107.6.88 100.107.25.114 2 u 2 64 1 17.522 311.783 0.000
4. Installez ntpdate sur le client
[root@localhost ~]# yum -y install ntpdate
tester
1. Simulez et modifiez l'heure côté serveur
[root@localhost ~]# date -s "2018-08-8 04:53"
2018年 08月 08日 星期三 04:53:00 CST
2. Vérifiez l'heure en synchronisant l'heure du serveur sur le client
[root@localhost ~]# ntpdate -u 192.168.27.136
8 Aug 04:56:25 ntpdate[13694]: step time server 192.168.27.136 offset 38531233.207033 sec
[root@localhost ~]# date
2018年 08月 08日 星期三 04:56:03 CST
Il peut y avoir un délai d'environ 30 secondes pendant le test