写在文章开头,对于内网主机(无法联网)一般都是采用NTP的方式来做时做时钟同步。下面就NTP作为解决方案来介绍一下相关操作步骤。
一、简版
1、NTP服务器主机 (192.168.23.123)
- 安装:yum install ntp -y ;
- vi /etc/ntp.conf,增加配置:server 127.127.1.0 ;fudge 127.127.1.0 stratum 8;
- sudo service ntpd start;
- sudo systemctl enable ntpd.service;
对于内网主机,请确认是否有本地yum源,否则无法安装成功,主机本地yum源所在位置:/etc/yum.repos.d
2、非服务器主机
- 手工同步:ntpdate -d 192.168.23.123;
- 定时任务:0 * * * * ntpdate 192.168.23.123;(crontab 每分钟同步一次)
以上两步可以完成,内网Linux主机的时钟同步问题!
二、详细操作
1、NTP服务器主机 (192.168.23.123)
- 安装:yum install ntp -y ;
[root@h1i5 ~]# yum install ntp ntpdate -y
Loaded plugins: fastestmirror, langpacks
Repository HDP-UTILS-1.1.0.21 is listed more than once in the configuration
HDP-2.5 | 2.9 kB 00:00:00
HDP-2.5.3.0 | 2.9 kB 00:00:00
HDP-UTILS-1.1.0.21 | 2.9 kB 00:00:00
ambari-2.4.x | 2.9 kB 00:00:00
centos74 | 3.6 kB 00:00:00
Determining fastest mirrors
Package ntpdate-4.2.6p5-25.el7.centos.2.x86_64 already installed and latest version
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-25.el7.centos.2 will be installed
--> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-25.el7.centos.2.x86_64
--> Running transaction check
---> Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================</