最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux系統(tǒng)之時間同步實現(xiàn)方法

 更新時間:2025年08月28日 10:59:09   作者:江湖有緣  
本文系統(tǒng)介紹了NTP、ntpdate和chrony三種時間同步工具的使用方法,包括安裝、配置、啟動、狀態(tài)檢查及同步失敗處理,同時涵蓋手動調(diào)整時間、同步硬件時間與設置時區(qū)的操作步驟

一、使用NTP服務時間同步

1.安裝ntp

[root@node ~]# yum -y install ntp

2.啟動ntp服務

[root@node ~]# systemctl start  ntpd
[root@node ~]# systemctl enable  ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

3.查看ntp服務

[root@node ~]# systemctl status ntpd
● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-08-04 08:00:47 CST; 7h left
 Main PID: 20746 (ntpd)
    Tasks: 1
   Memory: 768.0K
   CGroup: /system.slice/ntpd.service
           └─20746 /usr/sbin/ntpd -u ntp:ntp -g

Aug 04 08:00:47 node ntpd[20746]: Listen normally on 6 lo ::1 UDP 123
Aug 04 08:00:47 node ntpd[20746]: Listen normally on 7 ens33 fe80::8a83:7297:7cb8:9934 UDP 123
Aug 04 08:00:47 node ntpd[20746]: Listening on routing socket on fd #24 for interface updates
Aug 04 08:00:47 node systemd[1]: Started Network Time Service.
Aug 04 08:00:47 node ntpd[20746]: 0.0.0.0 c016 06 restart
Aug 04 08:00:47 node ntpd[20746]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Aug 04 08:00:47 node ntpd[20746]: 0.0.0.0 c011 01 freq_not_set
Aug 04 08:00:56 node ntpd[20746]: 0.0.0.0 c61c 0c clock_step -28798.353463 s
Aug 04 00:00:57 node ntpd[20746]: 0.0.0.0 c614 04 freq_mode
Aug 04 00:00:58 node ntpd[20746]: 0.0.0.0 c618 08 no_sys_peer

4.修改ntp.conf文件

[root@node ~]# vim /etc/ntp.conf
[root@node ~]# grep server /etc/ntp.conf 
# Use public servers from the pool.ntp.org project.
#server 0.centos.pool.ntp.org iburst
server ntp.aliyun.com iburst
#broadcast 192.168.1.255 autokey	# broadcast server
#broadcast 224.0.1.1 autokey		# multicast server
#manycastserver 239.255.254.254		# manycast server

5.重啟服務

[root@node ~]# systemctl restart ntpd

6.檢查同步狀態(tài)

[root@node ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 203.107.6.88    100.107.25.114   2 u    2   64    1   30.975  149.499   0.393

二、使用ntpdate同步

1.使用ntpd命令同步

[root@node ~]# ntpdate ntp.aliyun.com
 4 Aug 00:07:17 ntpdate[20924]: adjust time server 203.107.6.88 offset -0.001543 sec

2.查看時間

[root@node ~]# date
Thu Aug  4 00:07:46 CST 2022

三、處理ntpdate同步失敗報錯處理方法

1.報錯信息

cna02:~ # ntpdate ntp1.aliyun.com
 4 Aug 07:23:41 ntpdate[18694]: the NTP socket is in use, exiting

2.處理方法

cna02:~ # service ntpd stop
Redirecting to /bin/systemctl stop ntpd.service

3.重新同步

cna02:~ # ntpdate ntp1.aliyun.com
 3 Aug 23:22:36 ntpdate[28980]: step time server 120.25.115.20 offset -28911.609110 sec

4.查看時間是否正確

cna02:~ # date
Wed Aug  3 23:22:41 CST 2022

四、使用chrony服務時間同步

1.安裝chrony

[root@node ~]# yum -y install chrony
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package chrony.x86_64 0:3.2-2.el7 will be updated
---> Package chrony.x86_64 0:3.4-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================
 Package                                  Arch                                     Version                                        Repository                              Size
===============================================================================================================================================================================
Updating:
 chrony                                   x86_64                                   3.4-1.el7                                      base                                   251 k

Transaction Summary
===============================================================================================================================================================================
Upgrade  1 Package

Total download size: 251 k
Downloading packages:
No Presto metadata available for base
chrony-3.4-1.el7.x86_64.rpm                                                                                                                             | 251 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : chrony-3.4-1.el7.x86_64                                                                                                                                     1/2 
  Cleanup    : chrony-3.2-2.el7.x86_64                                                                                                                                     2/2 
  Verifying  : chrony-3.4-1.el7.x86_64                                                                                                                                     1/2 
  Verifying  : chrony-3.2-2.el7.x86_64                                                                                                                                     2/2 

Updated:
  chrony.x86_64 0:3.4-1.el7                                                                                                                                                    

Complete!

2.啟動chrony服務

[root@node ~]# systemctl enable --now chronyd
Created symlink from /etc/systemd/system/multi-user.target.wants/chronyd.service to /usr/lib/systemd/system/chronyd.service.

3.查看chrony狀態(tài)

[root@node ~]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2022-08-04 00:12:27 CST; 29s ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 21136 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 21132 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 21134 (chronyd)
    Tasks: 1
   Memory: 364.0K
   CGroup: /system.slice/chronyd.service
           └─21134 /usr/sbin/chronyd

Aug 04 00:12:27 node systemd[1]: Starting NTP client/server...
Aug 04 00:12:27 node chronyd[21134]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Aug 04 00:12:27 node systemd[1]: Started NTP client/server.
Aug 04 00:12:35 node chronyd[21134]: Selected source 193.182.111.141
Aug 04 00:12:35 node chronyd[21134]: Source 78.46.102.180 replaced with 94.237.64.20

4.修改配置文件

[root@node ~]# grep server /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp1.aliyun.com iburst

5.重啟服務

[root@node ~]# systemctl restart chronyd

6.檢查時間同步狀態(tài)

[root@node ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 120.25.115.20                 2   6    71    26   +751us[+1549us] +/-   19ms

五、手動修改時間

1.修改時間方法1

[root@node ~]# date -s "2012-05-23 01:01:01"
Wed May 23 01:01:01 CST 2012
[root@node ~]# date
Wed May 23 01:01:05 CST 2012

2.修改時間方法2

修改時間順序為月日時分年.秒

[root@tianyi ~]# date 090621282021.28
Mon Sep  6 21:28:28 CST 2021

3.硬件時間向系統(tǒng)時間同步

[root@node ~]# hwclock -w

4.按格式輸出時間

[root@node ~]# date "+%Y-%m-%d %H:%M:%S"
2012-05-23 01:04:10

5.設置時區(qū)

[root@tianyi backups]# timedatectl list-timezones |grep Shanghai
Asia/Shanghai
[root@tianyi backups]# timedatectl set-timezone Asia/Shanghai

總結

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • linux壓縮解壓命令使用方式(無廢話版)

    linux壓縮解壓命令使用方式(無廢話版)

    本文介紹了gzip、bzip2、tar和zip四種常用的文件壓縮和打包工具的使用方法,包括它們的功能、壓縮比率、使用場景以及基本命令示例
    2024-11-11
  • Linux中對lvm邏輯卷分區(qū)大小的調(diào)整教程(針對xfs與ext4不同文件系統(tǒng))

    Linux中對lvm邏輯卷分區(qū)大小的調(diào)整教程(針對xfs與ext4不同文件系統(tǒng))

    這篇文章主要給大家介紹了關于Linux中對lvm邏輯卷分區(qū)大小的調(diào)整教程(針對xfs與ext4不同文件系統(tǒng))的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考借鑒,下面隨著小編來一起學習學習吧
    2018-10-10
  • Linux查看log日志常用命令

    Linux查看log日志常用命令

    Linux日志存儲在/var/log目錄中,我們可以編寫腳本,來掃描這些日志,并基于它們的內(nèi)容去自動執(zhí)行某些功能,Linux查看日志的命令有多種:?tail、head、cat、more、less、sed等
    2024-06-06
  • Ubuntu 16.04無法切換root權限問題的解決

    Ubuntu 16.04無法切換root權限問題的解決

    root權限相信對大家來說都不陌生,下面這篇文章主要給大家介紹了關于Ubuntu 16.04無法切換root權限問題的解決方法,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考借鑒,下面隨著小編來一起學習學習吧。
    2018-04-04
  • 80端口被占用導致Apache啟動失敗怎么解決

    80端口被占用導致Apache啟動失敗怎么解決

    80端口被占用導致Apache啟動失敗怎么解決,小編遇到很頭疼的問題,下面為大家分享一篇關于80端口被占用導致Apache啟動失敗的文章,希望可以解決大家的問題
    2017-03-03
  • Nginx 0.7.x + PHP 5.2.6(FastCGI)+ MySQL 5.1 在128M小內(nèi)存VPS服務器上的配置優(yōu)化

    Nginx 0.7.x + PHP 5.2.6(FastCGI)+ MySQL 5.1 在128M小內(nèi)存VPS服務器上的

    VPS(全稱Virtual Private Server)是利用最新虛擬化技術在一臺物理服務器上創(chuàng)建多個相互隔離的虛擬私有主機。它們以最大化的效率共享硬件、軟件許可證以及管理資源。
    2008-12-12
  • linux docker倉庫拉取失敗問題及解決方案

    linux docker倉庫拉取失敗問題及解決方案

    這篇文章主要介紹了linux docker倉庫拉取失敗問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-10-10
  • Linux中如何查看文件的創(chuàng)建時間詳解

    Linux中如何查看文件的創(chuàng)建時間詳解

    這篇文章主要給大家介紹了關于Linux中如何查看文件的創(chuàng)建時間的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Linux具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-12-12
  • linux centos7安裝ftp及用戶權限配置方式

    linux centos7安裝ftp及用戶權限配置方式

    文章介紹了如何配置用戶登錄后直接進入指定路徑,并限制用戶只能訪問該路徑,使用usermod命令設置默認目錄,確保用戶權限僅限于此目錄,并具備寫入文件的權限
    2026-05-05
  • Linux服務器選擇什么版本好

    Linux服務器選擇什么版本好

    服務器選擇什么版本的linux,這個問題是個老生常談的問題,每個月都有人討論,根據(jù)我運維過1000臺 server的經(jīng)驗,回答如下
    2014-03-03

最新評論

普定县| 新巴尔虎右旗| 隆林| 永登县| 商城县| 普定县| 南澳县| 威宁| 兴城市| 南城县| 宝清县| 房产| 桓仁| 大港区| 九龙县| 开平市| 沧州市| 中牟县| 读书| 百色市| 章丘市| 保定市| 营山县| 汪清县| 宜兰市| 临沭县| 腾冲县| 太和县| 黄梅县| 奇台县| 阜宁县| 庆云县| 南汇区| 南京市| 普陀区| 宽甸| 龙游县| 安徽省| 宁化县| 邢台市| 元江|