centos7时间同步命令(centos7配置时间同步服务器)

来源:国外服务器 在您之前已被浏览:1 次
导读:目前正在解读《centos7时间同步命令(centos7配置时间同步服务器)》的相关信息,《centos7时间同步命令(centos7配置时间同步服务器)》是由用户自行发布的知识型内容!下面请观看由(国外主机 - www.2bp.net)用户发布《centos7时间同步命令(centos7配置时间同步服务器)》的详细说明。
国外云主机,www.2 bp .net

背景

最近要做阿里云迁移 IDC 机房,整理下 Linux 运维基线,简单记录,以备后用~

安装

# 默认已经安装$ yum install -y chrony

配置文件

$ cat /etc/chrony.conf# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).# 国家服务器server 0.cn.pool.ntp.orgserver 1.cn.pool.ntp.orgserver 2.cn.pool.ntp.orgserver 3.cn.pool.ntp.org# 阿里server ntp.aliyun.com# 腾讯server time1.cloud.tencent.comserver time2.cloud.tencent.comserver time3.cloud.tencent.comserver time4.cloud.tencent.comserver time5.cloud.tencent.com# 苹果server time.asia.apple.com# 微软server time.windows.com# 其他server cn.ntp.org.cn# Record the rate at which the system clock gains/losses time.driftfile /var/lib/chrony/drift# Allow the system clock to be stepped in the first three updates# if its offset is larger than 1 second.makestep 1.0 3# Enable kernel synchronization of the real-time clock (RTC).rtcsync# Enable hardware timestamping on all interfaces that support it.#hwtimestamp *# Increase the minimum number of selectable sources required to adjust# the system clock.#minsources 2# Allow NTP client access from local network.#allow 192.168.0.0/16# Serve time even if not synchronized to a time source.#local stratum 10# Specify file containing keys for NTP authentication.#keyfile /etc/chrony.keys# Specify directory for log files.logdir /var/log/chrony# Select which information is logged.#log measurements statistics tracking

启动服务及时区设置

# 启动服务$ systemctl start chronyd# 开机启动$ systemctl enable chronyd# 查看当前状态$ systemctl status chronyd# 查看亚洲时区$ timedatectl list-timezones | grep Asia# 设置时区$ timedatectl set-timezone Asia/Shanghai

验证服务

# 查看现有的时间服务器$ chronyc sources -v# 查看时间服务器状态$ chronyc sourcestats -v# 显示时钟同步相关参数$ chronyc tracking# 查看当前时区及时间$ timedatectl 

手动同步时间

# 使用 ntpdate 同步时间$ ntpdate ntp.aliyun.com# chronyd 未启动时,如下命令同步时间$ chronyd -q 'server pool.ntp.org iburst'# chronyd 启动时,使用如下命令同步时间$ chronyc -a 'burst 4/4' && sleep 10 && chronyc -a makestep

手动设置时间

# date 设置时间$ date -s '2021-06-03 19:00:00'# 关闭 ntp 同步后,才可以使用 timedatectl 进行时间设置$ timedatectl set-ntp false# 设置日期和时间$ timedatectl set-time '2021-06-03 19:00:00'# 设置日期$ timedatectl set-time '2021-06-03'# 设置时间$ timedatectl set-time '19:00:00'# 设置完成后,再开启$ timedatectl set-ntp true
国外云主机,www.2 bp .net
提醒:《centos7时间同步命令(centos7配置时间同步服务器)》最后刷新时间 2023-03-27 02:22:31,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《centos7时间同步命令(centos7配置时间同步服务器)》该内容的真实性请自行鉴别。