In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to solve centos time asynchrony". In daily operation, I believe many people have doubts about how to solve the problem of centos time asynchrony. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to solve centos time asynchrony"! Next, please follow the editor to study!
First, update the time from the time server with ntpdate
If your linux system does not have the command ntpdate at all
Yum install ntp
After the installation, you don't have to do any configuration, and you don't need to test it directly.
The code is as follows:
[root@localhost ~] # ntpdate time.nist.gov
22 Oct 21:11:43 ntpdate [5014]: adjust time server 207.200.81.113 offset-0.018788 sec
If you go out of the above description, the synchronization is successful. Then add the following to the crontab.
1.Placement 10 * ntpdate time.nist.gov # domain name or IP
Synchronize every ten minutes. Recommend several time servers.
Time.nist.gov
Time.nuri.net
Asia.pool.ntp.org
Asia.pool.ntp.org
Asia.pool.ntp.org
Asia.pool.ntp.org
Second, use ntp to build your own time server.
Above we use other people's time servers to synchronize time, these time servers are more authoritative. When we build our own time server, we don't use crontab to run regularly.
1. Install the time server ntp
1.yum install ntp
2, configure ntp
The code is as follows
[root@localhost ~] # cat / etc/ntp.conf | awk'{if ($0! ~ / ^ $/ & & $0! ~ / ^ # /) {print $0}}'
Restrict default ignore / / does not allow you to modify or query ntp by default, and does not receive special packets
Restrict 127.0.0.1 / / gives all permissions to this machine
Restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify / / machines on the LAN have permission to synchronize time
Server time.nist.gov prefer / / set time server, plus prefer means priority
Server 0.asia.pool.ntp.org
Server 1.asia.pool.ntp.org
Server 2.asia.pool.ntp.org
Server 127.127.1.0 # local clock
Fudge 127.127.1.0 stratum 10
Driftfile / var/lib/ntp/drift
Keys / etc/ntp/keys
3. Start ntp
[root@localhost ~] # / etc/init.d/ntpd start
4, view and test
The code is as follows:
[root@localhost ~] # netstat-upnl | grep ntpd / / View schedule
[root@localhost ~] # ntpq-pn / / View synchronized server IP
Remote refid st t when poll reach delay offset jitter
=
50.77.217.185.INIT .16u-64 0 0.000 0.000 0.000
202.90.158.4. Int. 16u-64 0 0.000 0.000 0.000
202.71.100.89. Int. 16u-64 0 0.000 0.000 0.000
202.134.1.10 .INIT. 16u-64 0 0.000 0.000 0.000
* 127.127.1.0. LOCL. 10 l 18 64 377 0.000 0.000 0.001
[root@localhost ~] # ntpstat / / result of synchronization
Synchronised to local net at stratum 11
Time correct to within 12 ms
Polling server every 512 s
Remote: that is, the IP or host name of the NTP host. Pay attention to the leftmost symbol. If "+" represents the upper NTP that is currently working on the clock, if it is "*", it means that it is also connected, but as a secondary online NTP host.
Refid: the address of the upper-level NTP host referenced
St: the stratum class
When: time synchronization update was done a few seconds ago
Poll: the next update is in a few seconds
Reach: the number of updates that have been requested from the upper NTP server
Delay: the time of clock delay during network transmission
Offset: the result of time compensation
Difference time between jitter:Linux system time and BIOS hardware time
Recommend the first method, although it is relatively simple to build a time server, but I do not think this is necessary. If you use someone else's time server, synchronize every 10 minutes, which can be accurate to milliseconds.
Author: undersea goshawk
Solution to the inconsistency between CentOS system time and UTC time
Install centos and find out that date is not the time we want. What should we do?
1. Vi / etc/sysconfig/clock # Editing time profile
ZONE= "Asia/Shanghai"
UTC=false # is set to false, and the hardware clock is not consistent with utc time.
ARC=false
2. The time zone of ln-sf / usr/share/zoneinfo/Asia/Shanghai / etc/localtime # linux is set to Shanghai time zone
3. Ntpdate 192.43.244.18 # alignment time
If you do not have a ntp server installed, you just need to execute the following command:
Yum install ntp # install ntp server
4. / sbin/hwclock-- systohc # set hardware time and system time consistent and calibrated
Well, our CentOS linux system time and computer hardware time are finally cst time, and both are in the Shanghai time zone, which is finally normal.
The ultimate solution of centos vps modification time and zone asynchrony
Due to the first use of domestic hyper-v architecture VPS and before buying to specify windows or centos system, because there is no reinstalled panel, for I am used to using debian is really torture, encountered a variety of minor problems in the process of operation. Ask customer service directly only understand winows environment, let you install WIN you have to install linux. Well, centos will have to fumble on his own. Because hyper-v is a virtualization product of Microsoft, it does not support linux earlier, and because of the corporate operation of debian, debian has entered a stage of rapid development, and even google has abandoned linux customization and turned to the debian development camp, which makes Microsoft feel some pressure, so Microsoft has pulled up centos, which is why hyper-v only supports centos, but does not support other linux derivative versions, and the support is not so reliable. After complaining, let's get to the point.
Topic: the time of installing lnmp in centos5.5 VPS of hyper-v architecture is out of sync, resulting in some functions of the website can not be used.
All kinds of methods found on the Internet failed. Then I looked for some documents carefully and finally got it done.
The time management of linux is strange that it is divided into system time and hardware time and subdivided into what UTC time. -_-|.
Hardware time is basically a CMOS clock.
Linux check hardware time: hwclock-- show
Linux View system time: date-R
Time and time zone synchronization for centos VPS.
System time part:
1. Edit the time zone profile: vi / etc/sysconfig/clock
ZONE= "Asia/Shanghai"
UTC=false # set UTC to false off
ARC=false
two。 Run the following command
# Delete default configuration
Rm-rf / etc/localtime
# reassign configuration
Ln-s / usr/share/zoneinfo/Asia/Shanghai / etc/localtime
# synchronize system time
Ntpdate-u pool.ntp.org
3. Hardware time part:
# adjust the hardware time to be consistent with the current system clock.
Hwclock-systohc
Or clock-- systohc
# forcing the system time to be written into CMOS to prevent restart failure
Hwclock-w
Or clock-w
Although the above steps have been successful, the time of my centos system of hyper-v architecture is not right. It can be a few minutes faster every day.
It can be solved by synchronizing the time with crontab.
# Editing the schedule
Vi / etc/crontab
# add the following line at the end of the table
30 5 * root / usr/sbin/ntpdate-u pool.ntp.org & & / sbin/clock-- systohc
# synchronize time at 05:30 every day. Clock-- systohc means hard disk time synchronizes system time.
At this point, the study on "how to solve the problem of centos time asynchrony" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.