Linux系统管理与编程24:基础条件准备-混搭“本地+阿里云”yum源

兰生幽谷,不为莫服而不芳;
君子行义,不为莫知而止休。

1.添加宿主机共享文件夹

Linux虚拟机可以和宿主机共享文件夹,这样有利于工具文件的共享。具体操作如下:

1)vmware workstation共享文件夹

虚拟机->设置->选项->总是启用->添加,选中自己要共享的文件夹,如图1-1、图1-2

图1- 1

图1- 2

共享后,显示结果如图1-3

图1- 3

2)安装vm-tools

如果不安装vmtools,linux里无法看见共享结果。虚拟机->安装vmware-tools

图1- 4

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| yum install -y tar wget curl net-tools bash-completion tree dnf root@newtemp \~# yum install -y gcc --nogpgcheck root@newtemp \~# yum install -y kernel-devel-$(uname -r) --nogpgcheck root@newtemp \~#mkdir /mnt/vmware-tools /tmp/vmware-tools root@newtemp \~#mount /dev/cdrom /mnt/vmware-tools root@newtemp \~cp -r /mnt/vmware-tools/* /tmp/vmware-tools/ root@newtemp \~# cd /tmp/vmware-tools/ root@newtemp vmware-tools# tar zxvf VMwareTools-10.3.23-17030940.tar.gz root@newtemp vmware-tools# cd vmware-tools-distrib/ root@newtemp vmware-tools-distrib# perl vmware-install.pl #一路按提示回车 |

进入/mnt查看

图1- 5

2.搭建本地+阿里云yum源

考试的时候,经常要断网,如果我们手上有centos的iso镜像也可以搭建本地yum源。最好是同时兼顾本地yum源和阿里云yum源,能上互联网可以安装软件包,不能上互联网,也可以安装软件包。

处理防火墙

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| systemctl stop firewalld systemctl disable firewalld sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config |

2.1 将centos镜像拷到前面准备的共享文件夹中。

2.2 光驱永久挂载

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| #在/etc/fstab后边添加下列内容 /mnt/hgfs/shared/CentOS-7-x86_64-Everything-2207-02.iso /mnt/dvd iso9660 loop,ro,auto 0 0 #执行安装 mount -a #验证 root@myshell wu# ls /mnt/dvd CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7 EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL |

2.3 备份原有的repo库文件,下载阿里云repo库文件

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| mkdir -p /etc/yum.repos.d/repo.bak mv -f /etc/yum.repos.d/* /etc/yum.repos.d/repo.bak wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo |

如果没有安装 wget 工具,也可以在 windows 下下载到共享文件夹里,拷贝到 /etc/yum.repos.d/

2.4 更新yum源至阿里云(略)

2.5 "混搭"本地yum和阿里云yum

1)安装优先级插件,并编写本地yum源repo文件

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| root@newtemp wuyum -y install yum-plugin-priorities.noarch root@newtemp wu# yum -y install yum-plugin-priorities #查看优先级插件是否生效 root@newtemp yum.repos.d# cat /etc/yum/pluginconf.d/priorities.conf main enabled = 1 root@newtemp wu#vi CentOS-Media.repo local-media name=CentOS-$releasever - Media baseurl=file:///mnt/dvd/ #file:///mnt/dvd2/ #如果有第二张光盘将前面dvd2行前面的 # 注释符号去掉 gpgcheck=0 enabled=1 gpgkey=file:///mnt/dvd/RPM-GPG-KEY-CentOS-7 priority=1 |

2)修改阿里云repo,添加优先权级别

图2-1

查看优先级yum repolist all

图2-2

可以看见local-media已经和阿里云混搭在一起了,我们关闭网络测试一下。

图2-3

安装一下apache

yum install -y httpd

图2-4

可以看见,即使没有互联网,安装基础服务一样可以实现。

相关推荐
阿里云大数据AI技术10 小时前
阿里云 EMR AI 助手正式发布:从问答工具到全栈智能运维助手
运维·人工智能
orion571 天前
Missing Semester Class1:course overview and introduction of shell
linux
SkyWalking中文站1 天前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
用户120487221611 天前
Linux驱动编译与加载
linux·嵌入式
火车叼位1 天前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
用户805533698032 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698032 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
小猿姐2 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
SkyWalking中文站2 天前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维