Table of Contents

Linux

yum configuration in RHEL/CentOS



References


Configuration /etc/yum.conf

How to Use a Proxy Server

Example1

proxy=http://proxysvr.yourdom.com:3128

Example2

#If the proxy server requires authentication
proxy=http://proxysvr.yourdom.com:3128
proxy_username=yumacc
proxy_password=clydenw

How to Check Repository

# grep -E "\[*\]|name|baseurl" /etc/yum.repos.d/*.repo

How to use only the specific repository

# yum --disablerepo=* --enablerepo=test-repo repolist


Configuration /etc/yum.repos.d/*.repo

Directive Description
name Descriptive name for the repository channel. This directive must be specified.
baseurl Location of the repository channel (expressed as a file://, ftp://, http://, or https:// address).
This directive must be specified.
gpgcheck If set to 1, verify the authenticity of the packages by checking the GPG signatures.
You might need to set gpgcheck to 0 if a package is unsigned.
enabled If set to 1, permit yum to use the channel.
gpgkey Pathname of the GPG public key file.

Using Yum Variables

Variable Explanation Example
$releasever You can use this variable to reference the release version of Red Hat Enterprise Linux.
Yum obtains the value of $releasever from the distroverpkg=value line in the /etc/yum.conf configuration file.
6.4
$arch You can use this variable to refer to the system's CPU architecture i586, i686, x86_64
$basearch You can use $basearch to reference the base architecture of the system. i386, x86_64

Custome Variables

echo "Red Hat Enterprise Linux" > /etc/yum/vars/osname

XXX.repo

name=$osname $releasever




Yum Note

CentOS repository

/etc/yum.repos.d/CentOS-Base.repo

repository enabled Explanation
base 1 This repository is equal to DVD iso.
updates 1 released updates
extras 1 additional packages that may be useful
centosplus 0 additional packages that extend functionality of existing packages
contrib 0 packages by Centos Users


Adding Repository

Adding EPEL

Extra Packages for Enterprise Linux (or EPEL) is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux,
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
or
# wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm



/etc/yum.repos.d/epel.repo

[epel]
(abbr)
enabled=0  #temporality  (1:enable, 0:temporality)
(abbr)

Example

# yum search python26 --enablerepo=epel
# yum -y install python26 --enablerepo=epel








How to use a repository

TMP Repo

/etc/yum.repos.d/tmp.repo

[tmp-repo]
name=TMP repo
baseurl=http://192.168.0.100/repo/spp/RedHatEnterpriseServer/6.7-Server/x86_64/current
gpgcheck=0
enabled=1

check with 'yum repolist'

'# yum --disablerepo=* --enablerepo=test-repo repolist'

Local DVD Repository

/etc/yum.repos.d/dvd.repo

# mount /dev/cdrom /mnt
[dvd]
baseurl=file:///mnt/repo/Server
enabled=0
gpgcheck=1
gpgkey=file:///mnt/RPM-GPG-KEY-redhat-release
# yum --disablerepo=\* --enablerepo=dvd list
# yum search XXXX --disablerepo=\* --enablerepo=dvd
# yum -y install XXXX --disablerepo=\* --enablerepo=dvd


Intra repository by myself

/etc/yum.repos.d/intra-repo.repo

[intra-repo]
name=CentOS-6.5 - Intra repo
baseurl=http://192.168.0.100/yum/$basearch/
gpgcheck=0
enabled=1

[intra-repo-rpm]
name=Intra repo rpm
baseurl=http://192.168.0.100/yum/rpm/
gpgcheck=0
enabled=1

[intra-repo-extra]
name=Intra repo extra
baseurl=http://192.168.0.100/yum/extra/
gpgcheck=0
enabled=0


Old Minor Repository Version of CentOS

http://vault.centos.org/

/etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


CentOS repository

/etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-$releasever

[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-$releasever

[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-$releasever






How to create local repository

Creating local repository from an ISO images

mount -o loop /home/elf/isos/CentOS-6.0-x86_64-bin-DVD1.iso /mnt/cdmedia
rsync -av /mnt/cdmedia/Packages /var/www/html/CentOS-6.0/x86_64/.
rsync -av /mnt/cdmedia/repodata /var/www/html/CentOS-6.0/x86_64/.
umount /mnt/cdmedia

mount -o loop /home/elf/isos/CentOS-6.0-x86_64-bin-DVD2.iso /mnt/cdmedia
rsync -av /mnt/cdmedia/Packages /var/www/html/CentOS-6.0/x86_64/.
umount /mnt/cdmedia

createrepo /var/www/html/CentOS-6.0/x86_64/


Mirror repository

rsync from internet

rsync  -avSHP --delete --exclude "local*" --exclude "isos" rsync://example.com/centos/5.4/ /var/www/html/mirror/centos/5.4/

#Example
#http://ftp.riken.jp/Linux/centos/6/
#ftp://ftp.riken.jp/Linux/centos/6/

#CentOS 6 x64
rsync -rptv --delete rsync://ftp.nara.wide.ad.jp/pub/Linux/centos/6/updates/x86_64/ /var/www/centos/6/updates/x86_64/
rsync -rptv --delete rsync://ftp.nara.wide.ad.jp/pub/Linux/centos/6/os/x86_64/ /var/www/centos/6/os/x86_64/

#CentOS 5 x64
# rsync -rptv --delete rsync://ftp.nara.wide.ad.jp/pub/Linux/centos/5/updates/x86_64/ /var/www/centos/5/updates/x86_64/
# rsync -rptv --delete rsync://ftp.nara.wide.ad.jp/pub/Linux/centos/5/os/x86_64/ /var/www/centos/5/os/x86_64/

Mirror repository with cobbler

cobbler import --path=rsync://your_centos_mirror_site/centos --name=centos --arch=x86_64


#cron
0 1 * * */usr/bin/cobbler reposync --tries=3 --no-fail > /dev/null 2>&1


Change repo file

/etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://192.168.0.10/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://192.168.0.10/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1


Creating my original yum repository

Repository Server

Creating a new Repository

yum install createrepo
cp myfile1.rpm /var/www/html/myrepo/x86_64/RPMS/
createrepo /var/www/html/myrepo/x86_64/RPMS

Updateing a Repository

cp myfile2.rpm /var/www/html/myrepo/x86_64/RPMS/
createrepo --update /var/www/html/myrepo/x86_64/RPMS

Client Server

/etc/yum.repos.d/my.repo

# my original yum repository
[mypkgs]
name=my original RPM packages
baseurl=http://192.168.0.10/myrepo/x86_64/RPMS/
gpgcheck=0
enabled=1

check repository

yum repolist
or
yum --enablerepo=myrepo list