Linux Configuration NTP server

Source: Internet
Author: User

Background

When the server is more, time is accurate or not, the same is a big problem. Although this problem is always overlooked, it is necessary to unify the time. Here's how to configure a Linux time server within a LAN.

Configuration of the environment and requirements:


1. Assume that a Linux machine time server with IP 192.168.0.240 is in the 192.168.0.0 network segment.

2.192.168.0.240 Server can Sisu network, can be synchronized with the more authoritative public network time server

3. Automatically synchronizes time to 192.168.0.240 per hour for other machines in the same network segment

Configuration method One, configure the NTP server (assuming that the IP address of the server you want to configure is 192.168.0.240)

The main configuration file for the 1.NTP server is/etc/ntp.conf now for the/etc/ntp.conf


#配置前做好备份
cd/etc/
MV Ntp.conf ntp.bak.conf

2.vi/etc/ntp.conf (Below is the contents of the ntp.conf file)

#设置此服务器同上层服务器做时间同步的IP地址, prefer means the preferred IP address
#经试验, the next few times the server is pretty fast.
Server210.72.145.44prefer
Server218.21.130.42
Server0. asia.pool.ntp.org
Server1. asia.pool.ntp.org
Server2. asia.pool.ntp.org

The time spent #记录上次的NTP server joins the upper NTP server
Driftfile/etc/NTP/Drift

#设置默认策略为允许任何主机进行时间同步
RestrictdefaultIgnore

#设置允许访问此时间服务器的时间服务的IP地址
#根据自己实际情况配置
Restrict127.0.0.1   
Restrict192.168.10.2# Specify a machine time synchronization
Restrict192.168.0.0Mask255.255.255.0#允许192.168.0.0/254 in-subnet host time synchronization
Restrict0.0.0.0Mask0.0.0.0nomodify Notrap #允许任何主机跟进行时间同步

#指定阶层编号为10, reducing its priority.
Fudge127.127.1.1StratumTen

#设置ntp日志的path
Statsdir/var/Log/NTP/

#设置ntp日志文件
LogFile/var/Log/NTP/Ntp.log

Maintenance of 3.NTP Server

----added as a service
Chkconfig--level 345 ntpd on

----Start
Service NTPD Start
Or
/ETC/RC.D/INIT.D/NTPD start
----Stop
Service NTPD Stop
Or
/ETC/RC.D/INIT.D/NTPD stop
----Management Commands
Ntpq–p #查看本机和上层服务器的时间同步结果
Ntptrace #可以用來追踪某台时间服务器的时间对应关系
Ntpdate IP #客户端要和NTP server for clock synchronization.
/var/log/ntp/ntp.log #查看ntp日志


Second, configure the client

1.LINUX Client: (Time-required machine in LAN)
echo "*/1 * * * * root/usr/sbin/ntpdate 192.168.0.240;/sbin/hwclock-w" >>/etc/crontab
Clock synchronization with NTP server hourly and write to native BIOS

2.Solaris Client:
echo "5 * * */usr/sbin/ntpdate 192.168.0.240" >>/etc/crontab

This article from "The Island is the sea cries broken Heart °" blog, declined reprint!

Linux Configuration NTP server

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.