Linux time server

Source: Internet
Author: User
Linux time server

In the RedHat Linux as 3.0 operating system, we can use NTP (Network Time Protocol) to build a local LAN time server.

The ASP platform contains more than 40 servers, including RedHat Linux as 3.0, Microsoft Windows 2000 Server, Microsoft Windows 2003 Enterprise Server, Solaris 9, and Aix 5.1, the time for installing the system is set according to the hardware time of the Local Machine. As a result, the time on each server may be significantly different, non-synchronization of time will certainly affect our applications, and sometimes may even cause some adverse consequences, such as affecting our backup and updating our databases. Most servers on the ASP platform cannot connect to the public network, that is, they cannot go to the public network to synchronize local time, therefore, it is necessary to select a machine that can connect to the public network as a time server on the ASP platform. The time server is synchronized with the public network time server on a regular basis, and the time of all servers on the ASP Platform is synchronized with the time server.

Step 1: Check whether the corresponding software package exists in Linux:

# Rpm-Qa | grep NTP
Ntp-4.1.1a-9
Chkfontpath-1.9.6-3
If the NTP package does not exist, it is mounted from the CD. Run the following command to install the ntp rpm package:
# Rpm-IVH ntp-4.1.1a-9.i386.rpm (I am using redhat8.0, please install the corresponding package according to your actual situation)

Step 2: modify the configuration file

/Etc/NTP. conf is the main configuration file of NTP, which sets the domain name or IP address of the server for the time you used to synchronize the time. The following is the most basic configuration for synchronizing time to the Internet:

First, let's define your favorite time server: (for available time servers, see http://chinaunix.net/jh/5/100591.html. For more information, see http://www.eecis.udel.edu /~ Mills/NTP/servers.html)
Server time.windows.com
Ntp1.sf-bay.org

Next, we set the access permissions for the above two servers. In this example, we do not allow them to modify or query the NTP server we configured on Linux.
Restrict time.windows.com mask quota limit 255 nomodify notrap noquery
Restrict ntp1.sf-bay.org mask limit 255 nomodify notrap noquery
Note: mask 255.255.255.255 is used to restrict the mask address of the remote NTP server.

Then set the Intranet machine that is allowed to access. Note that noquery has been removed from the Configuration:
Restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap
In this example, the mask address is extended to 255. Therefore, all computers from 192.168.1.1-192.168.1.254 can use our NTP server to synchronize time. If you want to limit more strictly, you can modify your mask.

Finally, the most important thing is that the default restricted configuration should be deleted from your configuration file. Otherwise, it will overwrite all your configuration options and you will find that if you do not delete the configuration, your time server can only communicate with itself. Comment out the following line in NTP. conf:
# Restrict default ignore
 
Step 3: Check Availability

A. Save your configuration file and run the query command on each time server you configured in NTP. conf to ensure that these upstream time servers are available.
# Ntpdate time.windows.com
27 Jun 10:12:01 ntpdate [25475]: adjust time server 133.100.11.8 offset-0.127154 Sec
# Ntpdate ntp1.sf-bay.org
27 Jun 10:12:06 ntpdate [25478]: adjust time server 133.100.9.2 offset 0.010008 Sec

B. Execute the following commands
# Ntpq-P
...... ...... Output omitted
One evidence proves that the jitter value of all remote servers is 4000 and the value of delay and reach is 0.
Remote refID st t when poll reach delay offset Jitter
========================================================== ==============================================
Local (0) Local (0) 10 L-64 7 0.000 0.000
* 0.0.0.0 16 U-64 0 0.000 0.000 4000.00

Step 4: Set auto-start

To enable the NTP service to automatically start during system boot, run:
# Chkconfig ntpd on

The command to start/disable/restart NTP is:
#/Etc/init. d/ntpd start
#/Etc/init. d/ntpd stop
#/Etc/init. d/ntpd restart

Step 5: Set the client

A. Linux Client
Log on as the root user, run ntpdate 61.152.112.13 to test whether it can be synchronized with the time server, and then run crontab-e input.
00 02 ***/usr/sbin/ntpdate 61.152.112.13 (change to the IP address of your time server). This will automatically synchronize time with the time server at every day.

B. Windows XP Client
Double-click the time in the lower-right corner. In the displayed "Date and time properties" window, select Internet time, enter the IP address of your time server in the server column, and click "Update Now ", the Update Success prompt will be displayed in a few seconds. Then, select "automatically synchronize with the Internet time server ". Click OK.

Now, the time server and its client settings based on Redhat Linux as 3.0 are complete, and the time of all ASP platforms will be synchronized to ensure the normal operation of various application systems and platforms.

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.