CentOS 7配置NTP客戶端


保持服務器時間准確,對於業務系統的運行、數據庫中時間的記錄等至關重要。通常的做法是為服務器配置NTP客戶端服務,讓服務器自己定時去與NTP服務器同步時間。

以CentOS 7服務器為例,為期配置NTP客戶端的具體步驟如下:

一、查看本機時間,確定NTP服務器的可用性(本例中以東北大學NTP服務器ntp.neu.edu.cn為例)

# date       //查看本機時間
# ntpdate ntp.neu.edu.cn  //確認NTP服務器的可用性

 

二、配置NTP客戶端

編輯ntp.conf文件,為NTP客戶端配置NTP服務器的地址ntp.neu.edu.cn

// 編輯NTP配置文件
# vim /etc/ntp.conf

// 注釋配置文件中原有的NTP服務器,並在其中添加自己所需的NTP服務器地址
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 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 ntp.neu.edu.cn iburst

  

三、將NTP配置為(自啟動)服務,並啟動運行

# systemctl enable ntpd.service  //安裝為服務
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

# systemctl start ntpd  //啟動運行

  

四、檢查NTP客戶端運行狀態

# systemctl status ntpd

  

 

# ntpstat

 

# watch ntpq -p

ctrl+c 退出NTP監視器

 

# ntpdate ntp.neu.edu.cn
12 Jul 00:14:46 ntpdate[19640]: the NTP socket is in use, exiting //提示NTP socket已經被使用

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM