NTP server build and client settings

Source: Internet
Author: User

The server is very time-critical, the generation of Linux server files, logs, and database connections are based on the logic of time

Task processing, if the time is not synchronized, then, the processing of the task, and the analysis of the problem log, the time is wrong, difficult to analyze

Directly change the Linux server time, the impact is particularly large, we all know that the server farm startup is regular, if you arbitrarily change the Linux server time

is likely to cause time logic station, causing other module alarm, as well as database alarm, and so on, before building the server, first configure the NTP server,

Some servers in order to be safe from the Internet, so we can not synchronize network time, so we let it synchronize my local area network NTP server, the following is the setting of related commands

[email protected] ~]# Cat/etc/sysconfig/clock #查看服务器现在在哪个时区
# The time zone of the system is defined by the contents of/etc/localtime.
# This file was only for evaluation by System-config-date, does not rely in its
# contents elsewhere.
Zone= "Asia/shanghai"

[email protected] ~]# ls/usr/share/zoneinfo/america/ #查看有哪些时区

[email protected] ~]# Yum list ntp\* #查看是否有ntp RPM Package

[email protected] ~]# more/etc/ntp.conf # Check the NTP server profile, or you can modify the online NTP server Education Network, many

[email protected] ~]# chkconfig ntpd on #启动ntp Services        

[email protected] ~]# Netstat-ntulp |grep 123 #查看ntp服务端口号upd 123 is started    
UDP 0 0 192.168.1.7:123 0.0.0.0:* 1659/ntpd
UDP 0 0 127.0.0.1:123 0.0.0.0:* 1659/ntpd
UDP 0 0 0.0.0.0:123 0.0.0.0:* 1659/ntpd
UDP 0 0:: 1:123:::* 1659/ntpd
UDP 0 0 fe80::20c:29ff:fe79:38bb:123:::* 1659/ntpd
UDP 0 0::: 123:::* 1659/ntpd

[[email protected "~]# iptables-i INPUT 1-p UDP--dport 123-j accept     #防火强打开upd123 port, let other servers synchronize time
[[email protected "~]# service iptables save      #保存防火墙配置
Iptables: Save firewall rules to/etc/sysconfig/iptables:[OK]

[email protected] ~]# ntpq-p #打印现在的ntp connection Information
Remote refID St T when poll reach delay offset jitter
==============================================================================
*dns1.synet.edu. 202.118.1.46 2 U 106 128 257 60.571 2.864 4.041
+gus.buptnet.edu 202.112.10.60 3 u 319 128 174 64.985 10.104 36.470
+dns2.synet.edu. 202.118.1.46 2 U 130 128 267 51.183 8.805 54.378

The client settings synchronize the NTP server command as follows

-bash-4.1# ntpdate 192.168.1.7         & nbsp     #同步自己建的192.168.1.7 This NTP server, results error
April 13:28:21 ntpdate[27058]: The NTP socket is on use, exiting
-bash-4.1# Service ntpd stop                   #关闭客户端ntpd服务器, let him not synchronize with NTP server, let it synchronize as NTP client you 192.168.1.7 NTP server
shutting down ntpd: [OK]
-bash-4.1# ntpdate 192.168.1.7               #同步时间, the NTP server is now synchronized for 192.168.1.7, and the return value indicates a successful synchronization
APR 13:29:02 ntpdate[27076]: Adjust time server 192.168.1.7 offset 0.005925 sec

-bash-4.1# Vi/etc/crontab #加入循环执行任务里面, automatic sync time 2:15 daily

2 * * * root/usr/sbin/ntpdate 192.168.0.20 &&/sbin/hwclock-w

NTP server build and client settings

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.