一、openEuler22.03-LTS配置网络yum源
openEuler22.03-LTS默认配置有指向openEuler官网镜像库的网络yum源,如果服务器可以连上公网上的repo.openeuler.org网站,我们不需要做任何yum配置和修改,就可以使用。如果大家不想用openEuler官网镜像仓的yum源,也可以修改指向其它镜像仓。在openEuler官网上,提供了收录有openEuler源的镜像仓及地址信息,链接网址为:https://www.openeuler.org/zh/mirror/list,信息如下:还有一种场景是,服务器不能上公网,企业内部数据中心自建有yum源,则也可以通过修改镜像仓库源地址的方式实现网络yum源的配置。
修改的方法为:编辑/etc/yum.repos.d/openEuler.repo文件,将文件中的repo.openeuler.org替换成其它镜像仓库的域名,完整网址中的其它路径名基本相同,如果确实发现有一些镜像库它的文件路径与名称不致,则需要根据镜像仓所提供的实际路径与名称而修改。
下面以将默认的openeuler.org镜像仓,修改成aliyun(阿里云)镜像仓为例,修改方法如下:
#vi etc/yum.repos.d/openEuler.repo
[OS] name=OS baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/OS/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler
[everything] name=everything baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/everything/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS/everything/$basearch/RPM-GPG-KEY-openEuler
[EPOL] name=EPOL baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/EPOL/main/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler
[debuginfo] name=debuginfo baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/debuginfo/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS/debuginfo/$basearch/RPM-GPG-KEY-openEuler
[source] name=source baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/source/ enabled=1 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS/source/RPM-GPG-KEY-openEuler
[update] name=update baseurl=http://repo.openeuler.org/openEuler-22.03-LTS/update/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler |
......
运行成功。从输出的From信息中可以清晰的看到yum源来自于mirrors.aliyun.com/的输出信息:
“From :https://mirrors.aliyun.com/openeuler/openEuler-22.03-LTS/OS/x86_64/RPM-GPG-KEY-openEuler”二、openEuler22.03-LTS配置本地yum源
本地yum源是指将操作系统的安装介质文件(ISO)映射至挂载点的方式提供yum源,适合无互联网、无内部私有网络yum源的环境。(一)上传ISO文件至操作系统指定目录内
本文以将openEuler-22.03-LTS-x86_64-dvd.iso文件上传至/u01/soft/目录内,做为配置yum源的原始文件。(二)创建挂载目录与挂载ISO文件
[root@pg-p ]# mkdir -p mnt/cdrom[root@pg-p ]# mount -o loop u01/soft/openEuler-22.03-LTS-x86_64-dvd.iso mnt/cdrom/
输出信息: mount: mnt/cdrom: WARNING: source write-protected, mounted read-only. |
--mount命令的 -o选项,loop,是指把一个文件当成硬盘分区mount到目录。
上面为挂载成功后用df-h命令显示的效果。(三)配置yum配置文件openEuler.repo
#vi etc/yum.repos.d/openEuler.repo
[OS] name=OS baseurl=file:///mnt/cdrom enabled=1 gpgcheck=1 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-openEuler
[everything] name=everything baseurl=file:///mnt/cdrom enabled=1 gpgcheck=1 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-openEuler
[EPOL] name=EPOL baseurl=file:///mnt/cdrom enabled=1 gpgcheck=1 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-openEuler
[debuginfo] name=debuginfo baseurl=file:///mnt/cdrom enabled=1 gpgcheck=1 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-openEuler
[source] name=source baseurl=file:///mnt/cdrom enabled=1 gpgcheck=1 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-openEuler
[update] name=update baseurl=file:///mnt/cdrom enabled=1 gpgcheck=1 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-openEuler |
再来yum install实测一下。#yum install -y *vnc* --skip-broken
......
运行成功,同时可见,yum源已经来自于本地文件。输出的From信息如下:“From : /mnt/cdrom/RPM-GPG-KEY-openEuler”至此,国产开源操作系统openEuler22.03-LTS修改网络yum源与配置本地yum源,经实测均已成功。