现象描述:
由于网络限制,有时会需要配置yum源来下载包。可通过挂在ISO镜像到驱动器或手动上传ISO镜像到服务器上
定位思路:
可通过挂在ISO镜像到驱动器或手动上传ISO镜像到服务器上
处理步骤:
本次环境为Hyper-v上的openEuler20.03虚拟机,可直接挂在ISO镜像
进入系统:
[root@localhost ~]# mkdir /test [root@localhost ~]# mount /dev/cdrom /test/ [root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ll 总用量 4.0K -rw-r--r--. 1 root root 519 3月 24 2020 openEuler_x86_64.repo [root@localhost yum.repos.d]# mkdir repo [root@localhost yum.repos.d]# mv openEuler_x86_64.repo repo/ [root@localhost yum.repos.d]# vi local.repo [iso] name=openEuler20.03 baseurl=file:///test/ gpgcheck=0 enabled=1 [root@localhost yum.repos.d]# yum clean all 0 files removed [root@localhost yum.repos.d]# yum makecache openEuler20.03 130 MB/s | 2.7 MB 00:00 Metadata cache created. 测试安装软件包看看能否正常运行: [root@localhost yum.repos.d]# yum install lrzsz -y You have enabled checking of packages via GPG keys. This is a good thing. However, you do not have any GPG public keys installed. You need to download the keys for packages you wish to install and install them. You can do that by running the command: rpm --import public.gpg.key Alternatively you can specify the url to the key you would like to use for a repository in the 'gpgkey' option in a repository section and YUM will install it for you. For more information contact your distribution or package provider. Problem repository: [iso] bandwidth: 0 baseurl: file:///test/ cachedir: /var/cache/dnf cost: 1000 countme: 0 deltarpm: 1 deltarpm_percentage: 75 enabled: 1 enabled_metadata: enablegroups: 1 exclude: excludepkgs: fastestmirror: 0 gpgcheck: 1 gpgkey: includepkgs: ip_resolve: whatever max_parallel_downloads: 3 mediaid: metadata_expire: 172800 metalink: minrate: 1000 mirrorlist: module_hotfixes: 0 name: openEuler20.03 password: priority: 99 protected_packages: dnf, sudo, yum, systemd, systemd-udev, dnf, sudo, yum, systemd, systemd-udev, dnf proxy: proxy_auth_method: any proxy_password: proxy_username: repo_gpgcheck: 0 retries: 10 skip_if_unavailable: 0 sslcacert: sslclientcert: sslclientkey: sslverify: 1 throttle: 0 timeout: 30 type: user_agent: libdnf username: [root@localhost yum.repos.d]# rpm --import public.gpg.key 错误:public.gpg.key:导入读取时失败(2)。 [root@localhost yum.repos.d]# find / -name RPM-GPG-KEY* /etc/pki/rpm-gpg/RPM-GPG-KEY /etc/pki/rpm-gpg/RPM-GPG-KEY-openEuler /test/RPM-GPG-KEY-openEuler [root@localhost yum.repos.d]# cd /etc/pki/rpm-gpg/ [root@localhost rpm-gpg]# rpm --import RPM-GPG-KEY [root@localhost rpm-gpg]# rpm --import RPM-GPG-KEY-openEuler [root@localhost rpm-gpg]# yum install lrzsz -y Last metadata expiration check: 0:00:24 ago on 2022年11月08日 星期二 10时08分20秒. Package lrzsz-0.12.20-46.oe1.x86_64 is already installed. Dependencies resolved. Nothing to do. Complete!
OK,可以使用了!