苏州阿里云服务器销量学习笔记-Linux-NTP服务器部署

名师云学堂服务器连接 NTP服务器搭建 基本安装 登录云服务器入口在哪检查系统是否安装有NTP服务rpm-qa | grep ntp安装yum服务yum-y install ntp ntpdate设定时区timedatect···

名师云学堂服务器连接

NTP服务器搭建

基本安装

登录云服务器入口在哪

检查系统是否安装有NTP服务rpm-qa | grep ntp安装yum服务yum-y install ntp ntpdate设定时区timedatectlset-timezone Asia/Shanghai选单设定时区tzselect5911将时区信息拷贝,覆盖原来的时区信息cp/usr/share/zoneinfo/Asia/Shanghai /etc/localtime

环境配置

修改配置文件nano/etc/ntp.conf

ntp.conf文件注释

第4行, 记录时间误差driftfile/var/lib/ntp/drift无,替代第5行,新增日志文件logfile/var/log/ntpd.log第8行,对NTP服务器作出限制,默认不限制。ignore:忽略所有类型的NTP连接请求nomodify:限制客户端不能使用命令ntpc和ntpq来修改服务器端的时间noquery:不提供NTP网络校时服务notrap:不接受远程登录请求notrust:不接受没有经过认证的客户端的请求restrictdefaultnomodifynotrapnopeernoquery第17行,下方增加restrict172.16.28.0mask255.255.255.0nomodifynotrap第21~24行,NTP服务器地址serverntp.aliyun.comservertime1.cloud.tencent.comserver210.72.145.44servertime.windows.com无,替代第25行,使用本地作为NTP服务器startum为时间服务器的层次,0最高,默认设置10fudge127.0.0.1stratum10

CentOS 7.9 默认ntp.conf文件

启动NTP服务器

腾讯云服务器中继软件

同步系统时间sudontpdate -u ntp.aliyun.com重新启动NTP服务systemctlrestart ntpd设置NTP服务为开机自启动systemctlenable ntpd防火墙放行NTP服务firewall-cmd--permanent --add-service=ntp && firewall-cmd --reload验证NTP服务是否正常启动,123端口被占用则表示成功启动systemctlstatus ntpd | grep Active ; netstat -tlunp | grep ntp将当前日期时间写入echo"SYNC_HWCLOCK=yes" >> /etc/sysconfig/ntpd验证NTP服务器ntpq-p时间服务器生效时间比较长,需要等待很久才能同步时间
remote:即NTP主机的IP或主机名称。注意最左边的符号,如果由+则代表目前正在作用钟的上层NTP,如果是*则表示也有连上线,不过是作为次要联机的NTP主机。 refid:参考的上一层NTP主机的地址 st:即stratum阶层when:几秒前曾做过时间同步更新的操作 poll:下次更新在几秒之后 reach:已经向上层NTP服务器要求更新的次数 delay:网络传输过程钟延迟的时间 offset:时间补偿的结果 jitter:Linux系统时间与BIOS硬件时间的差异时间

配置NTP服务

sudoyum -y install ntp配置NTP服务器地址sudontpdate {NTP服务器地址}sudontpdate 172.16.28.122设置本机时区为中国上海timedatectlset-timezone Asia/Shanghai将当前时间写入BIOSsudohwclock --localtime --systohc查看系统时间timedatectl

时区

时区概念

UTC整个地球分为二十四时区,每个时区都有自己的本地时间,在国际无线电通信场合,为了统一起见,使用一个统一的时间,称为通用协调时GMT格林威治标准时间指位于英国伦敦郊区的皇家格林尼治天文台的标准时间,因为本初子午线被定义在通过那里的经线(UTC与GMT时间基本相同)CST中国标准时间 CST = UTC+8 = GMT+8DST夏令时指在夏天太阳升起的比较早时,将时间拨快一小时,以提早日光的使用,中国不使用

时区相关命令

查看系统时区timedatectl设置系统时区timedatectllist-timezonestimedatectlset-timezone Asia/Shanghai

原版配置文件

For more information about this file, see the man pagesntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile/var/lib/ntp/driftPermit time synchronization with our time source, but do notpermit the source to query or modify the service on this system.restrictdefault nomodify notrap nopeer noqueryPermit all access over the loopback interface. This couldbe tightened as well, but to do so would effect some ofthe administrative functions.restrict127.0.0.1restrict::1Hosts on local network are less restricted.restrict 192.168.1.0 mask 255.255.255.0 nomodify notrapUse public servers from the pool.ntp.org project.Please consider joining the pool (http://www.pool.ntp.org/join.html).server0.centos.pool.ntp.org iburstserver1.centos.pool.ntp.org iburstserver2.centos.pool.ntp.org iburstserver3.centos.pool.ntp.org iburstbroadcast 192.168.1.255 autokey broadcast serverbroadcastclient broadcast clientbroadcast 224.0.1.1 autokey multicast servermulticastclient 224.0.1.1 multicast clientmanycastserver 239.255.254.254 manycast servermanycastclient 239.255.254.254 autokey manycast clientEnable public key cryptography.cryptoincludefile/etc/ntp/crypto/pwKey file containing the keys and key identifiers used when operatingwith symmetric key cryptography.keys/etc/ntp/keysSpecify the key identifiers which are trusted.trustedkey 4 8 42Specify the key identifier to use with the ntpdc utility.requestkey 8Specify the key identifier to use with the ntpq utility.controlkey 8Enable writing of statistics records.statistics clockstats cryptostats loopstats peerstatsDisable the monitoring facility to prevent amplification attacks using ntpdcmonlist command when default restrict does not include the noquery flag. SeeCVE-2013-5211 for more details.Note:Monitoring will not be disabled with the limited restriction flag.disablemonitor

lol福建服务器云主机

您好:云优数据云计算 www.yunyoushuju.cn 2核2G6M最低19.9元/月 欢迎开机

发表评论

评论列表
未查询到任何数据!