所有节点都要确保已安装ntpd(在步骤4已安装)

1.首先选择一台服务器作为时间服务器。

假设选定为node1.sunny.cn服务器为时间服务器。

2.ntp服务器的配置

修改ntp.conf文件:

 vi /etc/ntp.conf

一共修改三处内容,将#去掉,并且将网段修改正确。

  restrict 192.168.2.2  mask 192.168.2.255  nomodify notrap

将以下4个server进行#注释掉。

#server 0.centos.pool.ntp.org iburst

#server 1.centos.pool.ntp.org iburst

#server 2.centos.pool.ntp.org iburst

#server 3.centos.pool.ntp.org iburst

最后添加俩句话:

server 127.127.1.0 #local clock

fudge  127.127.1.0 stratum 10

3.编辑/etc/sysconfig/ntpd文件,替换为以下内容

vim /etc/sysconfig/ntpd

# Drop root to id 'ntp:ntp' by default.

SYNC_HWCLOCK=yes

OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"

4.设置正确时间,启动ntpd服务,并且设置开机启动

可以忽略这步

date -s ‘2017-01-01 01:01:01’

启动服务

service ntpd start

在/etc/rc.local中添加如下ntp服务器的启动命令行

/etc/init.d/ntpd start

5.root账户下在每个需要同步的子节点编写crontab任务。

命令:

crontab -e

输入以下内容:

 0-59/10 * * * * /usr/sbin/ntpdate node1.sunny.cn

这个任务的意义就是每10分钟和node1同步时间。

6.执行/usr/sbin/ntpdate node1.sunny.cn立刻同步服务器时间。

【同步时间】Linux设置时间同步的更多相关文章

  1. 同步时间linux

    针对对时间要求精确度高的服务器 1.安装时间服务器yum install ntp 2.同步时间ntpdate time.nist.gov 3.设置计划任务每隔10分钟同步一次 */10 * * * * ...

  2. linux 设置与网络同步的时间

    #设置linux时间 与网络时间同步安装命令yum install -y ntp同步网络时间ntpdate ntp1.aliyun.com

  3. linux设置时区同步时间

    linux设置时区同步时间 一.运行tzselect sudo tzselect 在这里我们选择亚洲 Asia,确认之后选择中国(China),最后选择北京(Beijing) 如图:   二.复制文件 ...

  4. Linux 同步时间 设置时区

    简化版 同步时间 #直接用域名同步中国上海时间 ntpdate -u ntp.api.bz # hwclock --hctosys 或者 # clock --hctosys hc代表硬件时间,sys代 ...

  5. linux设置时区和自动同步时间

    1.设置时区 编辑 /etc/sysconfig/clock 修改 ZONE="Asia/Shanghai" 然后  cp  /usr/share/zoneinfo/Asia/Sh ...

  6. linux 下使rdate命令支持ipv6 ntp server 同步时间

    如果使用linux 下,busybox自带的rdate命令 去ipv6 的ntp server 同步时间的话,会提示invalid argument :无效参数. 那么现在下载rdate的源码并对其进 ...

  7. 同步两台linux服务器时间同步方案

    Linux自带了ntp服务 -- /etc/init.d/ntpd,这个服务不仅可以设置让本机和某台/某些机器做时间同步,他本身还可以扮演一个time server的角色,让其他机器和他同步时间. 配 ...

  8. linux设置时间服务器

    对多个linux服务器,时间保持一致是很必要的.根据精确度要求,应该有相应的时间间隔进行时间同步.如果不进行时间同步,时间久了就会差别很大,遇到问题时定位就很困难.因为多台设备的配合,log之间可能有 ...

  9. 转载:linux同步时间信息

    Linux - CentOS7上的时间同步 1. 时区的概念 1.1 时区简介 地球是自西向东自转,东边比西边先看到太阳,东边的时间也比西边的早.东边时刻与西边时刻的差值不仅要以时计,而且还要以分和秒 ...

随机推荐

  1. LeetCode——Search for a Range

    Description: Given a sorted array of integers, find the starting and ending position of a given targ ...

  2. 关于线上js报错问题的思考

    1.有没有可能对线上报错进行实时监控,只要线上报错出现就会以邮件的形式发出来. 2.有没有可能将每个模块和开发者联系起来,只要报错就直接报给开发者

  3. JZOJ.5328【NOIP2017模拟8.22】世界线

    Description

  4. web移动端一些常用知识

    1.去掉 a,input 在移动端浏览器中的默认样式(半透明灰色遮罩阴影) a,button,input,optgroup,select,textarea { -webkit-tap-highligh ...

  5. 【BZOJ4195】[Noi2015]程序自动分析 并查集

    [BZOJ4195][Noi2015]程序自动分析 Description 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3 ...

  6. C#如何判断程序调用的exe已结束

    二个方法:以运行系统记事本为例 方法一:这种方法会阻塞当前进程,直到运行的外部程序退出System.Diagnostics.Process exep = System.Diagnostics.Proc ...

  7. 使用angular路由切换后 轮播以及iscrollJs失效的问题

    我们在使用angular的时候,路由总是最让人头疼的地方. 在这里为大家解决一些用angular来回切换遗留下的小问题 比如我们在使用ng-route时如果主页面含有轮播图,当你切换到其他页面再切回主 ...

  8. pandas的merge方法

    数据合并时可以使用merge方法,对两个dataFrame根据某一个series合并,这个方法非常好用,只要找到了合并的标准,新的数据就可以重构出来. 1.命令: pd.merge() on:列名,j ...

  9. backend community-driven web framework

    kataras/iris: The fastest backend community-driven web framework on (THIS) Earth. HTTP/2, MVC and mo ...

  10. Python之numpy基本指令

    https://blog.csdn.net/mmm305658979/article/details/78745637 # -*- coding: utf-8 -*- 多加练习才是真 import n ...