Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up time synchronization on servers of various Linux systems

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to set time synchronization on various Linux system servers", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "how to set time synchronization on servers of various Linux systems"!

standalone host

rm -rf /etc/localtime

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #Change the time zone to East 8.

date -R #Time zone setting to view.

Next, adjust the system time to synchronize with the time server

Debian system installation NTP timing package:

The code is as follows:

apt-get install ntpdate #Install ntp

CentOS system installation NTP timing package:

The code is as follows:

yum -y install ntpdate ntp #Install ntp

Ubuntu system installation NTP timing package:

The code is as follows:

sudo apt-get install -y ntpdate ntp

Modify/etc/ntp.conf

vi /etc/ntp.conf will see the following:

The code is as follows:

server 0.centos.ntp.org

server time.windows.com

server time.nist.gov

This is the default ntp synchronization server, you can change it yourself, global ntp server address: www.pool.ntp.org/

I changed it to:

The code is as follows:

server cn.pool.ntp.org Chinese ntp server

server time-a.nist.gov

server time.windows.com

server time.nist.gov

Then save exit (vi exit method see: www.dabu.info/personal-summary-personally-i- carefully-collected-must-be-familiar-with-vim-shortcut-key-operation.html)

Then enter the following command:

The code is as follows:

ntpdate -d cn.pool.ntp.org #Debug View Time Difference

ntpdate cn.pool.ntp.org #Sync Time

date -R #Check if time is synchronized

Modify ntp configuration file

The code is as follows:

vi /etc/sysconfig/ntpd

SYNC_HWCLOCK=yes #synchronize hardware clocks of standalone hosts

#configure startup ntp service, regular synchronization time

chkconfig --levels 235 ntpd on #start ntp synchronization

/etc/init.d/ntpd start

XEN VPS

It is best to install ntp service, which can solve the problem that vps is not accurate after restarting. Sometimes, depending on the hen's hardware clock, there was always a difference of seven or eight minutes. There's no other way. Many web services, such as Google Authenticator, etc., if the time is not synchronized, it will lead to the point where it cannot be verified, and naturally the website cannot be logged on.

The code is as follows:

rm -rf /etc/localtime

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #Change the time zone to East 8.

date -R #Time zone setting to view.

Next, adjust the system time to synchronize with the time server

Debian system installation NTP timing package:

The code is as follows:

apt-get install ntpdate #Install ntp

CentOS system installation NTP timing package:

The code is as follows:

yum -y install ntpdate ntp #Install ntp

Ubuntu system installation NTP timing package:

The code is as follows:

sudo apt-get install -y ntpdate ntp

Modify/etc/ntp.conf

vi /etc/ntp.conf will see the following:

The code is as follows:

server 0.centos.ntp.org

server time.windows.com

server time.nist.gov

This is the default ntp synchronization server, you can change it yourself, global ntp server address: www.pool.ntp.org/

I changed it to:

The code is as follows:

server cn.pool.ntp.org Chinese ntp server

server time-a.nist.gov

server time.windows.com

server time.nist.gov

Then save exit (vi exit method see: www.dabu.info/personal-summary-personally-i- carefully-collected-must-be-familiar-with-vim-shortcut-key-operation.html)

Then enter the following command:

The code is as follows:

ntpdate -d cn.pool.ntp.org #Debug View Time Difference

ntpdate cn.pool.ntp.org #Sync Time

date -R #Check if time is synchronized

#configure startup ntp service, regular synchronization time

chkconfig --levels 235 ntpd on #start ntp synchronization

/etc/init.d/ntpd start

#First set XEN VPS usage and system-independent time mode

echo 1 > /proc/sys/xen/independent_wallclock

Then try the configuration method of the independent host above. By configuring the correct time, edit the system configuration file to make the configuration permanent.

The code is as follows:

vi /etc/sysctl.conf

xen.independent_wallclock=1 #Add and save to file

OpenVZ VPS

(Burst VPS adoption)

OpenVZ's VPS reads the time directly from the physical machine and does not allow time modification to the host, you only need to modify the time zone. I haven't used openvz vps yet, so I don't know if I can use ntp service. I can try installing ntp service to see. Please let me know if you can.

The code is as follows:

rm -rf /etc/localtime

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #Change the time zone to East 8.

date -R #View time and time zone

At this time, if the time and time zone are correct, the configuration is successful, if the time is not correct, you need to contact the technical support of the host service provider, let them synchronize the hen (physical machine) time, your VPS time will be normal.

At this point, I believe that everyone has a deeper understanding of "how to set time synchronization on servers of various Linux systems," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report