A method of setting time synchronization on servers on various Linux systems

Source: Internet
Author: User
Tags pack web services centos vps

Standalone host

Rm-rf/etc/localtime

Ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime #修改时区到东8区.

Date-r #查看的时区设置.

Next, adjust the system time to time server synchronization

The Debian system installs the NTP school pack:

The code is as follows:

Apt-get Install Ntpdate #安装ntp

CentOS System Install NTP time pack:

The code is as follows:

Yum-y Install ntpdate NTP #安装ntp

Ubuntu System installs the NTP time pack:

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: http://www.pool.ntp.org/

I changed it:

The code is as follows:

Server cn.pool.ntp.org//This China's NTP server

Server time-a.nist.gov

Server time.windows.com

Server time.nist.gov

Then save the exit (vi exit method see: http://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 #调试查看时间差异

Ntpdate cn.pool.ntp.org #同步时间

Date-r # Check if time is synchronized

To modify the configuration file for NTP

The code is as follows:

Vi/etc/sysconfig/ntpd

Sync_hwclock=yes #同步独立主机的硬件时钟

#配置开机启动ntp服务, regular sync time

Chkconfig--levels 235 ntpd on #启动ntp同步

/ETC/INIT.D/NTPD start

XEN VPS

It is best to install NTP service, which can solve the problem that the VPS does not allow time after reboot. Sometimes, depending on the hen's hardware clock, it's always seven or eight minutes short. I can't do it. Just a lot of web services, such as Google Authenticator, if the time is not synchronized, will lead to an unverifiable point, the nature of the site is not on the landing.

The code is as follows:

Rm-rf/etc/localtime

Ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime #修改时区到东8区.

Date-r #查看的时区设置.

Next, adjust the system time to time server synchronization

The Debian system installs the NTP school pack:

The code is as follows:

Apt-get Install Ntpdate #安装ntp

CentOS System Install NTP time pack:

The code is as follows:

Yum-y Install ntpdate NTP #安装ntp

Ubuntu System installs the NTP time pack:

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: http://www.pool.ntp.org/

I changed it:

The code is as follows:

Server cn.pool.ntp.org//This China's NTP server

Server time-a.nist.gov

Server time.windows.com

Server time.nist.gov

Then save the exit (vi exit method see: http://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 #调试查看时间差异

Ntpdate cn.pool.ntp.org #同步时间

Date-r # Check if time is synchronized

#配置开机启动ntp服务, regular sync time

Chkconfig--levels 235 ntpd on #启动ntp同步

/ETC/INIT.D/NTPD start

#先设置XEN VPS Usage and system-independent time mode

Echo 1 >/proc/sys/xen/independent_wallclock

Then try the above stand-alone host configuration method. After the configuration time is correct, edit the system configuration file so that the configuration is permanently in effect.

The code is as follows:

Vi/etc/sysctl.conf

Xen.independent_wallclock=1 #在文件中增加并且保存

OpenVZ VPS

(Burst VPS adopted)

OpenVZ VPS directly from the physical machine read time does not allow the host to make time changes, you only need to modify time zone. I have not used OpenVZ VPS, so it is not clear if you can use NTP service, you may try to install an NTP service to see. If you can, please let me know.

The code is as follows:

Rm-rf/etc/localtime

Ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime #修改时区到东8区.

Date-r #查看时间和时区

At this point if the time and timezone are correct, configuration success, time if not, need to contact the technical support of the host provider, let them put the hen (physical machine) time synchronization, your VPS time will be normal.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.