Sinkhronisasi Waktu dengan NTP

Halaman berikut menjelaskan metoda untuk menjaga agar jam di komputer anda akurat. Hal ini berguna bagi server, tetapi tidak terlalu penting bagi komputer desktop.

NTP ada TPC/IP protocol untuk sinkronisasi waktu melalui jaringan. Secara mendasar dari sisi klien meminta nilai waktu di server, dan diset di komputer sisi klien.

Behind this simple description, there is a lot of complexity - there are tiers of NTP servers, with the tier one NTP servers connected to atomic clocks (often via GPS), and tier two and three servers spreading the load of actually handling requests across the internet. Also the client software is a lot more complex than you might think - it has to factor out communication delays, and adjust the time in a way that does not upset all the other processes that run on the server. But luckily all that complexity is hidden from you!

Ubuntu memiliki dua cara untuk mengatur waktu secara otomatis: ntpdate dan ntpd.

ntpdate

Ubuntu comes with ntpdate as standard, and will run it once at boot time to set up your time according to Ubuntu's NTP server. However, a server's clock is likely to drift considerably between reboots, so it makes sense to correct the time ocassionally. The easiest way to do this is to get cron to run ntpdate every day. With your favourite editor, as root, create a file /etc/cron.daily/ntpdate containing:

ntpdate ntp.ubuntu.com

Berkas /etc/cron.daily/ntpdate harus dapat di eksekusi

sudo chmod 755 /etc/cron.daily/ntpdate

ntpd

ntpdate is a bit of a blunt instrument - it can only adjust the time once a day, in one big correction. The ntp daemon ntpd is far more subtle. It calculates the drift of your system clock and continuously adjusts it, so there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory, but for a modern server this is negligible.

Untuk mengatur ntpd:

sudo apt-get install ntp-simple

Mengubah Server Waktu

Pada kedua kasus di atas, sistem anda akan menggunakan server NTP milik Ubuntu di ntp.ubuntu.com sebagai standar. Konfigurasi ini tidak ada masalah, tetapi mungkin anda ingin menggunakan beberapa server untuk meningkatkan akurasi dan resilience, dan anda mungkin ingin menggunakan time server yang terdekat dengan anda secara geografis. Untuk melakukannya pada ntpdate, ubah isi dari file /etc/cron.daily/ntpdate menjadi:

ntpdate ntp.ubuntu.com pool.ntp.org 

Dan untuk ntpd sunting /etc/ntp.conf untuk menyertakan berbagai server tambahan:

server ntp.ubuntu.com
server pool.ntp.org

Anda mungkin memperhatikan pool.ntp.org pada contoh di atas. Ini merupakan ide bagus untuk menggunakan round-robin DNS untuk memberikan alamat server dari sebuah pool, membagi beban dengan server lainnya. Bahkan lebih baik, server-server tersebut memiliki pool dari berbagai wilayah - misalnya, jika anda di New Zealand, anda dapat menggunakan nz.pool.ntp.org sebagai pengganti dari pool.ntp.org. Lihat http://www.pool.ntp.org/ untuk lebih detail.

Anda dapat mencari NTP server yang terdekat melalui mesin pencari Google, dan tambahkan alamat NTP tersebut ke file konfigurasi anda. Untuk mencoba apakah server tersebut berfungsi/aktif, ketikkan sudo ntpdate ntp.server.name dan perhatikan apa yang tampil di layar monitor anda.

Halaman Terkait