Linux NTP server, time synchronization

Source: Internet
Author: User

Zhou clan, finishing technical documents, for the next generation to stay a little tutorial ...


Company servers more, various services distributed management, so time synchronization is very important.

After a few times of understanding and thinking, decided to use this way to control time synchronization

1, any public network server SERVER21,NTP to http://www.pool.ntp.org, access to international standard Time

2, the internal formation of a local area network, all machines, NTP to the intranet server Server21, get synchronization

3, the intranet server, write a synchronization monitoring script, 1 hours to perform once to ensure that the time synchronization is correct.


Server, CentOS 6.3 64bit

Public network, the SERVER21 server is configured as follows:

-----------------------------------------------------------------------------------------------

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/47/85/wKiom1P8AJ7BzTBBAAFEmBpInk8910.jpg "title=" Unnamed QQ screenshot20140826101300.png "alt=" Wkiom1p8aj7bztbbaafembpink8910.jpg "/>

has been installed, the system itself has, do not need to install, the hint to do, not bird he


Before you edit the NTP profile, configure the file, first do a pre-work

1, to find out a more reliable public network server NTP, can not be full street, casually grabbed

2, we can go to the international standard NTP platform, find, HTTP://WWW.POOL.NTP.ORG/ZONE/CN

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/47/85/wKiom1P8AbOwKb_NAAGGu8-TgcA383.jpg "title=" Unnamed QQ screenshot20140826113902.png "alt=" wkiom1p8abowkb_naaggu8-tgca383.jpg "/>3, define the IP segment of the intranet server, if, We define it as 10.1.3.0/24.

4, Next, will really want to start configuring/etc/ntp.conf, the configuration file is as follows:

[Email protected] ~]# cat/etc/ntp.conf

# For more information on this file, see the "the Man pages"

# ntp.conf (5), NTP_ACC (5), Ntp_auth (5), Ntp_clock (5), Ntp_misc (5), Ntp_mon (5).


Driftfile/var/lib/ntp/drift


# Permit time synchronization with We time source, but does not

# permit the source to a query or modify the service on this system.

Restrict default Kod nomodify notrap nopeer noquery

restrict-6 default Kod nomodify notrap nopeer noquery


# Permit All access over the loopback interface. This could

# is tightened as well, but to does so would effect some of

# the administrative functions.

Restrict 127.0.0.1

Restrict-6:: 1


# Hosts on local network is less restricted.

Restrict 10.1.3.0 mask 255.255.255.0 nomodify notrap//Definition only 10.1.3.0 of Intranet Access Server21


# Use public servers from the Pool.ntp.org project.

# Please consider joining the pool (http://www.pool.ntp.org/join.html).

#server 0.cn.pool.ntp.org//Because my server room location, the first domain access speed is not good, so shield off his

Server 3.asia.pool.ntp.org

Server 2.asia.pool.ntp.org


#broadcast 192.168.1.255 AutoKey # Broadcast Server

#broadcastclient # Broadcast Client

#broadcast 224.0.1.1 AutoKey # Multicast Server

#multicastclient 224.0.1.1 # Multicast Client

#manycastserver 239.255.254.254 # Manycast Server

#manycastclient 239.255.254.254 AutoKey # manycast Client


# Enable Public Key cryptography.

#crypto


Includefile/etc/ntp/crypto/pw


# key file containing the keys and Key identifiers used when operating

# with symmetric key cryptography.

Keys/etc/ntp/keys


# Specify the key identifiers which is trusted.

#trustedkey 4 8 42


# Specify the key identifier to use with the NTPDC utility.

#requestkey 8


# Specify the key identifier to use with the NTPQ utility.

#controlkey 8


# Enable writing of Statistics records.

#statistics clockstats cryptostats loopstats peerstats

5. Start the NTP service and join the boot

Service ntpd start && chkconfig ntpd on


6. See if NTP time is synchronized.

[[Email Protected]_master ~]# Watch Ntpq-p

Every 2.0s:ntpq-p Tue 26 10:50:35 2014


Remote refID St T when poll reach delay offset jitter

==============================================================================

61.110.197.50 108.71.253.20 2 U 28 64 1 108.384 37.441 0.000

194.27.44.55 62.12.173.11 2 U 28 64 1 352.688 49.994 0.000

Obviously, it's already in sync.


7, attention, you ask me, now what time, I told you is 11:46:00, but, if you ask the foreigner, now, he may say, now is 24:00:00, because the time zone is different, so lead to time is not the same.

Therefore, we need to define our own time zone first, with this command

Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime

Then, restart the NTP service again, and the time is right.



Intranet, the configuration of all servers is as follows:

-----------------------------------------------------------------------------------------------

[Email protected] ~]# CRONTAB-E

#输入下面内容, save exit full wq!

XX */1 * * * root/usr/sbin/ntpdate 10.1.3.21 &&/sbin/hwclock-w

[Email protected] ~]# service Crond restart


Such two commands will allow him to automatically update the time, an hour/time


Because I this is the real environment, so will encounter a lot of problems, now the problem is that all the servers are intranet, the original is minimal installation, so did not install these crontab, but not even to the outside network, so it can not be installed Yum, only RPM package.


Http://rpm.pbone.net/index.php3/stat/4/idpl/25006580/dir/centos_6/com/cronie-1.4.4-12.el6.x86_64.rpm.html

Can come here to search, you want the RPM package, and then download to the local, and then upload to Server21, and then to the intranet server

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/47/85/wKiom1P8BSqBsL5LAANjn8kEdTQ535.jpg "title=" QQ Photo20140826115355.jpg "alt=" Wkiom1p8bsqbsl5laanjn8kedtq535.jpg "/>

RPM-IVH--nodeps cronie-1.4.4-12.el6.x86_64.rpm

Get


This article from the "Zhou Clan" blog, declined to reprint!

Linux NTP server, time synchronization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.