服务器一旦横向扩张,一发不可收拾 . 但如果集群的时间不统一,反映到应用上,就可能出现很多奇怪又麻烦的问题 ...
安装 yum install ntp rpm -ivh ntp-xxxx.i386.rpm or ntp-xxxx.x86_64.rpm
编译配置文件
restrict default kod
nomodify notrap nopeer noquery restrict -6 default kod nomodify
notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1
# 用restrict控管权限
# nomodify - 用户端不能更改ntp服务器的时间参数
# noquery - 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
# notrap - 不提供trap远端登陆 # 控制IP段访问权限 restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap
# 用server设定上层ntp服务器,“prefer”表示优先
server time-C.timefreq.bldrdoc.gov prefer server 0.rhel.pool.ntp.org server
1.rhel.pool.ntp.org server
2.rhel.pool.ntp.org
# 系统时间与bios事件的偏差记录 driftfile /var/lib/ntp/drift keys /etc/ntp/keys
# 日志 logfile /var/log/ntp.log broadcastdelay 0.008 一些维护命令 service ntpd start/stop/restart #启动/停止/重启 服务 ntpstat
#查看ntp服务器有无和上层连通 ntptrace -n 127.0.0.1
#查看ntp服务器与上层间的联系 ntpq -p
#查看ntp服务器与上层ntp服务器的状态 remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先 refid - 参考上一层ntp主机地址 st - stratum阶层 when - 多少秒前曾经同步过时间 poll - 下次更新在多少秒后 reach - 已经向上层ntp服务器要求更新的次数 delay - 网络延迟 offset - 时间补偿 jitter - 系统时间与bios时间差客户端时间同步
1. 1.1ntpdate [IP_Address] ntpdate只运行一次就结束。所以要使用ntpdate同步时间的话要将该命令写入cron中。 5 * * * * root ntpdate 192.168.1.5 && hwclock -w hwclock [--adjust][--debug][--directisa][--hctosys][--show][--systohc][--test] [--utc][--version][--set --date=] 在Linux中有硬件时钟与系统时钟等两种时钟。
硬件时钟是指主机板上的时钟设备,也就是通常可在BIOS画面设定的时钟。系统时钟则是指 kernel中的时钟。当Linux启动时,系统时钟会去读取硬件时钟的设定,之后系统时钟即独立运作。所有Linux相关指令与函数都是读取系统时钟的设定。
1.2 ntpdate同步时间是跳跃的,时间立即同步,这将可能导致文件时间标记、监控数据的紊乱。
2. 使用ntpd服务
2.1 ntpd服务始终运行,定期同步时间。
2.2 ntpd服务是慢慢改变时间直至标准时间。
2.3 如果系统时间与bios时间差异超过30分钟,ntpd就会报错
安装 yum install ntp rpm -ivh ntp-xxxx.i386.rpm or ntp-xxxx.x86_64.rpm
编译配置文件
restrict default kod
nomodify notrap nopeer noquery restrict -6 default kod nomodify
notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1
# 用restrict控管权限
# nomodify - 用户端不能更改ntp服务器的时间参数
# noquery - 用户端不能使用ntpq,ntpc等命令来查询ntp服务器
# notrap - 不提供trap远端登陆 # 控制IP段访问权限 restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap
# 用server设定上层ntp服务器,“prefer”表示优先
server time-C.timefreq.bldrdoc.gov prefer server 0.rhel.pool.ntp.org server
1.rhel.pool.ntp.org server
2.rhel.pool.ntp.org
# 系统时间与bios事件的偏差记录 driftfile /var/lib/ntp/drift keys /etc/ntp/keys
# 日志 logfile /var/log/ntp.log broadcastdelay 0.008 一些维护命令 service ntpd start/stop/restart #启动/停止/重启 服务 ntpstat
#查看ntp服务器有无和上层连通 ntptrace -n 127.0.0.1
#查看ntp服务器与上层间的联系 ntpq -p
#查看ntp服务器与上层ntp服务器的状态 remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先 refid - 参考上一层ntp主机地址 st - stratum阶层 when - 多少秒前曾经同步过时间 poll - 下次更新在多少秒后 reach - 已经向上层ntp服务器要求更新的次数 delay - 网络延迟 offset - 时间补偿 jitter - 系统时间与bios时间差客户端时间同步
1. 1.1ntpdate [IP_Address] ntpdate只运行一次就结束。所以要使用ntpdate同步时间的话要将该命令写入cron中。 5 * * * * root ntpdate 192.168.1.5 && hwclock -w hwclock [--adjust][--debug][--directisa][--hctosys][--show][--systohc][--test] [--utc][--version][--set --date=] 在Linux中有硬件时钟与系统时钟等两种时钟。
硬件时钟是指主机板上的时钟设备,也就是通常可在BIOS画面设定的时钟。系统时钟则是指 kernel中的时钟。当Linux启动时,系统时钟会去读取硬件时钟的设定,之后系统时钟即独立运作。所有Linux相关指令与函数都是读取系统时钟的设定。
1.2 ntpdate同步时间是跳跃的,时间立即同步,这将可能导致文件时间标记、监控数据的紊乱。
2. 使用ntpd服务
2.1 ntpd服务始终运行,定期同步时间。
2.2 ntpd服务是慢慢改变时间直至标准时间。
2.3 如果系统时间与bios时间差异超过30分钟,ntpd就会报错
如果你恨他.....
洗车跟我学













