Linux 配置yum源.


 Linux 配置yum源.

環境:虛擬機中安裝了RedHat ,在進行安裝mariadb的時候,出現如下錯誤。是因為yum源的問題,需要進行配置yum源。本教程是配置本地yum源

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

 

選中虛擬機中的操作系統,鼠標:右鍵-->>設置

 

在彈出的“虛擬機設置” 窗口中,選擇:CD/DVD -->>設備狀態(已連接,確保打上勾即可)

 

 

在Linux的終端輸入:mount 指令,可以查看到有塊設備被加載進來了,見紅色標注,相關信息如下:

 1 [root@localhost yum.repos.d]# mount  2 sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
 3 proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
 4 devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=917580k,nr_inodes=229395,mode=755)
 5 securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
 6 tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
 7 devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
 8 tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
 9 tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
10 cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
11 pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
12 cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
13 cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
14 cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
15 cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
16 cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
17 cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
18 cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
19 cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
20 cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls)
21 cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
22 configfs on /sys/kernel/config type configfs (rw,relatime)
23 /dev/mapper/rhel-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
24 selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
25 systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=35,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13695)
26 hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
27 debugfs on /sys/kernel/debug type debugfs (rw,relatime)
28 mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
29 nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
30 /dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
31 sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
32 tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=186704k,mode=700,uid=1000,gid=1000)
33 fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
34 gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
35 tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=186704k,mode=700)
36 /dev/sr0 on /run/media/hk-super/RHEL-7.4 Server.x86_64 type iso9660 (ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500,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之后,開始配置repo文件,相關指令如下:

  cd /etc/yum.repos.d/

  vim  hello.repo (名字隨便起,但后綴名必須是:.repo)

  

 

   hello.repo 文件內容如下:

1 [base]
2 name=base
3 baseurl=file:///mnt/dvd
4 enabled=1
5 gpgcheck=0

 

然后分別輸入如下指令:

   yum clean all

  yum makecache 

 1 [root@localhost yum.repos.d]# yum clean all  2 Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
 3 This system is not registered with an entitlement server. You can use subscription-manager to register.
 4 Cleaning repos: base
 5 Cleaning up everything
 6 Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
 7 [root@localhost yum.repos.d]# 
 8 [root@localhost yum.repos.d]# 
 9 [root@localhost yum.repos.d]# 
10 [root@localhost yum.repos.d]# yum makecache 11 Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
12 This system is not registered with an entitlement server. You can use subscription-manager to register.
13 base                                                                                                       | 4.1 kB  00:00:00     
14 (1/5): base/filelists_db                                                                                   | 3.4 MB  00:00:00     
15 (2/5): base/group_gz                                                                                       | 137 kB  00:00:00     
16 (3/5): base/other_db                                                                                       | 1.5 MB  00:00:00     
17 (4/5): base/productid                                                                                      | 1.6 kB  00:00:00     
18 (5/5): base/primary_db                                                                                     | 4.0 MB  00:00:00     
19 Metadata Cache Created
20 [root@localhost yum.repos.d]# 

 

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

 

 然后再次輸入安裝指令:yum groups install mariadb mariadb-client -y  無報錯信息,marridb安裝成功。

 

 

如有問題,歡迎糾正!!!

如有轉載,請標明源處:https://www.cnblogs.com/Charles-Yuan/p/9786415.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM