NTP服務及時間同步服務器,是用來使計算機時間同步化的一種協議,它能夠使計算機對其服務器或時鐘源(如石英鐘,GPS等等)作同步化,下面就來講下如何安裝NTP服務html
1.安裝ntp服務centos
輸入下面命令進行安裝(若是沒網絡或者安裝速度慢的請設置本地yum源進行安裝,設置教程請點擊這裏查看)服務器
yum install ntp -y
修改ntpd服務的配置文件/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 (註釋掉如上4行,同步本身定義的服務器) server 192.168.100.3 server 192.168.100.2 prefer (prefer優先服務器,可定義多個master同步服務器) logfile /var/log/ntp.log (可選的操做,方便記錄日誌信息)
啓動ntpd服務,並加入到開機啓動項spa
systemctl start ntpd.service
將ntp服務加入到開機啓動項日誌
systemctl enable ntpd.service
若是咱們須要將系統時間同步到硬件時間,還能夠使用hwclock -w命令進行同步code