The installation software of the CentOS system mainly has Yum installs and the source code installs two kinds, the source installation advantage is that you can customize many installation parameters according to your need, but he has one drawback is that every time needs to execute./configure && make && Make install and when you need to uninstall a software you may not be able to completely uninstall cleanly, so for most cases, yum installation is the best choice. CentOS official source is generally very slow, because it is foreign, so you can choose to use some of the domestic famous official sources, such as Sina, Ali, and so on, of course, you can choose to build your own Yum warehouse, in fact, it is very simple, not as difficult as you think. This article briefly describes how to build a local yum repository.
First, Environment preparation:
Two virtual machines, the system is Centos6.5.
192.168.1.22 for the Yum repository hereinafter referred to as a, need to install Apache or Nginx, or other Web services.
192.168.1.23 for the experimental machine hereinafter referred to as B.
Second, the establishment of the warehouse: (on the implementation of a)
Here we take the HTTP way to transfer the Yum file, so we create a total directory and create a virtual host.
Mkdir/www/yum
Mkdir-p 6.5/i386 6.5/x86_64 6.6/i386 6.6/x86_64 5.8/x86_64 5.8/i386
The simplest way is to put all the RPM packages in the Yum directory, but in the actual production environment we may need to differentiate between different operating system versions, such as 5.8 and 6.5, 6.6, and different bits 32-bit or 64-bit, so we create these subdirectories in the Yum directory. The final effect looks like this:
Tree/www/yum
├──5.8
│├──i386
│└──x86_64
├──6.5
│├──i386
│└──x86_64
└──6.6
├──i386
└──x86_64
Next add a virtual host file, I use Nginx, configured as follows:
Server
{
Listen 8001;
server_name fangqi.veone.cn
Index index.html index.htm index.php;
Root/www/yum;
Access_log off;
}
Don't forget the reload.
If you don't have a domain name, you can define it as yum.123.com, and then bind the domain name and IP to the/etc/hosts of B.
Here I use the public domain name. In the actual production environment, it is generally possible to resolve the in-network DNS.
Next you can put the package, put the prepared RPM package into the/www/yum/6.5/x86_64/path,
The next bag on the Internet, I'm using lrzsz-0.12.20-1.x86_64.rpm.
The next step is a critical one,
CD www/yum/6.5/x86_64/
Yum-y Install Createrepo
Createrepo./
This command may cause an error:
Traceback (most recent):
File "/usr/share/createrepo/genpkgmetadata.py", line up, in <module>
Import Createrepo
Importerror:no module named Createrepo
This is because the Python version has been upgraded, into the genpkgmetadata.py, the first line of the version designation to the old path can be, such as: I was originally 2.6 version, later upgraded to 2.7 version, this time only need to change #!/usr/bin/python to #!/ usr/bin/python2.6, and then execute the command again.
Execute the successful output:
Spawning worker 0 with 1 pkgs
Workers finished
Gathering worker Results
Saving Primary Metadata
Saving file lists Metadata
Saving other metadata
Generating SQLite DBs
Sqlite DBs Complete
You will notice that a Repodata folder appears on the current path, indicating that the Yum repository is already established.
In fact, the sub-folders we defined earlier are all separate yum repositories, so we need to execute the CREATEREPO command to generate the Yum repository.
Third, configure the Yum Source: (performed on B)
Cd/etc/yum.repos.d
First back up the original source, and then create a new file:
VI Centos-6.5.repo
Write
[CentOS-6.5]
name=centos-6.5
Baseurl=http://fangqi.veone.cn:8001/6.5/x86_64
Gpgcheck=0
The main baseurl don't write wrong.
Then update the local Yum cache:
sudo yum clean all
sudo yum Makecache
You can check the Lrzsz application at this point:
Yum List Lrzsz
The normal situation is that you can see the results.
If you can query other applications, such as GCC:
will prompt no matching pachages to list
Then install:
Yum Install-y Lrzsz
Test the LRZ,LSZ (RZ,SZ) command.
To this step is basically finished, if you want to add the package later, do not forget to repeat the three steps: in the source warehouse to perform Createrepo, and then execute the yum clean all && yum Makecache on the server, it seems to be a bit cumbersome, You can try to write scripts and flexibly use crontab to solve.
In addition, each of the different systems
Finally, if you don't want to be so troublesome, then simply use Ali's yum well, although I think it's quite simple.
Simple violence three steps are as follows:
The first step: Back up your original image file so that you can recover it after an error.
Mv/etc/yum.repos.d/centos-base.repo/etc/yum.repos.d/centos-base.repo.backup
Step two: Download the new Centos-base.repo to/etc/yum.repos.d/
CentOS 5
Wget-o/etc/yum.repos.d/centos-base.repo Http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
Wget-o/etc/yum.repos.d/centos-base.repo Http://mirrors.aliyun.com/repo/Centos-6.repo
Step three: Run the Yum makecache build cache
Yum Clean All
Yum Makecache
then install it.
This article is from the "linux-saints" blog, please be sure to keep this source http://fangqi.blog.51cto.com/10856791/1880395
Self-built local yum repository under CentOS