linux
  • Introduction
  • Yum
    • 基础yum源的配置
    • 为yum源配置代理
    • Centos指定版本的yum源
    • 环境变量
    • 本地yum源
    • 制作yum源
      • 同步yum源
    • epel源
  • Iptables
    • 基本匹配条件
    • Match-Extensions
      • Addrtype
      • Set
      • TCP
    • Target-Extensions
      • DNAT
      • LOG
    • Iptables规则持久化
    • 连接追踪
  • LVS
    • Ipvsadm命令
  • 磁盘与分区
    • 创建分区
    • 格式化与挂载
    • fstab
    • LVM
      • LVM扩容
    • swap分区
    • tmpfs
  • 网络相关
    • 重命名网卡
    • resolv.conf
    • Tcpdump
    • dig与nslookup
  • Other
    • CPU与内存
    • 进程
      • 僵尸进程
    • SSH密钥登录
    • 用户管理
    • Crontab
  • Nofile
    • 原理
  • 常用软件安装篇
    • MYSQL
    • 系统与内核
      • 指定内核启动
    • NFS
    • Haproxy
    • Keepalived
    • Squid
    • Redsocks
    • Shadowsocks
    • 时钟同步
  • 内存
Powered by GitBook
On this page
  • 向外网服务器进行同步
  • 1、安装ntpdate
  • 2、设置时区
  • 3、设置crontab

Was this helpful?

  1. 常用软件安装篇

时钟同步

本文介绍时钟同步工具ntpdate的安装。

假设有三台主机M1、M2、M3,要进行时钟同步。有两种方案,一是三台主机能连外网,那么可以让它们向外网的时钟服务器进行同步

向外网服务器进行同步

1、安装ntpdate

在三台主机上都安装ntpdate

$ yum -y install ntpdate

2、设置时区

把三台主机的时区设置为北京时间(东八区)

$ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

3、设置crontab

我们可以手动执行命令ntpdate cn.pool.ntp.org来手动向服务器cn.pool.ntp.org进行时钟同步。外部服务器有很多,比如cn.pool.ntp.org、us.pool.ntp.org等等。

当然,上面的命令是手动同步的,我们可以在三台主机上设置一个定时任务,周期性同步时间,如下设置每10分钟同步一次

*/10 * * * * ntpdate cn.pool.ntp.org
PreviousShadowsocksNext内存

Last updated 5 years ago

Was this helpful?