木易仁 發表於 2022-4-15 16:11:00

centos 7 NTP离线安装部署

<p>1.下载三个rpm离线包</p>
<p>ntpdate-4.2.6p5-29.el7.centos.2.x86_64</p>
<p>ntp-4.2.6p5-29.el7.centos.2.x86_64</p>
<p>autogen-libopts-5.18-5.el7.x86_64</p>
<p>地址:</p>
<p>http://mirror.centos.org/centos/7/os/x86_64/Packages/ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm</p>
<p>http://mirror.centos.org/centos/7/os/x86_64/Packages/ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm</p>
<p>http://mirror.centos.org/centos/7/os/x86_64/Packages/autogen-libopts-5.18-5.el7.x86_64.rpm</p>
<p>&nbsp;</p>
<p>2.上传至centos安装</p>
<p>ntp -ivh ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm</p>
<p>ntp -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64</p>
<p>ntp -ivh&nbsp;autogen-libopts-5.18-5.el7.x86_64.rpm</p>
<p><img src="https://img2022.cnblogs.com/blog/811703/202204/811703-20220415155658262-1445265620.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;3.查看安转版本&nbsp;rpm -q ntp</p>
<p><img src="https://img2022.cnblogs.com/blog/811703/202204/811703-20220415155901862-1512297820.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;4. 启用ntp服务&nbsp; systemctl enable ntpd&nbsp;</p>
<p>&nbsp;<img src="https://img2022.cnblogs.com/blog/811703/202204/811703-20220415160005407-1350464481.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;5.开始ntp服务&nbsp;systemctl start ntpd</p>
<p>&nbsp; &nbsp; &nbsp;查看状态&nbsp;systemctl status&nbsp;&nbsp;ntpd</p>
<p><img src="https://img2022.cnblogs.com/blog/811703/202204/811703-20220415160139272-501795829.png"></p>
<p>&nbsp;</p>
<p>6.&nbsp;编辑master的机器的文件/etc/ntp.conf</p>
<div>
<div><em id="__mceDel"> 找到ntp时间同步的机器范围配置项<br>
restrict 192.168.3.0mask255.255.255.0nomodify notrap<br>
这里的意思代表,192.168.3的网段的机器都参与ntp的时间同步</em></div>

</div>
<div class="cnblogs_code">
<p># For more information about this file, see the man pages<br># ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).</p>
<p>driftfile /var/lib/ntp/drift</p>
<p># Permit time synchronization with our time source, but do not<br># permit the source to query or modify the service on this system.<br>restrict default nomodify notrap nopeer noquery</p>
<p># Permit all access over the loopback interface.This could<br># be tightened as well, but to do so would effect some of<br># the administrative functions.<br>restrict 127.0.0.1 <br>restrict ::1</p>
<p># Hosts on local network are less restricted.<br>restrict 192.168.111.0 mask 255.255.255.0 nomodify notrap</p>
<p># Use public servers from the pool.ntp.org project.<br># Please consider joining the pool (http://www.pool.ntp.org/join.html).<br>server ntp1.aliyun.com<br>server ntp2.aliyun.com<br>server ntp3.aliyun.com<br>server 127.0.0.1<br>fudge 127.0.0.1 stratum 10</p>
<p>#broadcast 192.168.1.255 autokey        # broadcast server<br>#broadcastclient                        # broadcast client<br>#broadcast 224.0.1.1 autokey                # multicast server<br>#multicastclient 224.0.1.1                # multicast client<br>#manycastserver 239.255.254.254                # manycast server<br>#manycastclient 239.255.254.254 autokey # manycast client</p>
<p># Enable public key cryptography.<br>#crypto</p>
<p>includefile /etc/ntp/crypto/pw</p>
<p># Key file containing the keys and key identifiers used when operating<br># with symmetric key cryptography. <br>keys /etc/ntp/keys</p>
<p># Specify the key identifiers which are trusted.<br>#trustedkey 4 8 42</p>
<p># Specify the key identifier to use with the ntpdc utility.<br>#requestkey 8</p>
<p># Specify the key identifier to use with the ntpq utility.<br>#controlkey 8</p>
<p># Enable writing of statistics records.<br>#statistics clockstats cryptostats loopstats peerstats</p>
<p># Disable the monitoring facility to prevent amplification attacks using ntpdc<br># monlist command when default restrict does not include the noquery flag. See<br># CVE-2013-5211 for more details.<br># Note: Monitoring will not be disabled with the limited restriction flag.<br>disable monitor</p>

</div>
<div>
<div>ntp.conf中有默认的时间服务器,我们需要注销,然后添加上我们对应的时区时间服务器。<br>
server ntp1.aliyun.com<br>
server ntp2.aliyun.com<br>
server ntp3.aliyun.com
<p>&nbsp;</p>
<p>///当以上三个时间服务器不可用时,就是以本机时间作为集群机器的统一时间。<br>
server 127.0.0.1<br>
fudge 127.0.0.1 stratum 10</p>

</div>

</div>
<p>&nbsp;<img src="https://img2022.cnblogs.com/blog/811703/202204/811703-20220415160542825-591940706.png"></p>
<p>&nbsp;</p>
<p>&nbsp;6.更新时间&nbsp;ntpdate -u ntp2.aliyun.com</p>
<p>7.配置客户机&nbsp;/etc/ntp.conf&nbsp;&nbsp;</p>
<p>server 192.168.111.128</p>
<p>同步时间命令&nbsp;ntpdate -u&nbsp;&nbsp;192.168.111.128&nbsp; 需要关闭防火墙</p><br><br>
来源:https://www.cnblogs.com/jinpeigang/p/16149670.html
頁: [1]
查看完整版本: centos 7 NTP离线安装部署