安装libressl后升级ntp
NTP 是网络时间协议(Network Time Protocol)的简称
生成libssl.so.10和libcrypto.so.10文件
一.强制卸载OpenSSL:
rpm -e --nodeps openssl
二.卸载后重装OpenSSL提示:
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
libssl.so.10: cannot open shared object file: No such file or directory
Please install a package which provides this module, or
verify that the module is installed correctly.
It’s possible that the above module doesn’t match the
current version of Python, which is:
2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
三.解决方案
1.下载:https://www.openssl.org/source/old/1.0.1/openssl-1.0.1e.tar.gz 上传到服务器,
1 2 3 4 5 6 7 8 9 | tar xvf openssl-1.0.1e. tar .gz cd openssl-1.0.1e . /config shared zlib-dynamic #生成Makefile文件 make #生成libssl.so.1.0.0 和 libcrypto.so.1.0.0 cp libssl.so.1.0.0 /usr/lib64 cp libcrypto.so.1.0.0 /usr/lib64 cd /usr/lib64 ln -s libssl.so.1.0.0 libssl.so.10 ln -s libcrypto.so.1.0.0 libcrypto.so.10 |
编译安装ntp
./configure --prefix=/usr/local/ntp --bindir=/usr/sbin --sysconfdir=/etc
make && make install
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #!/bin/bash # chkconfig: - 58 74 . /etc/init .d /functions . /etc/sysconfig/network prog=ntpd lockfile= /var/lock/subsys/ $prog start() { [ "$EUID" != "0" ] && exit 4 [ "$NETWORKING" = "no" ] && exit 1 [ -x /usr/sbin/ntpd ] || exit 5 [ -f /etc/sysconfig/ntpd ] || exit 6 . /etc/sysconfig/ntpd # Start daemons. echo -n $ "Starting $prog: " daemon $prog $OPTIONS RETVAL=$? echo [ $RETVAL - eq 0 ] && touch $lockfile return $RETVAL } stop() { [ "$EUID" != "0" ] && exit 4 echo -n $ "Shutting down $prog: " killproc $prog RETVAL=$? echo [ $RETVAL - eq 0 ] && rm -f $lockfile return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $prog ;; restart|force-reload) stop start ;; try-restart|condrestart) if status $prog > /dev/null ; then stop start fi ;; reload) exit 3 ;; *) echo $ "Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 esac |
配置文件介绍
1 2 3 4 | #系统时间与BIOS事件的偏差记录 driftfile /etc/ntp/drift #设定NTP主机来源(其中prefer表示优先主机) server 192.168.7.49 prefer |
restrict 控制相关权限。
语法为: restrict IP地址 mask 子网掩码 参数
其中IP地址也可以是default ,default 就是指所有的IP
参数有以下几个:
1 2 3 4 5 6 7 8 | ignore :关闭所有的 NTP 联机服务 nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。 notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网 noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器 notrap :不提供 trap 远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。 nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟 kod : 访问违规时发送 KoD 包。 restrict -6 表示IPV6地址的权限设置。 |
客户机与服务器时间同步
[root@cdh2 ~]# ntpdate -u 192.168.20.134
-
查看时间是否同步
[root@cdh2 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
cdh1 LOCAL(0) 6 u 14 64 3 1.092 9.130 3.475
1 2 3 4 5 6 7 8 9 | remote #列出源的 IP 地址或主机名,“+”表示优先,“*”表示次优先 refid #参考上一层ntp主机地址 st #stratum阶层 when #多少秒前曾经同步过时间 poll #指出轮询间隔时间。该值会根据本地时钟的精度相应增加。 reach #是一个八进制数字,指出源的可存取性。值 377 表示源已应答了前八个连续轮询。 delay #网络延迟 offset #是源时钟与本地时钟的时间差(毫秒) jitter #系统时间与bios时间差 |
查看时间,东部标准时间 (EST),这样会导致看到的时间不一致,需要修改时区。
1 2 3 4 5 6 7 8 | # date 2019年 01月 04日 星期五 04:12:05 EST # dpkg-reconfigure tzdata #更改时区 # date #查看当前系统时间 2019年 01月 04日 星期五 17:59:20 CST hwclock #查看当前硬件时间 date -s "2018-01-01 11:20:30" #设置系统时间,字符串形式 hwclock --systohc #将系统时间同步到硬件 |
ntpd、ntpdate的区别
ntpd可以是服务端,也可以是客户端,平滑同步
ntpdate立即同步,在生产环境中慎用ntpdate,也正如此两者不可同时运行。
由于是跳变,而不是使时间变快或变慢,依赖时序的程序会出错(例如,如果ntpdate发现你的时间快了,则可能会经历两个相同的时刻,对某些应用而言,这是致命的)。因而,唯一一个可以令时间发生跳变的点,是计算机刚刚启动,但还没有启动很多服务的那个时候。其余的时候,理想的做法是使用ntpd来校准时钟,而不是调整计算机时钟上的时间。
NTPD 在和时间服务器的同步过程中,会把 BIOS 计时器的振荡频率偏差——或者说 Local Clock 的自然漂移(drift)——记录下来。这样即使网络有问题,本机仍然能维持一个相当精确的走时。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现