🍌Install NTP on Oracle Linux

NTP ( Network Time Protocol ) เป็นโปรโตคอลที่ใช้ในการ Sync Time ของเครื่อง Server ทุกเครื่องภายใน Network ให้ตรงกันผ่าน Protocol UDP ซึ่งทำงานแบบ Client-Server หรือ Peer-to-Peer ด้วย Port 123 ถ้าหาก Sync Time ของเครื่องไม่ตรงกัน อาจจะทำให้ Application หรือ Database ทำงานผิดพลาดได้

Install

  • ทำการติดตั้ง Package

#
yum install ntp -y
  • ทำการแก้ไขไฟล์ /etc/ntp.conf เลือกตาม NTP Pool Zone in Thailand คำเตือนหากไม่ระบุ iburst จะไม่ทำการ Sync ทันที ดังนั้นควรระบุ

#
vi /etc/ntp.conf
server 3.th.pool.ntp.org iburst
server 0.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
  • กรณีที่ต้องการใช้ NTP Server อื่นของไทย

#
vi /etc/ntp.conf
server time.navy.mi.th iburst
server time1.nimt.or.th iburst
server clock.nectec.or.th iburst
  • ทำการ Enable Firewall

#
iptables -I INPUT -p udp -m udp --dport 123 -j ACCEPT
#
service iptables save
  • ทำการ Start Service NTP

#
service ntpd restart
  • ทำการกำหนดให้ Start ทุกครั้งที่ Restart เครื่อง

#
chkconfig ntpd on
  • ทำการตรวจสอบ List of Peers ด้วย NTP Query

#
ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 203.147.59.16   .INIT.          16 u    -   64    0    0.000    0.000   0.000
 110.78.24.101   .IRIG.           1 u    -   64    1    3.513    0.018   0.000
 203.185.67.115  .GPS.            1 u    -   64    1    2.370    0.093   0.000
  • ทำการแสดง Network Time Synchronization ด้วย NTP Stat

#
ntpstat
synchronised to NTP server (218.186.3.36) at stratum 2
   time correct to within 75 ms
   polling server every 64 s
  • ทำการตรวจสอบ Date

#
date
Fri Nov 13 17:17:29 +07 2020
  • ทำการสร้าง Crontab

#
crontab -e
0 0 * * * root /usr/sbin/ntpdate -s -u time.navy.mi.th time1.nimt.or.th clock.nectec.or.th

อ่านเพิ่มเติม : https://bit.ly/38E7ROy, https://bit.ly/35tDSaq

Last updated

Was this helpful?