时间同步:

在服务器端共享时间:

vim /etc/chrony.conf

29 local stratum 10

开启时间共享功能并设定共享级别

这个参数开启后本机不去同步别人的时间到本机

22 allow 172.25.254.0/24  允许哪些客户来共享本机的时间

systemctl restart chronyd

基于linux下的时间同步

[[email protected] ~]# vim /etc/chrony.conf

[[email protected] ~]# systemctl restart chronyd

[[email protected] ~]# date

Sat Apr 14 03:04:48 EDT 2018

[[email protected] ~]# date

Sat Apr 14 03:05:24 EDT 2018

基于linux下的时间同步

在客户端:

vim /etc/chrony.conf

server 172.25.254.100 iburst

systemctl restart chronyd

基于linux下的时间同步

chronyc sources -v   查看时间同步进度

[[email protected] ~]# vim /etc/chrony.conf

[[email protected] ~]# systemctl restart chronyd

[[email protected] ~]# date

Sat Apr 14 03:04:40 EDT 2018

[[email protected] ~]# chronyc sources -v

210 Number of sources = 1

 

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.

 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,

| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.

||                                                 .- xxxx [ yyyy ] +/- zzzz

||                                                /   xxxx = adjusted offset,

||         Log2(Polling interval) -.             |    yyyy = measured offset,

||                                  \            |    zzzz = estimated error.

||                                   |           |                         

MS Name/IP address         Stratum Poll Reach LastRx Last sample

===============================================================================

^* 172.25.254.121               10   6    17    27    -12ms[  -12ms] +/-   17ms

*说明时间同步完成,如果为?检查防火墙再看看chronyd有没有重启。

基于linux下的时间同步

[[email protected] ~]# date

Sat Apr 14 03:05:17 EDT 2018

还可以使用watch -n 1 date来监控时间,可以更加直观的看到效果。

timedatectl命令:

[[email protected] Desktop]$ rht-vmctl start desktop

Starting desktop.

[[email protected] Desktop]$ rht-vmctl view desktop

[[email protected] Desktop]$ ssh [email protected]

[email protected]'s password:

Last login: Fri Apr 13 22:32:39 2018 from 172.25.254.221

[[email protected] ~]# timedatectl

      Local time: Sat 2018-04-14 04:01:58 EDT

  Universal time: Sat 2018-04-14 08:01:58 UTC

[[email protected] ~]# timedatectl list-timezones       显示时区列表

Africa/Abidjan

Africa/Accra

Africa/Addis_Ababa

Africa/Algiers

Africa/Asmara

Africa/Bamako

基于linux下的时间同步

[[email protected] ~]# timedatectl set-timezone Asia/Shanghai        更改时区为上海

[[email protected] ~]# timedatectl

      Local time: Sat 2018-04-14 16:03:28 CST

  Universal time: Sat 2018-04-14 08:03:28 UTC

        RTC time: Sat 2018-04-14 08:03:28

        Timezone: Asia/Shanghai (CST, +0800)

     NTP enabled: yes

NTP synchronized: no

 RTC in local TZ: no

      DST active: n/a

[[email protected] ~]# date

Sat Apr 14 16:03:32 CST 2018

基于linux下的时间同步

[[email protected] ~]# timedatectl set-local-rtc 0              0代表使用UTC

[[email protected] ~]# vim /etc/adjtime                         显示

基于linux下的时间同步

[[email protected] ~]# timedatectl set-local-rtc 1              1代表使用本地时间

[[email protected] ~]# vim /etc/adjtime

基于linux下的时间同步

[[email protected] ~]# timedatectl set-time "2018-11-11 11:11:11"   更改时间

[[email protected] ~]# date                             显示时间

Sun Nov 11 11:11:14 CST 2018

相关文章:

  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-11-13
  • 2021-11-13
  • 2021-09-25
猜你喜欢
  • 2022-12-23
  • 2021-08-17
  • 2021-05-17
  • 2021-07-18
  • 2021-12-25
相关资源
相似解决方案