cengos 5.5搭建NTP服务器

简介:

#为了保证应用程序层和数据库层的服务器能够同步时钟,所以要架设一台NTP服务器,让内部所有的服务器来同步NTP服务器的时钟

#检查服务器是否安装ntp
[root@ntp ~]# rpm -qa |grep ntp

#yum安装ntp
[root@ntp ~]# yum install -y ntp

#源码包安装ntp
[root@ntp ~]# wget 
http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.6p2.tar.gz
[root@ntp ~]# tar -zxvf ntp-4.2.6p2.tar.gz
[root@ntp ~]# cd ntp-4.2.6p2
[root@ntp ntp-4.2.6p2]# ./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
[root@ntp ntp-4.2.6p2]# make;make install

#让本服务器时间与time.nist.gov时间同步,使服务器为标准时间
[root@ntp ~]# ntpdate time.nist.gov

#自动同步服务器时钟
[root@ntp ~]# crontab -e
*/5 * * * * /usr/sbin/ntpdate time.nist.gov

[root@ntp ~]# service crond restart

#修改ntp配置文件
[root@ntp ~]# vi /etc/ntp.conf

# 用restrict控管权限
# nomodify - 用户端不能更改ntp服务器的时间参数
# noquery - 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
# notrap - 不提供trap远端登陆

#允许任何IP的客户机都可以进行时间同步
#restrict default nomodify notrap noquery  //注释掉这一行
restrict default nomodify

#只允许10.8.0.0网段的客户机进行时间同步
restrict default nomodify notrap noquery
restrict 10.8.0.0 mask 255.255.0.0 nomodify     //添加一行

# 以下是两个ntp服务器
restrict time.nist.gov
restrict 164.67.62.194

# 用server设定上层ntp服务器,“prefer”表示优先
server time.nist.gov prefer
server 164.67.62.194
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10

# 系统时间与bios事件的偏差记录
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

# 日志
logfile /var/log/ntp.log
broadcastdelay 0.008

#BIOS时间同步
SYNC_HWCLOCK=yes


#yum安装启动方式
[root@ntp ~]# service ntpd start

#源码包安装以守护进程启动ntpd
[root@ntp ~]# /usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid

#查看端口
[root@ntp ~]# netstat -unlnp

#iptables开启udp 123端口
[root@ntp ~]# iptables -A INPUT -p udp -m udp --dport 123 -j ACCEPT

#查看ntp服务器有无和上层连通
[root@ntp ~]# ntpstat

#查看ntp服务器与上层间的联系
[root@ntp ~]# ntptrace -n time.nist.gov
time.nist.gov: stratum 1, offset 0.000000, synch distance 0.002650, refid 'ACTS'

查看ntp服务器与上层ntp服务器的状态
[root@ntp ~]# ntpq -p

remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过时间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差

#linux客户端同步NTP服务器时钟
[root@db_1 ~]# crontab -e
*/5 * * * * /usr/sbin/ntpdate 10.8.2.10

#winsows客户端同步NTP服务器时钟



本文转自king_819 51CTO博客,原文链接:http://blog.51cto.com/kerry/394513,如需转载请自行联系原作者

相关文章
|
Ubuntu 安全 机器人
把Windows打造成一个NTP时间同步服务器
把Windows打造成一个NTP时间同步服务器
把Windows打造成一个NTP时间同步服务器
|
弹性计算 Windows
同步服务器时间NTP
在秒杀、抢券等高并发的活动中,一点点的时间延迟,也会让自己后悔莫及……
1468 0
同步服务器时间NTP
|
Ubuntu Linux 虚拟化
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
1410 0
使用阿里云镜像站NTP服务搭建NTP服务器(基于CentOS 7系统)
|
安全 Linux 网络安全
手把手教你在centos 7.4上搭建NTP服务器
手把手教你在centos 7.4上搭建NTP服务器
732 0
手把手教你在centos 7.4上搭建NTP服务器
|
测试技术 Windows
Windows下安装NTP服务器
原文:Windows下安装NTP服务器 NTP服务器介绍 NTP服务器【Network Time Protocol(NTP)】是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒)。
2954 0
|
5月前
|
Linux
CentOS7搭建ntp时钟服务器
CentOS7搭建ntp时钟服务器
667 0
|
7月前
NTP服务器时间配置
NTP服务器时间配置
157 0
|
11月前
|
安全 Linux 网络安全
Linux 时间同步 -NTP 服务器
本文主要介绍如何配置 Linux 服务器集群的时间同步,技术实现上使用 NTP 服务器和客户端同步时间。
430 0
|
Linux 网络安全
linux篇-CentOS7搭建NTP服务器
linux篇-CentOS7搭建NTP服务器
866 0
linux篇-CentOS7搭建NTP服务器