所有节点都要确保已安装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. MyBatis官方文档——入门

    入门 安装 要使用 MyBatis, 只需将 mybatis-x.x.x.jar 文件置于 classpath 中即可. 如果使用 Maven 来构建项目,则需将下面的 dependency 代码置于 ...

  2. 关于Android原生Email的自己的一些认识

    http://blog.csdn.net/gloryhero/article/details/47259583 Email的框架图: Email 包含3个包:Eamil.Exchagne.Unifie ...

  3. Linux系统下编译连接C源代码

    gcc test.c -o test 一步到位的编译指令 得到 test 文件 gcc test.c 得到 test.out 文件 gcc -g -c test.c -o test 只生成目标文件(. ...

  4. C#文件下载的几种方式

    第一种:最简单的超链接方法,<a>标签的href直接指向目标文件地址,这样容易暴露地址造成盗链,这里就不说了 1.<a>标签 <a href="~/Home/d ...

  5. SpringMVC XXX-servlet.xml ApplicationContext.xml

    因为直接使用了SpringMVC,所以之前一直不明白xxx-servlet.xml和applicationContext.xml是如何区别的,其实如果直接使用SpringMVC是可以不添加applic ...

  6. [shell]用shell脚本将本地文件夹与ftp上的文件夹同步

    需求说明 最近在AIX上做开发,开发机器在office网段,测试机器在lab网段,不能互相通讯,只能通过特定的ftp来传文件. 每次上传的机器都要做:登录ftp,进入我的目录,上传:下载的机器都要做: ...

  7. sqlserver字符串多行合并为一行

    --创建测试表 CREATE TABLE [dbo].[TestRows2Columns]( [Id] [,) NOT NULL, [UserName] [nvarchar]() NULL, [Sub ...

  8. try...finally的妙用

    受博文 C#中Finally的一个不太常见的用法 的启发,正好在开发中遇到这样一段代码: public bool ChangeBlogApp(Guid userID, string oldBlogAp ...

  9. Python开发【模块】:matplotlib 绘制折线图

    matplotlib 1.安装matplotlib ① linux系统安装 # 安装matplotlib模块 $ sudo apt-get install python3-matplotlib # 如 ...

  10. 初识MVCSharp

    MVCSharp其实是MVP模式 主要内容 ITask IView IController