Discussion of the time synchronization (NTP) operation under CENTOS6

Source: Internet
Author: User

1 . The importance of time synchronization

Time synchronization can ensure the normal operation of the business, such as data synchronization, such as the batch execution of the system planning task. such as


2. Check your system time .

[[Email protected] ~]# Date


3. System modification Time

# date-s "2015-10-17 19:00:00"
After the modification, remember to execute the CLOCK-W, write the system time to the CMOS, to ensure that the restart will take effect.


4 . Setup of hardware time

View: [[email protected] ~] #clock--show

Synchronize system time to hardware time: [[email protected] ~]# clock-w

Immediately synchronize the time of the network time source to the system time: [[email protected] ~]# ntpdate IP of the time server on the network

Time zone modification: [[email protected] ~]# Tzselect


You can modify the time file directly:

[Email protected] ~]#/etc/sysconfig/clock

Synchronize hardware time to System time:

[Email protected] ~]# hwclock-s


5. Network Synchronization

After the ntpdate operation, it is only mandatory to set the system time to NTP server time. There may be a problem with CPU tick. Crontab commands are generally required for regular synchronization settings. For example, add in crontab: (Remember to manage the scheduled tasks.)

0 * * * */usr/sbin/ntpdate time source of IP 12 point synchronization.


6.NTP related configuration and file directory

/etc/ntp.conf the NTP configuration file.

/usr/share/zoneinfo/directory for each time zone file

/etc/sysconfig/clock Linux boot will read the time to use here.

        /etc/localtime         local time call, will read the time zone's configuration, and then the corresponding timezone to copy.

        /etc/timezone         Modifying the system time zone


configuration:

    

[Email protected] ~]# vi/etc/ntp.conf
# 1. About the Permission Settings section
# The setting of the permission is mainly set by the Restrict parameter, the main syntax is:
# Restrict IP Mask netmask_ip parameter
# where IP can be a software address or default, default is similar to 0.0.0.0
# As for the paramter, there are:
# Ignore: Turn off all NTP Online Services
# Nomodify: Indicates that the client side cannot change the server-side time parameter, however, the client side can still be on the server side to network school.

# Notrust: The client source will be treated as untrusted domain unless authenticated
# Noquery: Does not provide client-side time query

# Notrap: Do not provide trap this remote event log in

# If paramter is not set at all, it means that the IP (or domain) "has no restrictions"

Restrict default nomodify notrap noquery # Close all NTP Request packets
Restrict 127.0.0.1 #这是允许本级查询
Restrict 192.168.0.1 mask 255.255.255.0 nomodify
#在192. The server in the 168.0.1/24 network segment can be synchronized with this NTP server for time.
# 2. Settings for upper-level hosts
# to set the upper host to the main server this parameter to set, the syntax is:
# Server [ip| HOST Name] [prefer]
# The server is followed by our upper time server! And if the Server parameter
# After adding perfer, it means that our NTP host is mainly used as the host of the
# The correspondence of the time correction. In addition, in order to resolve the delivery delay action of the update Time packet,
# so you can use Driftfile to specify our host
# The amount of time spent communicating with the Times Server can be recorded in Driftfile
# later in the file, for example, in the sample below, our NTP server is connected to the
# time spent cn.pool.ntp.org online is recorded in the/etc/ntp/drift file
Server 0.pool.ntp.org

Server 1.pool.ntp.org

Server 2.pool.ntp.org

Server cn.pool.ntp.org prefer

#其他设置值, you can use the system default value

Server 127.127.1.0 # Local clock

Fudge 127.127.1.0 Stratum 10

Driftfile/var/lib/ntp/drift
Broadcastdelay 0.008
Keys/etc/ntp/keys

Restrict is used to set access permissions, and the server is used to set up the upper-level time server, driftfile to set the file to save drift time.


Remember to check to see if NTPD is open.

[[Email protected] ~] # netstat-ln|grep 123 NTP Port 123


Ntpstat View the synchronization status.

After you turn on the service, you will need to wait a few minutes for synchronization.


NTP service, the system time is only synchronized by default. If you want NTP to synchronize hardware time simultaneously, you can set the/etc/sysconfig/ntpd file.

In the/etc/sysconfig/ntpd file, add Sync_hwclock=yes This allows the hardware time to synchronize with the system time.



ntpd is smooth. The ntpdate is decisive.

If you feel that ntpd is so slow. Then make sure the business doesn't go down because of your decisiveness. Manual modification time or Ntpdate decisive synchronization.




This article is from the "love to Learn bear children" blog, please be sure to keep this source http://molilinzi.blog.51cto.com/8282931/1703845

Discussion of the time synchronization (NTP) operation under CENTOS6

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.