Objective:
Network Time Protocol NTP (Networktime Protocol) is a standard Internet protocol used for time synchronization in the Internet. The purpose of NTP is to synchronize the computer's time to certain time standards. The time standard currently in use is UTC at World coordination Time (Universal-coordinated). The main developer of NTP is Professor David L. Mills of the University of Nottingham, USA.
What is the use of NTP for us personally, simply speaking, when your computer time is not accurate, you can access to the Internet, from the Internet to synchronize time, see how convenient.
ntpd in the actual synchronization time is a little bit of calibration over time, and eventually the time to adjust the correct pair. And Ntpdate will not consider whether other programs will be painful, directly adjust the time (there will be unexpected consequences)
One is the calibration time, one is the adjustment time.
For enterprises, when you have hundreds of computers, can not directly connected to the Internet, time does not unify the impact of business, if a set of changes, it should not be exhausted people ah. This is the advantage of building your own NTP server.
Because of the online environment, some servers do not need to Sisu network, just do the communication between the intranet, so the time of these servers can not guarantee synchronization, may have some impact on the business, for this reason, we need to set up a NTP time synchronization server in the intranet.
First install the NTPD service on the server side, normally install the system when the installation is good, if not installed, we can use the following command to install
First, server-side configuration
Download NTP software (yum source download)
Wget-o/etc/yum.repos.d/epel.repo Http://mirrors.aliyun.com/repo/epel-6.repo
Yum Install Ntp-y
2. Modify the configuration file
The default is in the/etc/ntpd.conf file:
First, before modifying the configuration file backup, cp/etc/ntpd.conf/etc/ntpd.conf.org
[Email protected] ~]# Grep-ev "#|^$"/etc/ntp.conf.org
Driftfile/var/lib/ntp/drift
Restrict default Kod nomodify notrap nopeer noquery
restrict-6 default Kod nomodify notrap nopeer noquery
Restrict 127.0.0.1
Restrict-6:: 1
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
Includefile/etc/ntp/crypto/pw
Keys/etc/ntp/keys
Modified configuration file:
[Email protected] ~]# cat/etc/ntp.conf
Driftfile/var/lib/ntp/drift
Restrict default nomodify
restrict-6 default Kod nomodify notrap nopeer noquery
Restrict 127.0.0.1
Restrict-6:: 1
Server time.nist.gov
#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
Includefile/etc/ntp/crypto/pw
Keys/etc/ntp/keys
3. Restart the NTPD service:
/ETC/INIT.D/NTPD restart
4. View local NTP communication with the parent server
[Email protected] ~]# ntpq-p
Remote refID St T when poll reach delay offset jitter
==============================================================================
Utcnist2.colora. ACTS. 1 u 66 64 76 313.246 5980216 2441326
Explain:
Remote: The name of the NTP server that responds to this request.
The REFID:NTP server uses the upper-level NTP server.
St:remote the level of the remote server. Because NTP is a layered structure, there is a top-level server, multi-tier relay server, and then to the client. So the server can be set to 1-16 from the high to the low level. To slow down the load and network congestion, you should avoid connecting directly to a Level 1 server in principle.
When: The number of seconds from the last successful request to the present.
Poll: How much time the local and remote servers synchronize (in seconds). At the beginning of the NTP run time this poll value will be relatively small, so the frequency of synchronization with the server will increase, can be adjusted to the correct time range as soon as possible, then the poll value will gradually increase, the frequency of synchronization will be correspondingly reduced
Reach: This is an octal value that is used to test whether a connection to the server can be made. Each successful connection will increase its value
Delay: Round trip time to send synchronization requests from the local machine to the NTP server
Offset: The amount of time offset, in milliseconds (ms), that the host synchronizes with the synchronized time source through the NTP clock. The closer the offset is to 0, the closer the host and NTP servers are
Jitter: This is a value used to do statistics. It counts the distribution of offset in a particular contiguous number of connections. Simply put, the smaller the absolute value, the more accurate the host time
Second, the NTP configuration file:
/etc/ntp.conf the configuration file for the NTP service.
1), the permission is set mainly to restrict this parameter to set, the main syntax is:
Restrict IP address mask Subnet mask parameter
Where IP can be an IP address or default, default means all IP
The parameters are as follows:
Ignore: Turn off all NTP Online Services
Nomodify: The client cannot change the time parameters on the server side, but the client can perform the network calibration via the server.
Notrust: The client source will be treated as untrusted subnet unless authenticated
Noquery: Do not provide a time query for the client
2), with the server this parameter set the parent time server, the syntax is:
Server IP address or domain name [prefer]
The IP address or domain name is the parent time server we specified, and if the server parameter is finally added prefer, it means that our NTP server is mainly calibrated with the host time of the unit.
3), to resolve the NTP server calibration time delivery delay
Use the Driftfile parameter setting:
Driftfile file name
The time that is spent in contacting the parent time server is recorded in the file following the Driftfile parameter.
Note: The files that follow the driftfile need to use the full path file name, cannot be a link file, and the permissions of the file need to be set to NTPD daemon can write.
Third, the client
The server in the cluster with no external network LAN is all synchronized with the server, and the timer task is set to synchronize this NTP server time.
Note that the NTPD service for these servers must be turned off.
Ntpdate NTP server IP address
[[email protected] scripts]# ntpdate 172.16.1.61 (test succeeded)
3 Dec 20:17:35 ntpdate[16063]: Adjust time server 172.16.1.61 offset-0.000570 sec
The mid-term cluster construction in the expansion of NTPD service to build self-study, the novice through the search for information and communication with students to build the process, there may be defects, please also welcome the vast number of Bo friends to criticize the correction!
Old boy big God warm hint:
Imageco Configuring NTP server Considerations
1 modifying vi/etc/ntp.conf
Add a previous level of NTP server
Server clock.redhat.com
It's better to add a few more levels, or a level two NTP server
2 Adding an NTP server to allow updated clients
Restrict 192.168.0.0 mask 255.255.255.0 nomodify
Allow 192.168.0.0 network segment machines to update on this machine
3 NTP Service initialization synchronization
Configure/etc/ntp/step-tickers to add clock.redhat.com or other NTP server addresses.
This NTP server is forced to update when the NTP service is started
4 Adding Hardware clock synchronization:
Configure the/etc/sysconfig/ntpd file to add:
Sync_hwclock=yes
This article is from the "Dream Boy" blog, please be sure to keep this source http://runningyongboy.blog.51cto.com/8234857/1719377
SME Cluster NTPD Service Building