yum is a package manager, based on rpm package management, which can automatically download rpm packages from a specified location, automatically handle dependencies, and install all packages at one time, without the need for tedious downloads and installations again and again
Common options of yum command: yum list all ###List all installation packages yum list installed ###List installed yum list available ###List not installed yum remove software ###Uninstall software yum install software ###install software yum search keywords ###Search for software related to keywords yum whatprovides file ###Search for packages that contain this file yum reinstall software ###Reinstall software yum localinstall third-party software ###Install third-party software and resolve dependencies yum info software ###Query software information yum groups list ###List software groups yum groups install ###Install group yum groups remove ###Uninstall group yum groups info ###View group information
local source configuration
[root@foundation43 ~]# ostnamectl ##View system version Static hostname: foundation43.ilt.example.com Icon name: computer-laptop Chassis: laptop Machine ID: 5dda1580e9474d0ab1a33787bad19b3b Boot ID: cc6ec8b27bd44f3f8ac0e0aa20d25035 Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) ##System Version CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server Kernel: Linux 3.10.0-327.el7.x86_64 Architecture: x86-64
Find the corresponding iso file to mount
[root@foundation43 ~]# cd /iso ##Find the CD corresponding to the system [root@foundation43 iso]# ll total 11309056 -rw-rw-r-- 1 qemu qemu 3743416320 Apr 22 2016 rhel-server-7.0-x86_64-dvd.iso -rw-rw-r-- 1 kiosk kiosk 4043309056 Jul 25 2016 rhel-server-7.2-x86_64-dvd.iso -rw-rw-r-- 1 kiosk kiosk 3793747968 Sep 16 2017 rhel-server-7.3-x86_64-dvd.iso [root@foundation43 iso]# mkdir /mnt/rhel7.2 ##Create a hanging directory [root@foundation43 iso]# mount rhel-server-7.2-x86_64-dvd.iso /mnt/rhel7.2 mount: /dev/loop0 is write-protected, mounting read-only ##Mount the iso image to the mount directory
Configure local sources
[root@foundation43 iso]# cd /etc/yum.repos.d/ ##Switch to the yum library configuration file directory [root@foundation43 yum.repos.d]# mkdir repo.bak ##Create a backup directory [root@foundation43 yum.repos.d]# mv * repo.bak/ ##Backup existing files [root@foundation43 yum.repos.d]# vim yum.repo ##Create a new repo file [rhel7.2] ##source name name=rhel7.2 ##source description baseurl=file:///mnt/rhel7.2 ##Source address gpgcheck=0|1 ##Whether to detect the gpgkey of the source #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ##The native gpgkey file, this parameter is required if the gpgkey of the source is detected #enabled=1 ##Whether the source is valid, not required [root@foundation43 yum.repos.d]# yum clean all ##Clean yum cache Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Cleaning repos: rhel7.2 Cleaning up everything
Shared source build
Install httpd after the local source is successfully built
[root@foundation43 yum.repos.d]# yum install httpd ##Install apache Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-40.el7 will be installed --> Processing Dependency: httpd-tools = 2.4.6-40.el7 for package: httpd-2.4.6-40.el7.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-40.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.6-40.el7 rhel7.2 1.2 M Installing for dependencies: apr x86_64 1.4.8-3.el7 rhel7.2 103 k apr-util x86_64 1.5.2-6.el7 rhel7.2 92 k httpd-tools x86_64 2.4.6-40.el7 rhel7.2 82 k Transaction Summary ================================================================================ Install 1 Package (+3 Dependent packages) Total download size: 1.4 M Installed size: 4.3 M Is this ok [y/d/N]: y Downloading packages: -------------------------------------------------------------------------------- Total 28 MB/s | 1.4 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : apr-1.4.8-3.el7.x86_64 1/4 Installing: apr-util-1.5.2-6.el7.x86_64 2/4 Installing : httpd-tools-2.4.6-40.el7.x86_64 3/4 Installing : httpd-2.4.6-40.el7.x86_64 4/4 Verifying : httpd-tools-2.4.6-40.el7.x86_64 1/4 Verifying : apr-1.4.8-3.el7.x86_64 2/4 Verifying : apr-util-1.5.2-6.el7.x86_64 3/4 Verifying : httpd-2.4.6-40.el7.x86_64 4/4 Installed: httpd.x86_64 0:2.4.6-40.el7 Dependency Installed: apr.x86_64 0: 1.4.8-3.el7 apr-util.x86_64 0: 1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-40.el7 Complete! [root@foundation43 yum.repos.d]# systemctl start httpd.service ##Restart the service [root@foundation43 yum.repos.d]# systemctl enable httpd.service ##Startup Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@foundation43 yum.repos.d]# systemctl stop firewalld.service ##Close the firewall [root@foundation43 yum.repos.d]# systemctl disable firewalld.service ##Disable the firewall to start at boot Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@foundation43 yum.repos.d]# mkdir /var/www/html/rhel7.0 ##Create a shared directory [root@foundation43 yum.repos.d]# mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0 ##Mount the image to the shared directory
The browser accesses the ip address/rhel7.0 to test the shared source. If the access is successful, the sharing is successful.
Client configuration yum source
[root@desktop ~]# cd /etc/yum.repos.d/ ##Move to the repo configuration directory [root@desktop yum.repos.d]# mkdir repo.bak ##Create backup directory [root@desktop yum.repos.d]# mv *repo.bak ##Backup file [root@desktop yum.repos.d]# vim yum.repo ##Configuration source [rhel7.0] name=rhel7.0 baseurl=http://172.25.254.43/rhel7.0 ##Network source path gpgcheck=0 [root@desktop yum.repos.d]# yum clean all ##Empty cache Loaded plugins: langpacks Cleaning repos: rhel7.0 ##Current source Cleaning up everything [root@desktop yum.repos.d]# yum install zsh ##Install software Loaded plugins: langpacks rhel7.0 | 4.1 kB 00:00 (1/2): rhel7.0/group_gz | 134 kB 00:00 (2/2): rhel7.0/primary_db | 3.4 MB 00:00 Resolving Dependencies --> Running transaction check ---> Package zsh.x86_64 0:5.0.2-7.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: zsh x86_64 5.0.2-7.el7 rhel7.0 2.4 M Transaction Summary ================================================================================ Install 1 Package Total download size: 2.4 M Installed size: 5.6 M Is this ok [y/d/N]: y Downloading packages: zsh-5.0.2-7.el7.x86_64.rpm | 2.4 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zsh-5.0.2-7.el7.x86_64 1/1 Verifying : zsh-5.0.2-7.el7.x86_64 1/1 Installed: zsh.x86_64 0:5.0.2-7.el7 Complete!After the configuration is successful, the software is successfully installed through the network source