标签:management compatible important computer involved
Every operating system must have some or the other way to install a program. What‘s important is the fact that the user must not be given the responsibility of managing the overhead involved in the installation of the program.
You would ask,what‘s the overhead involved in installing a program?
Yes there are several overheads involved in installing a program in a computer Like the following.
Is the program compatible with my computer architecture.
Is that program compatible with my operating system version.
Does all the programs and libraries required to run a certain program there in the system
Will the newly installed program conflict with an already installed program
An installer or program manager, must handle those overhead by itself by not harassing the user. Linux, by nature is the best operating system out there(if you configured it the right way). The main issue with installing a program‘s in Linux distribution‘s is the fact that, different distribution‘s use different methods to install a program.
Here, in this post we will be discussing a very famous tool used to install program‘s in Red Hat Linux system‘s(even fedora,centos and all red hat like system‘s). That‘s none other than the very famous YUM.
YUM stands for Yellowdog Updater, Modified. Like all other program‘s in Linux, YUM is also an open source tool.
It was initially used in Duke University, for managing package installation on their Red Hat based system‘s. These day‘s its been widely used by almost all Red Hat based system‘s. In fact its the default program installer and package management tool these days.
If you are interested in visiting the official home page of YUM, then i would recommend, visiting the below link of Duke university.
http://linux.duke.edu/projects/yum/
Red hat Linux,Fedora & all other red hat based distributions uses RPM as their main software installation package tool.
A Linux software package is nothing but a compressed archive of files,consisting of a particular product information,program files,icons,libraries etc. which enables the functioning of that software package.
RPM is the default package installation tool used in Red Hat Linux. RPM stands for Red Hat Package Manager.
All required files of an application is compiled in a single file format called with a file extension of .rpm.The Red Hat package manager tool, which is installed in all RPM based system, knows how to open and install these .rpm files in the system(.rpm files are compiled and are ready to install, they also perform a dependency prerequisite check for all required libraries before installing a particular package.)
RPM itself is a vast topic, so we will be covering that in separate post, in great detail.
RPM and YUM are completely two different things. RPM is the package manager tool which installs the package. YUM is a repository management tool which will fetch the appropriate package for your particular version of Linux(along with all other required packages).
Repositories is an organized collection of packages that YUM uses. YUM can use these repositories to fetch the correct and exact version of a particular package compatible for your system. Previously before YUM(or before the existence of such repository management tools), the user had to fetch the rpm package for installation, and if a dependency problem arises, the user had to fetch those dependencies from internet or some other sources.
YUM will contain the URL‘s(Uniform Resource Locators) of different repositories in its configuration files. You can in fact update all the installed applications on your system, with the help of a single YUM command(yum will fetch different packages from appropriate different repositories.)
Let‘s create a yum repository from the packages that we have in the Red Hat/Centos installation DVD. Creating a YUM repository will help you to understand the concept of a YUM repository closely.
You get a large number of packages(development tools & application packages etc), inside the installation disk. However all are not installed, when you install the operating system.
Later on if you need a particular package, its not at all advisable to insert the installation disk once again, and fetch that required .rpm package and install it. Again if you face dependency problems, you need to fetch that dependency package once again(sometimes there are yet another dependency package required for installing your dependency package. So it becomes a tedious job).
Let‘s go through a step by step method of creating a local YUM repository.
Step 1: Copy all the .rpm packages from your Installation disk(also all your collected packages)to an isolated folder on your system.
Step 2:For showing you this example, i will be copying all the .rpm packages inside /var/yum folder
1 2 3 4 5 6 7 8 | [root@slashroot2 yum] # pwd /var/yum [root@slashroot2 yum] # ls a2ps-4.13b-57.2.el5.i386.rpm acl-2.2.39-3.el5.i386.rpm acpid-1.0.4-7.el5.i386.rpm adaptx-0.9.13-3jpp.1.i386.rpm adaptx-doc-0.9.13-3jpp.1.i386.rpm |
If you see the above output(there are around 2000 packages in the installation disk, i have not shown the whole output.), all packages from the installation disk are copied inside /var/yum.
As i told before, a repository is nothing but a collection of packages in a directory. YUM was made, so that an operating system can use different repositories at the same time.
It is not at all feasible for an operating system to download the entire repository(because a repository is sometimes very large in the size of Gigabytes. And YUM was designed to fetch and download only those packages that are required to install your required software on demand.) to install the packages required. For example, if i want to install a package called "Perl", YUM must first have the list of all the package‘s in a repository(note the fact that it only requires the list, not the package)
YUM will download the total list of packages available in a repository(the list will contain the package names in the repository,package details etc). Not that it will download only the list of packages with details, not the packages. After downloading the list, If yum was able to fetch all the dependencies for your required package(from that repository or other repositories) yum will install it after confirming with you.
Now lets make that file, which will be containing the package names and other repository details. For this, there is another tool called "Createrepo". Let‘s see what createrepo does.
1 2 3 4 5 6 | [root@localhost var] # createrepo /var/yum/ 2669 /2669 - orca-1.0.0-5.el5.i386.rpm Saving Primary metadata Saving file lists metadata Saving other metadata [root@localhost var] # |
In the above example, i have ran createrepo command with the directory "/var/yum" as an argument(you need to install "createrepo" package for that command. You will get that in the installation disk, so install it with "rpm -ivh createrepo-XX-XX-XX.noarch.rpm").
1 2 3 | [root@localhost yum] # ll | grep ^d drwxr-xr-x 2 root root 4096 Feb 10 16:40 repodata [root@localhost yum] # |
After running "createrepo" for our repository directory you will have an extra directory along with the packages inside the repository. this directory is named as "repodata"
Lets see what‘s inside that directory.
1 2 3 4 5 6 7 8 9 | [root@localhost repodata] # pwd /var/yum/repodata [root@localhost repodata] # ll total 13840 -rw-r--r-- 1 root root 3021610 Feb 10 16:39 filelists.xml.gz -rw-r--r-- 1 root root 10148949 Feb 10 16:39 other.xml.gz -rw-r--r-- 1 root root 969664 Feb 10 16:39 primary.xml.gz -rw-r--r-- 1 root root 951 Feb 10 16:40 repomd.xml [root@localhost repodata] # |
You can clearly see there are four files inside that directory.
Let‘s understand the contents of each and every file in detail.
Let‘s see what‘s inside that compressed file with the help of "zcat". For explanation i have copied one line from the file "filelists.xml.gz".
1 | <package pkgid= "deee52b24486906ee52576ee471b57061ccd5544" name= "php-mbstring" arch= "i386" ><version epoch= "0" ver= "5.1.6" rel= "32.el5" />< file > /etc/php .d /mbstring .ini< /file >< file > /usr/lib/php/modules/mbstring .so< /file >< /package > |
If you see the above line, the first entry tell‘s the package ID, which will uniquely identify the package.
The second entry "name" ofcourse suggests the name of the package.
it also mentions the architecture, version and also the release of the package.
An important fact to note is that, it also gives the information about the file‘s that are going to be installed on the system, if you install this package. Installing this package, will install two files namely,
/etc/php.d/mbstring.ini
/usr/lib/php/modules/mbstring.so
Wow isnt that cool? So that filelists.xml.gz will contain the complete information about all the packages in the repository. This file will be used by YUM to fetch details of all the packages in the repository.
Let‘s get the detail‘s of that exact same package from primary.xml.gz file. Lets see what‘s inside this file.
1 | <package type = "rpm" ><name>php53-mbstring< /name ><arch>i386< /arch ><version epoch= "0" ver= "5.3.3" rel= "5.el5" /><checksum type = "sha" pkgid= "YES" >e4d153d1ac6f71fa50bb6587cf13b324ee44537c< /checksum ><summary>A module for PHP applications which need multi-byte string handling< /summary ><description>The php-mbstring package contains a dynamic shared object that will add |
So this file also consists of package details. But it contains some additional information‘s like the following.
type of the packet
sha hash
And a summery of the package
If you have noticed the file "filelists.xml.gz"contains the information about the file‘s a particular package will install on the system. So if you dont have "filelists.xml.gz"inside your repository, then you will not be able to search the repository with your required file(this kind of searching is done to identify, which package provides a particular file.)
Most of the packages install a lot number of files on the system. Thats why the file "filelists.xml.gz" is too large.
the file remomd.xml contains the details about all the files in the repsitory. the contents of remomd.xml is as shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?xml version= "1.0" encoding= "UTF-8" ?>
<data type = "other" >
<location href= "repodata/other.xml.gz" />
<checksum type = "sha" >53349b063023303c5976135a7e485b0aa932ba6f< /checksum >
<timestamp>1360494599< /timestamp >
< open -checksum type = "sha" >2245d5a3cf0c3398a28b0c63948ecdf58668041e< /open-checksum >
< /data >
<data type = "filelists" >
<location href= "repodata/filelists.xml.gz" />
<checksum type = "sha" >35d6d80d5b115f0da3452534c1f5cf9c0efcef3f< /checksum >
<timestamp>1360494599< /timestamp >
< open -checksum type = "sha" >5d1f2791794e1cc20590099a962cf5260f942b7a< /open-checksum >
< /data >
<data type = "primary" >
<location href= "repodata/primary.xml.gz" />
<checksum type = "sha" >afe11b0976096135357e11e2ff1707d88ebef6fd< /checksum >
<timestamp>1360494599< /timestamp >
< open -checksum type = "sha" >976baa466007d496accfa24922f2f0722c56f1dd< /open-checksum >
< /data > < /repomd > |
It tell‘s the details about all the other files in the repository metadata, or call it repodata.
Location of primary.xml.gz,filelists.xml.gz,other.xml.gz
their modification time stamp
their checksum
this file contains the complete information about a package like the following
Author
Version details
Changelog
Bug fixes from previous versions etc
This file is used when a user queries information about a package with the help of "repoquery" command. this command is part of yum-utils package.
We will be discussing "YUM"commands, and other util‘s that can be used to query repositories in another post, because that needs special attention.
other.xml.gz is the biggest repo file because it contains a lot of version specific details and change log of a particular package.
the primary configuration file for yum is /etc/yum.conf. Let‘s see the contents of that file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [root@localhost ~] # cat /etc/yum.conf [main] cachedir= /var/cache/yum keepcache=0 debuglevel=2 logfile= /var/log/yum .log distroverpkg=redhat-release tolerant=1 exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 bugtracker_url=http: //bugs .centos.org /yum5bug # Note: yum-RHN-plugin doesn‘t honor this. metadata_expire=1h installonly_limit = 5 # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d [root@localhost ~] # |
the second last line in the file "yum.conf", says that you can either put your repository configuration details here, or inside /etc/yum.repos.d/, with the extension of .repo.
So let‘s now create the file called local.repo(You can do that with any name of your wish. Only remember that the extension must be .repo.)
1 2 3 4 5 6 7 | [root@localhost yum.repos.d] # pwd /etc/yum .repos.d [root@localhost yum.repos.d] # cat local.repo [localrepo] baseurl= file : ///var/yum/ gpgcheck=0 [root@localhost yum.repos.d] # |
In the above example i have created the file named local.repo inside /etc/yum.repos.d/ wih three lines.
The first line indicates the repo name,
the second line indicates the URL of the repository. I have used file:///, because its in my local system. the first two "//", in the URL indicates the protocol slashes, the third slash indicates the Linux root filesystem "/"
You can also place your repository inside your FTP home directory to run with FTP protocol(You will be using ftp://YOURIP/FTP HOME as the baseurl).
Also you can use HTTP protocol, after placing this in your document ROOT in Apache and giving appropriate URL in "baseurl"argument.
the third line ask‘s to ignore key checking(Don‘t worry, i will include them in my second post about yum.)
let‘s try installing one package through our newly created repository.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [root@localhost yum.repos.d] # yum install php-mbstring Loaded plugins: fastestmirror, security Repository ‘localrepo‘ is missing name in configuration, using id Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package php-mbstring.i386 0:5.1.6-32.el5 set to be updated --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================================================================
Package Arch Version Repository Size ============================================================================================================================================================================================================================================= Installing:
php-mbstring i386 5.1.6-32.el5 localrepo 996 k
Transaction Summary ============================================================================================================================================================================================================================================= Install 1 Package(s) Upgrade 0 Package(s) Total download size: 996 k Is this ok [y /N ]: |
There is a cache directory for yum, where yum saves all the required files of a repository. It contains all the files that we created, with the help of "createrepo" command.they are downloaded and kept when you initially use a repository.
1 2 3 4 5 6 7 | [root@localhost ~] # cd /var/cache/yum/ [root@localhost yum] # ls base extras localrepo myrepo timedhosts.txt updates [root@localhost yum] # cd localrepo/ [root@localhost localrepo] # ls cachecookie packages primary.xml.gz primary.xml.gz.sqlite repomd.xml [root@localhost localrepo] # |
From the above output you can clearly see that, our cache directory has got separate directories for separate yum repositories.
you can create as many repositories as you want (and put their .repo files containing the URL inside /etc/yum.repos.d/).
there are also some publicly know yum repositories, which you can use. Some of them are listed below.
Will cover some of the advanced topics and other configuration options in the second part of this yum tutorial.
本文出自 “小小鸟你妈” 博客,请务必保留此出处http://xiaoxiaoniao.blog.51cto.com/8727225/1408268
YUM repository and package management: Complete Tutorial,布布扣,bubuko.com
YUM repository and package management: Complete Tutorial
标签:management compatible important computer involved
原文地址:http://xiaoxiaoniao.blog.51cto.com/8727225/1408268