Sunday, November 2, 2014

Setting Up a Local yum Server

YUM is a package manager for RPM-compatible Linux systems. You can use it to install or update packages through the internet without considering dependencies. However, if you cannot connect to the internet or you want to save the bandwidth, and you still want to use the yum function, how to do it? The best way is to create a yum local repository server.
1. Create local disk repository
This approach is adapted to the situation that you cannot connect with the internet. You should mount the DVD of installation, copy its contents to the disk, create repository, and do the configuration. The following is the detailed steps on Fedora 9.
Mount the DVD and copy to disk
# mount /dev/cdrom /mnt
# mkdir /install
# cp –r /mnt /install/yum 
Install the createrepo package
# cd /install/yum/Packages
# ls createrepo*
createrepo-0.9.5-2.fc9.noarch.rpm
# rpm –ivh createrepo-0.9.5-2.fc9.noarch.rpm
Preparing…       ###################### [100%]
    1:createrepo ###################### [100%]
Create repository
# createrepo /install
2071/2071 – yum/Packages/zsh-4.3.4-7.fc9.i386.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
 
Configure
# cd /etc/yum.repos.d
# ls
fedora-rawhide.repo   fedora-updates.repo
fedora.repo                  fedora-updates-testing.repo

# find . –name “*.repo” –exec mv {} {}.bak \;
# vi local.repo
[local]
name=yum
baseurl=file:///install

Verify
# yum list bind
Loaded plugins: refresh-packagekit
Local                                                               |  951 B  00:00
primary.xml.gz                                                | 772 kB 00:00
local         : ###################### 2071/2071
Available Packages
bind.i386                                 32:9.5.0-29.b2.fc9       local

2. Create a local repository server
This approach is adapted to the situation that you have many Linux systems in the same LAN and you want to save the internet bandwidth. You should install vsftpd or httpd, mount the DVD of installation, copy its contents to the disk, create repository on the server side, and do the configuration on the client side. The following is the detailed steps with vsftpd on Fedora 9.
A. On the server side
Mount the DVD, install vsftpd and copy DVD to disk
# mount /dev/cdrom /mnt
# cd /install/yum/Packages
# ls vsftpd*
vsftpd-2.0.6-3.fc9.i386.rpm
# rpm –ivh vsftpd-2.0.6-3.fc9.i386.rpm
Preparing…                 ###################### [100%]
    1:vsftpd                   ###################### [100%]

# cp –r /mnt/* /var/ftp/pub
Install the createrepo package
# ls createrepo*
createrepo-0.9.5-2.fc9.noarch.rpm
# rpm –ivh createrepo-0.9.5-2.fc9.noarch.rpm
Preparing…       ###################### [100%]
    1:createrepo ###################### [100%]
 
Create repository
# createrepo /var/ftp/pub
2071/2071 – yum/Packages/zsh-4.3.4-7.fc9.i386.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata

Start the vsftpd service
#service vsftpd start
B. On the client side
Configure
# cd /etc/yum.repos.d
# ls
fedora-rawhide.repo   fedora-updates.repo
fedora.repo                  fedora-updates-testing.repo

# find . –name “*.repo” –exec mv {} {}.bak \;
# vi server.repo
[server]
name=yum
baseurl=ftp://192.168.189.142/pub/   #IP address is server’s
enabled=1

Verify
# yum list bind
Loaded plugins: refresh-packagekit
server                                                             |  951 B  00:00
primary.xml.gz                                                | 772 kB 00:00
server         : ##################### 2071/2071
Available Packages
bind.i386                                 32:9.5.0-29.b2.fc9       server
Note: If you couldn’t connect with the server, you should check the firewall firstly.

No comments:

Post a Comment