简谈linux 光盘镜像iso的挂载与ntpd服务的搭建与配置

step1:放入镜像文件,建立挂载点
cd /tmp/jingxiang
mv CentOS-7-x86_64-DVD-1708.iso CentOS74.iso
mkdir /mnt/yum

step2:挂载与卸载
注:loop是用来把一个文件当成硬盘分区mount到目录
mount -o loop,rw /tmp/jingxiang/CentOS74.iso /mnt/yum
umount /mnt/yum/
ll /mnt/yum/Packages

step3:配置yum仓库
vim /etc/yum.repos.d/mgbg.repo
加入:baseurl=file:///mnt/yum/

yum clean all

step4:安装ntp服务与启动

如果已经安装ntpdate rpm包(通过rpm -qa | grep ntp查看),则先卸载
rpm -e ntpdate-4.2.6p5-25.0.1.el7_3.2.x86_64 或者 yum remove ntpdate-4.2.6p5-25.0.1.el7_3.2.x86_64

yum install ntp*
systemctl restart ntpd

[root@ywcs02 yum.repos.d]# ps -ef | grep ntp
ntp 26950 1 0 11:03 ? 00:00:00 /usr/sbin/ntpd -u ntp:ntp -g
root 26955 26506 0 11:03 pts/0 00:00:00 grep --color=auto ntp


step5:配置ntp服务
vim /etc/ntp.conf
加入
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict 144.54.65.29 kod nomodify notrap nopeer noquery --改为实际具体的ip
restrict 127.0.0.1
restrict ::1
server 144.23.218.21 iburst  --此为时钟参照主机

然后执行:systemctl restart ntpd
过几分钟就可以发现时间同步了

注:如果对/etc/ntp.conf不理解,也可以直接在/etc/ntp.conf 添加server 144.23.218.21 iburst,然后systemctl restart ntpd,
过几分钟就可以发现时间同步了

原文地址:https://www.cnblogs.com/entrepreneur/p/11477320.html