Objective
In the world of computers, time synchronization is extremely important for co-ordination between computers, and it takes time to synchronize our high availability clusters, load balancing, DNS services, and so on. NTP (Network time Protocol) is a protocol used to synchronize the time of each computer in a network. Its purpose is to synchronize the computer clock to the World coordinated UTC, its accuracy in the LAN up to 0.1ms, in most places on the Internet its accuracy can reach 1-50ms.
"Experimental Topology"
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/70/9B/wKiom1W551qjiMELAAFnw52FYHY575.jpg "title=" Ntp.png "alt=" Wkiom1w551qjimelaafnw52fyhy575.jpg "/>
"Configuration Steps"
The Linux system kernel itself provides support for NTP, so we only need to install the NTP server daemon, and we can get the latest version through ntp.org.
The first step: Download install NTP installation program, the current stable version of NTP-4.2.8P3;
[Email protected] ~]# tar zxf ntp-4.2.8p3.tar.gz [[email protected] ~]# Mkdir/usr/local/ntp[[email protected] ~]# CD NTP -4.2.8p3[[email protected] ntp]#./configure--prefix=/usr/local/ntp--enable-all-clocks--enable-parse-clocks # Note: The current system time must be new to the file creation time when the installation profile is generated, otherwise an error will occur! [[email protected] ntp]# make && make install
[[email protected] ntp]# vim /etc/ntp.conf driftfile /var/lib/ntp/drift # Record the time spent on the last Ntp server and Upper Ntp server joins; #restrict default kod nomodify notrap nopeer noquery #默认对于所有客服端拒绝所有的操作; restrict default nomodify # Modified to allow all clients to synchronize time with the server; #restrict 192.168.0.0 mask 255.255.255.0 nomodify # You can also specify that only one segment is allowed to synchronize time with the server; #restrict -6 default kod nomodify notrap nopeer noquery #相对于IPv6的设置, the default is to deny all operations;restrict 127.0.0.1 #允许本机的一切操作; restrict -6 ::1server 0.cn.pool.ntp.org #指定上层服务器server 1.asia.pool.ntp.orgserver 0.asia.pool.ntp.orgserver 192.168.0.111 #设置该主机为时间服务器;server 127.127.1.0 #使用本机时间; fudge 127.127.1.0 stratum 10 #指定时间服务器的层次. Set to 0 is the top level, if you want to update the time to another NTP server, do not set it to 0; #参数说明: #ignore: Turn off all NTP Online Services ; #nomodify: The client cannot change the time parameters on the service side. However, the client can perform network; through the server.#notrust : Unless authenticated, the client source will be treated as untrusted subnet; #noquery : No time query is provided for the client;
Step three: Start the NTP service;
[[Email protected] ntp]# service ntpd startstarting ntpd: [OK]
[[email protected] ~]# echo ' */30 * * * * root /usr/sbin/ ntpdate 192.168.0.111 ' >> /etc/crontab #添加一条时间同步计划任务, synchronized once every 30 minutes;[[email protected] ~]# chkconfig crond on #将计划任务设置为自动启动; [[email protected] ~]# service crond restart #重启计划任务载入设置;stopping crond: [ OK ]Starting crond:  [  OK  ]
Test
[Email protected] ntp]# DATEFRI Jul 01:15:11 CST 2015
[[email protected] ~]# ntpdate 192.168.0.11131 Jul 01:15:19 ntpdate[10082]: Adjust time server 192.168.0.111 offset 0.0018 Sec[[email protected] ~]# DATEFRI Jul 01:15:12 CST 2015
Note:1 . After you start the NTP service on an NTP server ,the NTP server itself or the synchronization with its server needs a time period , the no server suitable for synchronization found error occurs during this time when the client runs the ntpdate command for synchronization ;2, notice whether the settings for the firewall are disabledUDPof the123Ports,NTPis based on this port for communication and needs to be opened.
Ok! At this point, we have an NTP time server is configured, if there is any summary of the wrong place, but also ask you to shoot bricks! Thank you!
This article is from the "Flying Snail" blog, please be sure to keep this source http://ljmsky.blog.51cto.com/2878/1680371
Linux NTP time server configuration deployment