Linux下局域网同步时间
来源:互联网 发布:数据库服务器默认地址 编辑:程序博客网 时间:2024/05/17 03:33
- 选择一台能上外网的机器作为时间服务器(都不能上亦可以,任选一台即可,但是只能保证局域网内时间同步)
- 配置此时间服务器
- 安装 ntp
- 在 /etc/ntp.conf 中配置
restrict 127.0.0.1 //给予本机所有权限restrict -6 ::1 //不大明白,针对IPV6吗?restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap //给局域网内主机同步时间的权限,但不允许修改时间服务器的时间server 0.rhel.pool.ntp.org //时间服务器,下同server 1.rhel.pool.ntp.orgserver 2.rhel.pool.ntp.org
- 其余采用默认的配置即可
- 配置局域网内机器
- 安装 ntp
- 在 /ect/ntp.conf 中配置
- 注释掉原来的外网时间服务器,添加内网时间服务器:
server 192.168.1.100 //修改为你内网时间服务器的IP
- 注释掉原来的外网时间服务器,添加内网时间服务器:
- 设置计划任务,每小时同步一次:
vi /etc/cron.hourly/ntpdatehourly.sh添加如下内容:#!/bin/sh ntpdate 192.168.1.100
- 停掉 ntpd 服务:service ntpd stop
- 手动同步时间,在各个节点上执行: ntpdate 192.168.1.100
- 在上基础上设置间隔任意时间同步的方法:
- vi /etc/crontab,如下截图:
- 从上图可以看到定时任务指令编写的大致要求
- 我们可以用 crontab -e 添加一个新的定时任务,在弹出的新文件编辑框中输入:
*/15 * * * * ntpdate 192.168.1.100
- 然后保存退出,会提示增加了一个新任务(上面这个任务代表“没间隔15分钟向时间服务器192.168.1.100同步一次时间”)
- 可以用指令 crontab -u root -l 查看 root 用户的定时任务
- vi /etc/crontab,如下截图:
- Linux下的定时任务还是蛮有用的东西的,详细讲解见我的另一篇博客:点击这儿
- Linux下局域网同步时间
- linux在局域网下设置时间同步
- Linux实现局域网时间同步
- 局域网windows平台下时间同步
- 局域网内Linux服务器时间同步
- linux 局域网的时间同步配置
- 局域网内Linux服务器时间同步
- 局域网内Linux服务器时间同步
- Linux 局域网内服务器时间同步
- 局域网内Linux服务器时间同步
- Linux下时间同步
- 局域网中同步时间
- Linux下ntpdate时间同步
- Linux下ntpdate时间同步
- Linux下ntpdate时间同步
- Linux下ntpdate时间同步
- Linux下集群时间同步
- Linux下ntpdate时间同步
- C++语法基础--顺序容器(一)--vector,list,deque
- Matlab点除和除的区别
- 需求的粒度是项目的心跳
- 在Debian 6下安装R和Bioconductor
- 一句话
- Linux下局域网同步时间
- 浅谈windows8.1--从输入法开始
- SQL Server 排序规则
- 2013年暑假队内选拔赛题解1
- Could not load the Tomcat server configuration at \Servers\Tomcat v7.0 Server at localhost-config
- jsonc库使用
- UNIX环境高级编程——信号(API)
- 统计学习方法阅读笔记:k近邻法
- WIN7桌面出现最近访问的位置图标无法删除,如何处理