In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
preface
When multi-hosts work together, time synchronization of each host is very important. Time inconsistency will cause many important applications to fail, such as encryption protocols, logs, clusters, etc. NTP(Network Time Protocol) is used to synchronize the time of computers in a network.
Environment system selinux, firewalld implementation server-side client CentOS7 closed chrony172.20.3.34172.20.200.200chrony Introduction
Free software that implements NTP protocol. Clock can be synchronized with NTP servers, reference clocks (e.g. GPS receivers), and manual input via chronyc using watches and keyboards. It can also act as an NTPv4 (RFC 5905) server and peer to it to provide time services to other computers in the network. Designed to function well under a variety of conditions, including intermittent and highly congested network connections, temperature variations (computer clocks are sensitive to temperature), and systems that cannot run continuously or on virtual machines. The typical accuracy between two machines synchronized over the Internet is within milliseconds, and on a LAN, the accuracy is typically tens of microseconds. Sub-microsecond accuracy can be achieved using hardware timestamps or hardware reference clocks.
Chrony Official Website: chrony.tuxfamily.org
Advantages Faster synchronization takes minutes rather than hours, minimizing time and frequency errors and is useful for virtual machines that are not running 24 hours a day. Being able to respond better to rapid changes in clock frequency is useful for virtual machines with unstable clocks or energy-saving technologies that cause clock frequency changes. After initial synchronization, it does not stop the clock to prevent impact on applications that require system time to remain monotonous. Provides better stability when dealing with temporary asymmetric delays (e.g., when massive downloads cause link saturation). No periodic polling of servers is required, so systems with intermittent network connectivity can still synchronize clocks quickly. Information about software packages and services
Package: chrony-3.4-1.el7.x86_64
Listening port: 323/udp, 123/udp
Service unit file: /usr/lib/systemd/system/chronyd.service
Two main programs: chronyd and chronyc
chronyd: daemon running in the background to adjust the system clock and clock service running in the kernel chronyc: command-line user tool for monitoring performance and making various configurations. It can work on a computer controlled by chronyd samples, or it can work on a different remote computer. Configuration file: /etc/chrony.conf Related parameter explanation server -can be used for clock server, iburst option When the server is reachable, send one of eight data
packet rather than the usual one. packet interval is usually 2 seconds, which speeds up initial synchronization driftfile -calculates the ratio of computer increase and decrease time based on actual time, records it in a file,
rtcsync -enables kernel mode, system time is copied to real-time clock (RTC) every 11 minutes allow / deny -specifies a host, subnet Or the network to allow or deny access to this server cmdallow / cmddeny -can specify which host can use the control command bindcmdaddress through chronyd-allows chronyd to listen on which interface to receive commands executed by chronyc makestep -usually chronyd will slow down or speed up the clock as needed, so that the system gradually corrects.
All time deviations. Under certain circumstances, the system clock may drift too fast, causing the adjustment to overshoot
It takes a long time to correct the system clock. This command forces chronyd to be greater than a certain valve during the adjustment period
local stratum 10 -Allows local time to be adjusted even if the time server in the server directive is unavailable
chronyc command related parameter explanation help command can view more chronyc interactive command accheck check whether the current server activity is accessible to a specific host shows how many NTP sources are online/offline sources [-v] shows synchronization information for the current time source sourcestats [-v] display synchronization statistics for the current time source add server manually add a new NTP server clients report a list of clients that have visited this server delete manually remove NTP server or peer server settime manually set daemon time tracking display system time information public NTP service pool.ntp.org: project is a virtual cluster that provides reliable and easy-to-use NTP service cn.pool.ntp.org0-3.cn.pool.ntp.org Aliyun public NTP server Unix/linux classes: ntp.aliyun.com,ntp1-7.aliyun.comwindows classes: time.pool.aliyun.com University ntp service s1a.time.edu.cn Beijing University of Posts and Telecommunications s1b.time.edu.cn Tsinghua University s1c.time.edu.cn Beijing University National Time Service Center Server 210.72.145.44chrony Time Synchronization Implementation Steps Server Configuration (172.20.3.34)[root@CentOS7 ~]# egrep "^server| ^allow| ^local" /etc/chrony.conf server ntp.aliyun.com iburstserver ntp1.aliyun.com iburstlow s1a.time.edu.cn 172.20.0.0/16local stratum 10[root@CentOS7 ~]# systemctl restart chronyd[root@CentOS7 ~]# systemctl enable chronyd Notes: allow 172.20.0.0/16 indicates which hosts can synchronize time to that host;local stratum 10 indicates that time services are still provided using local time when the Internet cannot access the time server. Client Configuration (172.20.200.200)[root@CentOS7 ~]#grep "^server" /etc/chrony.conf server 172.20.3.34 iburst[root@CentOS7 ~]#systemctl restart chronyd[root@CentOS7 ~]#systemctl enable chronyd Verify time synchronization
1. View the current synchronized time source information of the server
2. View a list of clients that have visited the server
3. View currently synchronized time source information on client
4. The client deliberately sets the time to 1 year ago, and then sees if it can automatically synchronize the time of the server
[root@CentOS7 ~]#ifconfig eth0| awk -F"[ ]+" 'NR==2{print $3}'172.20.200.200[root@CentOS7 ~]#date -s '-1 -year'Mon Nov 12 17:45:03 CST 2018[root@CentOS7 ~]#systemctl restart chronyd[root@CentOS7 ~]# pssh -h hosts.txt -i date[1] 17:53:16 [SUCCESS] 172.20.3.34Tue Nov 12 17:53:16 CST 2019[2] 17:53:16 [SUCCESS] 172.20.200.200Tue Nov 12 17:53:16 CST 2019 time tool timedatetl
View date time, time zone and NTP status
[root@CentOS7 ~]# timedatectl Local time: Tue 2019-11-12 17:49:16 CST Universal time: Tue 2019-11-12 09:49:16 UTC RTC time: Tue 2019-11-12 09:49:16 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yesNTP synchronized: yes RTC in local TZ: no DST active: n/a
View list of time zones
[root@CentOS7 ~]# timedatectl list-timezones
modified the time zone
timedatectl set-timezone Asia/Shanghai
Date and time of modification
timedatectl set-time "2019-11-12 18:30:00"
Start NTP
timedatectl set-ntp true/flase
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.