Home  >  Article  >  php教程  >  linux ntp service establishment

linux ntp service establishment

高洛峰
高洛峰Original
2016-11-23 17:32:011406browse

Background:

When there are too many servers, whether the time is accurate or consistent is a problem. So consistent timing is necessary.

The following is how to configure a Linux time server in the LAN.

Configuration environment and requirements:

1. Assume that in the 192.168.1.0 network segment, the Linux machine with IP address 192.168.1.201 should be used as the time server.

2. The 192.168.1.201 server can access the external network and synchronize with the more authoritative public network time server.

3. Other machines in the same network segment automatically synchronize their time to 192.168.1.201 every minute.

Preparation method:

1. yum install ntpdate -y Download ntp

/etc/init.d/ntpd start Start ntpd

linux ntp service establishment

2. cd /etc cp ntp.conf ntp.conf.bak backup ntp configuration file

vim (vi) ntp.conf Then you can see that there are four lines of server

Edit the first line and change it to server time.windows.com Then save and exit.

Then /etc/init.d/ntpd restart Restart ntpd

You can check whether the time has changed (of course, the premise is that your time is incorrect)

linux ntp service establishment

3. Now you can configure other servers to connect to


yum of 192.168.1.201 install ntpdate -y Download ntp

/etc/init.d/ntpd start Start ntpd

Set a scheduled task

crontab -e

*/1 * * * * /usr/sbin/ntpdate 192.168.1.201 >> /tmp/log

is synchronized with the 192.168.1.201 server every minute and entered into /tmp/log

and then wait a moment to see the result.

linux ntp service establishment

linux ntp service establishment

Of course the 2 machine times synchronized with the 192.168.1.201 host better be wrong. Otherwise it won’t be easy to compare.

The screenshot below is from the log

linux ntp service establishment

linux ntp service establishment

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn