We all come to learn the first service, NTP time server. Learning Services first to know what this service is mainly to do, how to install, how to configure, and then start. Once we know this, we'll build the NTP service.
1. What does the NTP service do primarily?
A: NTP (Network time Protocol) is a protocol used to synchronize the computer's timing, which allows the computer to synchronize its server or clock source, which provides a high degree of accuracy in time correction. This example explains how to configure the NTP server and NTP client on CentOS6.5 to keep the time of multiple clients consistent with the time specified by the NTP server. This ensures the time synchronization of multiple servers.
What packages do 2.NTP servers and NTP clients need to install?
A: The NTP server yum install NTP ntpdate-y (must first be configured with Yum, here is not much introduction)
NTP Client yum Install ntpdate-y
3. What needs to be achieved?
For:
1) Prepare 3 machines, 192.168.137.11 (NTP server) and 192.168.137.12-13 (NTP client).
2) server synchronization time with the upper-level servers, the client half-hour and NTP service side synchronization time, to the client time and service side of the normal time.
Experimental steps
1. At 192.168.137.11 (NTP server side)
[[email protected] ~]# yum install ntp ntpdate -yloaded plugins: fastestmirrorloading mirror speeds from cached hostfile * base: Mirrors.163.com * extras: mirrors.163.com * updates: centos.ustc.edu.cnsetting up Install ProcessResolving Dependencies--> Running transaction Check---> package ntp.i686 0:4.2.6p5-3.el6.centos will be installed ..... (Omitted here) installed: ntp.i686 0:4.2.6p5-3.el6.centos ntpdate.i686 0:4.2.6p5-3.el6.centos Dependency Installed: libedit.i686 0:2.11-4.20080712cvs.1.el6 complete !
We then configure the configuration file for the NTP server.
[Email protected] ~]# vim/etc/ntp.conf driftfile/var/lib/ntp/driftrestrict default kod nomodify notrap nopeer Noqueryre strict-6 default Kod nomodify notrap nopeer noqueryrestrict 127.0.0.1 restrict-6:: 1server ntp.fudan.edu.cn (server refers to Fixed upper server time) restric ntp.fudan.edu.cn nomodify notrap noquery (allows the upper server to modify the local machine time, if this column is not written, local time will not be modified) server 127.127.1.0 Fudge 127.127.1.0 Stratum 10 (if the upper server does not synchronize time, the machine automatically synchronizes its own time) Includefile/etc/ntp/crypto/pwkeys/etc/ntp/keys
After modifying the configuration file, restart the NTP service.
[[Email protected] ~]# service ntpd startstarting ntpd: [OK][[email Protec Ted] ~]# Datefri 7 21:25:35 CST 2015
If the time is not synchronized immediately, it will take several minutes to synchronize with the upper server.
2. In 192.168.137.12 and (NTP client)
[[email protected] ~]# yum install ntpdate -yloaded plugins: fastestmirror, securitydetermining fastest mirrors * base: mirrors.163.com * extras: mirrors.163.com * updates: centos.ustc.edu.cnsetting up install processresolving dependencies--> running transaction check---> Package ntpdate.i686 0:4.2.6p5-1.el6.centos will be updated ..... (omitted here) Dependency Updated: ntp.i686 0:4.2.6p5-3.el6.centos complete! [[email protected] ~]#
After you install the software, you can automatically synchronize NTP server time by setting up automatic task scheduling.
[[email protected] ~]# CRONTAB-E*/30 * * * */usr/sbin/ntpdate 192.168.138.12 >>/tmp/ntp.log
Set up automatic task scheduling and synchronize NTP server time in half an hour.
192.168.137.12 and 192.168.137.13 are the same operation.
The experiment is so simple, but if you want to know the NTP server configuration file, you can go to Google.
This article is from the "Linux" blog, so be sure to keep this source http://liunxbk.blog.51cto.com/8683822/1682789
CentOS 6.5 Build NTP service