Posted by: kezhong | June 19, 2009

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.


Responses

  1. put a search box on website.u r doing a great job
    keep it up& finally thank u.

  2. This is a well documented with a simple description.
    I loved it.

    Thanks,
    Prabhu

  3. […] Here is an example. September 17, 2009 3:35 am John Gardeniers Is there a reason why you can’t allow the server access to the Internet while you are installing Apache and turn it back off afterward? September 16, 2009 10:35 am Maksim Not right now, I’m going to need to wait for IT to enable it which will take for ever… :/ September 16, 2009 10:56 am […]

  4. […] Here is an example. […]

  5. […] Here is an example. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: