centos7 local yum configuration and use

Posted by Terrum on Sun, 26 Apr 2020 16:23:32 +0200

1. Mount system CD

2. Mount the CD to make the rpm package in the CD available

Create CD mount point directory

[root@localhost ~]# mkdir /mount

Mount CD

[root@localhost ~]# mount /dev/cdrom /mount
mount: /dev/sr0 is write-protected, mounting read-only

After mounting, you can see the Packages directory of the rpm package in the CD under the mounting path

[root@localhost ~]# ls /mount/Packages/
··· ···

If you don't need to mount the CD, you can uninstall it

[root@localhost ~]# umount /mount/

3. Write yum file (repo file)

The file of Yum exists by default under / etc/yum.repos.d/

centos7's own network yum is shown below

[root@localhost ~]# ls /etc/yum.repos.d/      
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo

If you want to have a better experience of using local yum, we suggest hiding network Yum as follows

Be careful not to delete the network yum provided by centos7, which is very convenient to use later

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir data
[root@localhost yum.repos.d]# mv C* data/
[root@localhost yum.repos.d]# ls

The name and suffix of the local Yum file are. Repo. Note that the repo file must be placed in the / etc/yum.repos.d/ directory, and it is not easy to place it in other places

[root@localhost yum.repos.d]# vim vase.repo

Parameter interpretation:

[vase] #yum name

name=vase #Description information of yum can be omitted

baseurl=file:///Mount ා warehouse address file: / /, which means to find the path behind the file system (similar to http: / /), and then write the mount point. My mount point directory is / mount, so the two splices are file:///mount

enabled=1 enable this yum 1 means enable 0 means not enable

gpgcheck=0 roommate verifies GPG key when using this yum

4. Use local yum

Check whether the local Yum is available. The last column can see the name of the yum written by you

[root@localhost yum.repos.d]# yum list
389-ds-base.x86_64                             vase
389-ds-base-libs.x86_64                        vase
ElectricFence.x86_64                    2.2.2-39.el7                   vase
GConf2.x86_64                           3.2.6-8.el7                    vase
GeoIP.x86_64                            1.5.0-14.el7                   vase
ImageMagick.x86_64                             vase
ImageMagick-c++.x86_64                         vase
ImageMagick-perl.x86_64                        vase
LibRaw.x86_64                           0.19.2-1.el7                   vase

Install the service using yum

[root@localhost ~]# yum -y install zsh            
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-33.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package         Arch               Version                    Repository        Size
 zsh             x86_64             5.0.2-33.el7               vase             2.4 M

Transaction Summary
Install  1 Package

Total download size: 2.4 M
Installed size: 5.6 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : zsh-5.0.2-33.el7.x86_64                                            1/1 
  Verifying  : zsh-5.0.2-33.el7.x86_64                                            1/1 

  zsh.x86_64 0:5.0.2-33.el7                                                           


5. Common commands from yum

-y: Auto answer yes

Install: yum -y install zsh
Uninstall: yum -y remove zsh
Update: yum -y update zsh

Topics: yum RPM CentOS network