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

背景最近阿里云会迁移IDC机房,整理Linux wiki线,简单录下来备用~固定# 默认已经安装$ yum install -y chrony配置文件$ cat /etc/chrony.conf# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://***.pool.ntp.org/join.html)....

背景

最近阿里云会迁移IDC机房,整理Linux wiki线,简单录下来备用~

固定

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

配置文件

$ cat /etc/chrony.conf# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://***.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.***kestep 1.0 3# Enable kernel synchronization of the real-time clock (RTC).rtcsync# Enable hardware timestamping on all inte***ces 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 infor***tion 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 ***kestep

手动设置时间

# 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

本文来自早川希奈子投稿,不代表舒华文档立场,如若转载,请注明出处:https://www.chinashuhua.cn/24/526355.html

打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
() 0
上一篇 04-30
下一篇 04-30

相关推荐

  • centos7命令行网络配置命令 centos7 命令行

    通过我对Linux的基础学习之旅,逐渐把我对Linux的学习过程和对Linux系统的学习心得分享给我这样的初学者。分享内容如有问题,欢迎批评指出!!!上一部分介绍了VMWare下CentOS系统的网络配置。本文将介绍如何通过命令行配置网络,主要针对系统最小化安装模式的网络设置。注:以

    2023-07-16 21:57:01
    939 0
  • centos7打开防火墙端口 centos7防火墙开放端口

    为了服务器的安全,建议打开防火墙,但此时某些服务将无法访问。你可以用下面的方法打开你需要的端口号。1]首先检查防火墙状态。firewall-cmd --state如果出现以下情况:防火墙已关闭。not running下面是centos7关闭防火墙的方法:关闭防火墙:systemctl stop firewalld.service

    2023-07-16 10:12:01
    435 0
  • centos7忘记密码怎么办 centos7进入单用户模式修改root密码

    最近有一台很久没用的Centos 7.2系统电脑。打开试了几次常用密码,都无***常登录。以下是我修改密码的做法。1.centos7的grub2接口会有两个入口,正常系统入口和救援模式;2.修改grub2引导Centos7系统正常系统入口按“E”,会进入编辑模式,搜索以linux16开头的行ro;把ro改成

    2023-07-03 00:36:01
    268 0
  • centos7查看防火墙状态的命令 centos7查看防火墙是否开启

    centos7如何检查防火墙是否在运行?方法1:系统状态防火墙d打开、关闭和禁用防火墙的命令(1)设置启动启用防火墙:system CTL enable firewall d . service(2)设置启动禁用防火墙:system CTL disable firewall d . service(3)启动防火墙:systemctl启动防火墙(4)关闭防火墙:syste

    2023-06-10 07:55:01
    805 0

评论列表

联系我们

在线咨询: QQ交谈

邮件:admin@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信