构建NTP时间服务器
2024-10-07 16:07:03
NTP服务器是用于局域网服务器时间同步使用的,可以保证局域网所有的服务器与时间服务器的时间保持一致,某些应用对时间实时性要求高的必须统一时间。
互联网的时间服务器也有很多,例如ntpdate ntp.fudan.edu.cn 复旦大学的NTP免费提供互联网时间同步。
NTP时间服务器安装:
yum install ntp ntpdate -y 即可!
修改ntp.conf配置文件
vi /etc/ntp.conf 只修改如下两行,把#号去掉即可!
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
以守护进程启动ntpd
/etc/init.d/ntpd start 即可
(注意*: ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。)
配置时间同步客户机
crontab -e
增加一行,在每天的6点10分与时间同步服务器进行同步
10 06 * * * /usr/sbin/ntpdate ntp.pool.org的ip >>/usr/local/logs/crontab/ntpdate.log
备注:如果客户机没有ntpdate,可以yum –y install ntp 即可!
以下是ntp服务器配置文件内容(局域网NTP,如果需要跟外网同步,添加外网server即可)
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
参数详解
restrict default ignore # 关闭所有的 NTP 要求封包
restrict 127.0.0.1 # 开启内部递归网络接口 lo
restrict 192.168.0.0 mask 255.255.255.0 nomodify #在内部子网里面的客户端可以进行网络校时,但不能修改NTP服务器的时间参数。
server 198.123.30.132 #198.123.30.132作为上级时间服务器参考
restrict 198.123.30.132 #开放server 访问我们ntp服务的权限
driftfile /var/lib/ntp/drift 在与上级时间服务器联系时所花费的时间,记录在driftfile参数后面的文件内
broadcastdelay 0.008 #广播延迟时间
自此NTP服务搭建完毕,然后在所有客户端crontab里面添加如下语句:
0 0 * * * /usr/sbin/ntpdate 10.0.0.155 >>/data/logs/ntp.log 2>&1
最新文章
- 设置UITableView的separatorInset值为UIEdgeInsetsZero,分隔线不最左端显示的问题
- CentOS7 Nginx负载均衡
- Portable Basemap Server:多数据源多客户端的底图服务器
- project.VERSION_NAME定义
- Mybatis中 sequence不能自增长
- hdu3038(带权并查集)
- web storm
- php使用openssl来实现RSA(非对称加密)
- GridView如何实现双击行进行编辑,更新
- 关于oc中出现的typedef的用法/定义函数指针
- 第八章 管理类型(In .net4.5) 之 加强封装
- skill-判断浏览器
- 备份 VPS 上得内容到国内
- 无法通过 128 (在表空间 TEMP 中) 扩展 temp 段
- WinForm实现窗体最小化后小图标在右边任务栏下
- xshell 注册码
- Struts2-2.了解struts.xml>;package>;action>;result的name属性
- ANSJ中文分词使用方法
- Android签名机制---签名过程
- cookie路径问题