1. The origins of Yum
To address the dependencies between programs, Redhat has introduced a tool called update. Although this tool has achieved its purpose, the user experience is not very good. Later, a Redhat-based two release version of Yellowdog, which also introduced a tool: Yellowdog update modifier, abbreviated to YUM. Because it is more useful than update, it is popular. Later caused Redhat to abandon update without using Yum
2. Features of Yum
Yum is relative to RPM: RPM is the base Package Manager and Yum is the front-end tool for RPM. Yum cannot exist independently
The system does not allow two Yum commands to run at the same time, and if there are two, the second run will cause an error. This is to prevent the conflicts between Yum
3. How Yum Works
Yum works on a file server that relies on the C/S architecture working mode, and the server stores the packages required for Yum to work. After Yum receives the name of the package that needs to be installed, the File sharing protocol (or File Transfer Protocol) is used to query the required packages in the Yum repository (which can be multiple) in the configuration file. Once found, the package is downloaded to the local Yum cache directory via the file download protocol, and the cache directory is deleted when the installation is complete.
But if Yum needs to traverse every time it goes to the Yum repository, it can cause slow speed. In the Yum repository, there are two types of data: program and program metadata. When created, the Yum Repository extracts property information from all program names, sizes, versions, and dependencies, and saves them to the Repodata directory. So when Yum accesses the Yum repository for the first time, it gets the in-store metadata (repodata) and downloads it locally. So, the next time you need to install the package, just get the information from the local cache and download it directly to the repository
How to keep the local cache repodata and server-side repodata real-time synchronization? Each time yum accesses the repository, it obtains the signature of each file in the Repodata directory, compares it to the local one, and, if it is not the same, re-downloads and overwrites
4. Yum configuration file
Point to the location of the warehouse and the various configuration information associated with it. Each yum command line can point to multiple warehouses at the same time, the warehouse can be prioritized and other related configuration, priority is determined by the cost
A configuration file consists of two parts: a master profile and a configuration file for each warehouse. Because if all the configuration information is placed in a file, it is too bloated, inconvenient. Where the main configuration file is located in/etc/yum.conf, which provides a public profile for each repository, and the configuration file for each warehouse is the path:/etc/yum.repos.d/*.repo, which is in the assigned format.
[root ~]# cat /etc/yum.conf # viewing the master profile [main] # All warehouse public configuration cachedir=/var/cache/yum/$basearch [p1] /$releasever # The Cache directory keepcache=0 # package is no longer saved to the cache after installation is complete debuglevel=2 # The output information when the program is installed, the larger the number the more output information. It's best to shut down in a production environment, but opening allows us to quickly locate the logfile=/var/log/yum.log # log file where the problem occurs in the installation exactarch=1 # the version of the installer is consistent with the current platform obsoletes=1 # the check package has been discarded gpgcheck=1 # check the source legitimacy and package integrity, there should also be a gpgkey, to indicate where the repository's public key files are obtained from, but this is a public configuration, and the configuration warehouse is not the same, so don't put it here plugins=1 # Support Plugin installonly_limit=5 # package limit of one installation 5 x bugtracker_url=http:// bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php? Path of Category=yum # bug tracing distroverpkg=centos-release # Determine the current system Information #&nbsP This is the default, if you make this bigger yum won ' t See if themetadata# is newer on the remote and so you ' ll ' Gain " the bandwidth of not having to# download the new Metadata and "Pay" for it by yum not having correct# information.# Itis esp. important, to have correct metadata, for Distributions like# fedora which don ' T keep old packagesaround. if you don ' T like this checking# interupting your command line usage, it ' smuch better to have something# manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire= 90m # put your repos here or in separate filesnamed file.repo# in /etc/yum.repos.d # can be attached to the configuration information, or can be placed in each configuration file # can be viewed in detail through man yum.conf
[Root ~]# Cat/etc/yum.repos.d/centos-media.repo # Open a repository configuration file [C6-media] # ID, it is best to see the name, and must be unique name=centos-$releaseve R-media # Description of the current warehouse #mirrorlist= # You can write all the mirror site URLs to a file, point to the file, and then pick the fastest one to use. Generally not with BaseURL use baseurl=ftp://# to the path to the warehouse, point to multiple standby HTTP/# # Alternate paths cannot be shelf write, at least 1 spaces are required file:///media/cdrecorder/g Pgcheck=1 # is defined here with a higher priority, need to mate with Gpgkey Enabled=0 # This warehouse is not used gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-6 cost= # Priority, the smaller the number, the lower the overhead, and the higher the priority. Default 1000[media] # a second warehouse
5. Yum command
-Y: Auto Answer Yes
List: List all packages in the warehouse, support wildcard characters
Clean: Cleans up the cache. Yum Cache path:/var/cache/yum/
Repolist: Displays a list of warehouses and their brief information
Install: Installation
Remove|erase: Uninstall. Other packages that have dependencies on this package will also be uninstalled
Infopackage ... : A brief information about the query program. It doesn't matter if it's packed in a warehouse.
Grouplist: List all package groups
Groupinstall: Installing package Groups
You can manage package groups directly with install, remove, or update, adding @ To differentiate between package groups: Yuminstall @ "Server Platform Development"
6. Configure the Yum repository based on the CentOS release CD RPM package
[Root packages]# yum install-y Createrepo
[Root packages]# mount-r/dev/cdrom/mnt/
[root packages]# mkdir /var/repo# new directory for RPM package storage [Root packages]# cd /var/repo [root repo]# cp /mnt/Packages/* .# a lot of documents, need to wait [root repo]# createrepo /var/repo/spawning worker 0 with 4184 pkgsworkers finishedgathering worker resultssaving primary metadatasaving file lists metadatasaving other metadatagenerating sqlite dbssqlite dbs complete# en, Finally created, and waited long enough [root repo]# cd repodata/[root repodata]# ls318f1b79bc13b0daf243cdf4fad87af1e49fef06920b74f135e3d6d9af3a3abf-primary.sqlite.bz25015d87cfb7d1484fc9949b398c5d2d4916c B5c257939be34d0b9595e3bd734d-filelists.xml.gz62d8a6fade0ecb892b8a58601665a77c95f5c278d57927274f9d3afef8378119-filelists.s qlite.bz275d262ab21744dd239762ac72543a4ebe74c7b7bd333dd7a96ff0a4636814144-primary.xml.gz81cdd7de2b2e08780255e5c7e711f0499 Fc0f2e01e322e4f05b03f61434ea2f7-other.sqlite.bz2fad987423b71003dbf3661f6bc4f51f50584c4fb0881b6506ccf7baf99c7aa1d-other.xml.gzrepomd.xml# These are meta-data messages, [root repodata]# cd /etc/yum.repos.d/[root yum.repos.d]# vim . centos6.6.repo# new configuration file, must end with Repo! Or just use the out-of-the-box [test2]name=fuck mebaseurl=file:///var/repoenabled=1gpgcheck=0# mentioned above, here will not repeat, save exit! [root yum.repos.d]# yum repolistloaded plugins: fastestmirror, Refresh-packagekit, securityloading mirror speeds from cached hostfiletest2 &nbsP; | 2.9 kb 00:00 ... repo id repo name statustest epel 4,184test1 epel 41test2 fuck me 4,184repolist: 8,409# Successful display
[Root yum.repos.d]# yum install-y vsftpd# Download FTP service [root yum.repos.d]# service vsftpd start# start service [root yum.repos.d]# Cd/va r/ftp/pub/# This is the FTP default directory that is automatically created after the service is started [root pub]# mv/var/repo. [Root pub]# lsrepo[root pub]# vim/etc/yum.repos.d/centos6.6.repobaseurl=ftp://172.16.249.135/pub/repo/# change this one, You must point to the path where Repodata is located [root pub]# service iptables stop# shutdown Firewall # can be viewed under the browser ftp://172.16.249.135/pub/repo/
Configuration is complete, this can be said to be the most fool-type FTP configuration, because this is just about yum. In addition, it can be made into an HTTP server, the method is basically the same
END
Linux Yum and Yum repositories