Linux 配置yum源.

时间:2021-11-21 06:20:23

Linux 配置yum源.

环境:虚拟机中安装了RedHat ,在进行安装mariadb的时候,出现如下错误。是因为yum源的问题,需要进行配置yum源。本教程是配置本地yum源

 [root@localhost yum.repos.d]# yum groups install mariadb mariadb-client -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>

选中虚拟机中的操作系统,鼠标:右键-->>设置

Linux 配置yum源.

在弹出的“虚拟机设置” 窗口中,选择:CD/DVD -->>设备状态(已连接,确保打上勾即可)

Linux 配置yum源.

在Linux的终端输入:mount 指令,可以查看到有块设备被加载进来了,见红色标注,相关信息如下:

 [root@localhost yum.repos.d]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=917580k,nr_inodes=,mode=)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=,mode=,ptmxmode=)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mapper/rhel-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd- on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=,pgrp=,timeout=,minproto=,maxproto=,direct,pipe_ino=)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/ type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=186704k,mode=,uid=,gid=)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user//gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=,group_id=)
tmpfs on /run/user/ type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=186704k,mode=)
/dev/sr0 on /run/media/hk-super/RHEL-7.4 Server.x86_64 type iso9660 (ro,nosuid,nodev,relatime,uid=,gid=,iocharset=utf8,mode=,dmode=,uhelper=udisks2)

使用root账号(切换root指令:su - root),在/mnt 目录下创建一个目录。

  指令: mkdir /mnt/dvd

然后卸载/dev/sr0 ,然后挂在到/mnt/dvd ,进入的/mnt/dvd,就可以查看到镜像内的文件了。

相关指令如下:

  卸载: umount /dev/sr0

  重新挂在: mount /dev/sr0 /mnt/dvd

  进入dvd目录: cd /mnt/dvd(此时也进入到镜像文件内了)

  查看镜像内的文件:ls -l ( l是字母 )

  Linux 配置yum源.

镜像加载到Linux之后,开始配置repo文件,相关指令如下:

  cd /etc/yum.repos.d/

  vim  hello.repo (名字随便起,但后缀名必须是:.repo)

  Linux 配置yum源.

  hello.repo 文件内容如下:

 [base]
name=base
baseurl=file:///mnt/dvd
enabled=
gpgcheck=

Linux 配置yum源.

然后分别输入如下指令:

   yum clean all

  yum makecache

 [root@localhost yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Cleaning repos: base
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
base | 4.1 kB ::
(/): base/filelists_db | 3.4 MB ::
(/): base/group_gz | kB ::
(/): base/other_db | 1.5 MB ::
(/): base/productid | 1.6 kB ::
(/): base/primary_db | 4.0 MB ::
Metadata Cache Created
[root@localhost yum.repos.d]#

上面操作反显的日志,说明yum源配置完成。

然后再次输入安装指令:yum groups install mariadb mariadb-client -y  无报错信息,marridb安装成功。

如有问题,欢迎纠正!!!

如有转载,请标明源处:https://www.cnblogs.com/Charles-Yuan/p/9786415.html