linux上ntp时钟服务器搭建

linux上ntp时钟服务器搭建,第1张

配置的时钟服务器的ip地址为192168100116

第一步  为服务器和客户机安装ntp  ntpdate

[root@sql-proxy1 app]#yum install ntp ntpdate -y第二步 查找时间同步服务器

>执行ntpdate xxxxxxxxxxxx(ntp服务器地址)。
Linux下配置NTP服务器
配置方法:
1、ntp服务安装
NTP服务在RHEL5x中式默认安装的软件包,可用rpm -qa |grep
ntp检查是否安装,如果未安装可使用如下命令安装与删除NTP服务器软件包
#使用rpm方式安装
rpm -ivh ntp-422p1-8el5i386rmp
#使用yum方式安装
yum -y install ntpi
#使用rpm方式删除
rpm -e ntp-422pl-8el5i386rpm
#使用yum方式删除
yum -y remove ntpi
2、ntp服务配置
在ntp服务安装完成后,需要修改ntp服务配置文件。ntp服务主配置文件/etc/ntpconf
21 ntp服务的启动、暂停
NTP属于system
V服务,其启动、暂停相关命令如下:
#启动
service ntpd
start
#停止
Service ntpd
stop
#重新加载
service ntpd
reload
#查看当前启动状态
service ntpd
status
22 ntp服务自动加载
设置ntp服务下一次开机运行状态可通过命令配置
#在运行级别2、3、4、5上设置为自动运行
chkconfig
ntpd on
#在运行级别2、3、4、5上设置为不自动运行
chkconfig
ntpd off
#在运行级别3、5上设置为自动运行
chkconfig
ntpd --level 35 on
#在运行级别3、5上设置为不自动运行
chkconfig
ntpd --level 35 off
23 配置信息
配置ntp,将Internet上的时间服务器作为内部标准时间来源,过程如下
1)修改/etc/ntpconf文件
restrict default kod nomodify notrap nopeer noquery
restrict 127001
restrict -6::1
restrict 19216800 mask 2552552550 nomodify notrap
restrict 19216810 mask 2552552550 nomodify notrap
#指定Internet上的时间服务器
restrict 20746232182 mask 255255255255 nomodify notrap noquery
server 20746232182
server 12712710
fudge 12712710 stratum 10
keys /etc/ntp/keys
#指定NTP服务器日志文件
logfile /var/log/ntp
2)修改/etc/ntp/stpe-tickers文件,内容如下(当ntpd服务启动时,会自动与该文件中记录的上层NTP服务进行时间校对)
20746232182
12712710
3)修改/etc/sysconfig/ntpd文件,内容如下:
#允许BIOS与系统时间同步,也可以通过hwclock -w 命令
SYNC_HWCLOCK=yes
4)在配置完成并重新启动服务后,可通过ntpstat
命令显示本机上一次与上层ntp服务器同步时间的情况,也可以使用ntpq -p 查看本机与上层ntp服务器通信情况,
24 图形界面配置NTP
图形界面下直接用system-config-date, 在“Network Time Protocol”选项页指定NTP服务器后勾选“Synchronize system clock before startingservice”,将ntpd服务设置为自动运行即可。
25 客户端访问
1)Linux客户端可通过图形界面进行配置,也可以通过ntpdate命令立即与NTP服务器及行时间校对。
ntpdate 192168010
2)Windows客户端,只需双击任务栏右下角的时钟,选择“Internet时间”选项页,输入NTP服务IP地址或FQDN,并勾选“自动与Internet时间服务器同步”即可。
Windows默认7天自动更新一次,可通过修改注册表HKEY_LOCAL_MACHINE\SYSTEM
\CurrentControlSet\services\W32Time\TimeProviders\NtpClient\SpecialPollInterval 默认单位为妙,修改后重新启动即可生效。

在一台计算机上我们有两个时钟:一个称之为硬件时间时钟(RTC),还有一个称之为系统时钟(System Clock)。
系统时钟就是 *** 作系统的kernel所用来计算时间的时钟 它从1970年1月1日00:00:00 UTC时间到目前为止秒数总和的值。

在Linux下,系统时间在开机的时候会和RTC硬件时钟同步(synchronization),之后也就 各自独立运行 了。

系统运行期间,则通过其他硬件时钟源进行tick计算(tsc、hpet、acpi_pm)。

RTC(real time clock)通过主板(CMOS)的电磁供电,精确到秒。用户可手工设置RTC时间。

1 强制跃迁同步

ntpdate -u xxxxxxxx

xxxxxxxx 为ntpServer地址,如 ntpaliyuncom

注意:此时本机的ntpd不能启动,否则执行 ntpdate会报socket占用
2 将系统时间同步到硬件时钟

hwclock -w 
3 启动ntpd,后续平滑同步

systemctl start ntpd

注意:此时本机的不能在ntpd运行期间执行ntpdate,否则会报socket占用
NTP服务器时间监控脚本

>2107214544 (国家授时中心服务器IP地址)
ntpsjtueducn 2021202101 (上海交通大学网络中心NTP服务器地址)
s1atimeeducn 北京邮电大学
s1btimeeducn 清华大学
s1ctimeeducn 北京大学
s1dtimeeducn 东南大学
s1etimeeducn 清华大学
s2atimeeducn 清华大学
s2btimeeducn 清华大学
s2ctimeeducn 北京邮电大学
s2dtimeeducn 西南地区网络中心
s2etimeeducn 西北地区网络中心
s2ftimeeducn 东北地区网络中心
s2gtimeeducn 华东南地区网络中心
s2htimeeducn 四川大学网络管理中心
s2jtimeeducn 大连理工大学网络中心
s2ktimeeducn CERNET桂林主节点
s2mtimeeducn 北京大学


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/13482935.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-16
下一篇 2023-08-16

发表评论

登录后才能评论

评论列表(0条)

保存