Pages

Wednesday, June 1, 2011

Creating A Local Yum Repository on CentOS 5.x

In our University we have multiple systems those running on Linux platforms so it is good to have local repository to prevent from downloading the remote repository over and over again. Also in university day time our downloading speed is low because of high network traffic so having a local repository is a big advantage to update our all systems once and its save our internet bandwidth because it use fast LAN connection.
Today I'm going to explain how to create local Centos repository to update our local Centos systems. So for that first we need to have rcync  software and httpd server in Centos, default we can get these two in Centos otherwise you can use following command to install it.

su -c 'yum install httpd rsync'
Now we want to create directory to repo , that will hold all the RPM files. For that if we get all the Centos files from rsync we can create just one directory and rsync will automatically create folder structure according to it.

mkdir /var/www/html/CentOS/

If u copy Centos first from DVD or CDs you want to create Centos folder structure, because when rsync update your repository it used this folder structure to update for that.


su -c 'mkdir -p /var/www/html/centos/5/{os,updates}/x86_64'
Here 5 is your Centos vertion and  x86_64 is architecture, Then you can copy relevant files into   
/var/www/html/centos/5/os/x86_64/ 
 eg:su -c 'mount /dev/cdrom /mn
su -c 'cp -rv /mnt/CentOS /mnt/repodata /var/www/html/CentOS/5/os/x86_64/'
su -c 'umount /mnt' 
Now you can verify it's working by opening your Centos folder using browser (in localhost or remote). 
Eg:htp://your IP or 127.0.0.1/CentOS 
This how its look like in my server 
 
Now our repository server is ready since distributions change often we need to sync with the distribution update servers. So we use rsync for this job it scan directory tree of distribution servers and applies changes to local directory. So we need rsync mirror for updates.Centos OS Mirror List you can identify it with rsync.Now we need to create script to run this rsync when we need, following is the script that I used. (updaterepo.sh)


#!/bin/bash

s=1

for (( c=1; c<=3; c++ ))
do

if [ $s -ne 0 ]; then
rsync -avSHP --delete --exclude "local*" --exclude "isos" ftp.jaist.ac.jp::pub/Linux/CentOS/5.5 /var/www/html/CentOS/ 2> error_log.txt
s=$?

fi

done
cp /usr/local/test /usr/local/suc 
To run this script manually you can type  
./updaterepo
Updating this repository should done often so running script manually is not good so we can use cron job to run this script automatically in relevant time. For that enter  

crontab -e
this will promt your current crontab table so you can enter your crontab here as follow. When you save this crontab file will loaded and ready for use.  
0 2 * * * /myscripts/updaterepo 
In this crontab, myscript is updaterepo.sh in /myscripts directory  I'm going to run this script every morning at 2am. There are five fields for setting the date and time in cron tab that a program should be run. The five time settings are in the following order. 
  • Minutes - in therange of 0 - 59
  • Hour - in the range of 0 - 23  
  • Day of month - in the range 1 - 31 
  • Month - in the range 1 -12  
  • Day of week - in the range 0 - 6 (0 = Sunday)
Any field with a * means run every possible match, so for example a * in the day of month field will run the script every single day of the month at the specified time. More about crontab

That was all on the server part. Now client should chang his /etc/yum.repos.d/CentOS-Base.repo to get local mirror instance of other mirrors. for that you should change base url with your local ip. Its good to copy following my file and replace my IP with your one.

#replace your repo IP with my 10.16.91.1

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

#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://10.16.91.1/CentOS/$releasever/updates/$basearch/

gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
baseurl=http://10.16.91.1/CentOS/$releasever/addons/$basearch/

gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://10.16.91.1/CentOS/$releasever/extras/$basearch/

gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://10.16.91.1/CentOS/$releasever/centosplus/$basearch/

gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://10.16.91.1/CentOS/$releasever/contrib/$basearch/

gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
                                                           


Now you are done

 




33 comments:

Anonymous said...

Hi,

For the mkdir :

Centos is case sensitive

Anonymous said...

Or simply needed some funds, oferta dla zadłużonych however just don’t own it right up until fast cash? It again develops kredyt bez bik towards innumerable People today in america country wide regular. An issue pops up while you have to have pożyczki pozabankowe some dough, your examine isn’t settled but still. Anxieties pożyczki pozabankowe poznań there was how to rekomendowane witryny internetowe obtain a cash payday loan on line, best?

Anonymous said...

dating website server http://loveepicentre.com/ dating sites in cleveland ohio

Anonymous said...

standard of honor ebook http://audiobookscollection.co.uk/The-Expert-Guide-to-Beating-Heart-Disease-What-You-Absolutely-Must-Know/p224983/ halo the cole protocol ebook [url=http://audiobookscollection.co.uk/Teach-Yourself-Visually-Sewing/p190831/]rca ebook software[/url] marketing viral have ebook people

Anonymous said...

Excellent ωeb site you've got here.. It's difficult to find exсellent ωriting like youгs theѕe dayѕ.

I sеrіously apprеciаte pеople liκe you!
Take care!!

Mу webpage ... hcg diet plan

Anonymous said...

My spouse and I аbsolutеly lovе your blog and find most of
уοur post's to be what precisely I'm
lοoking for. can you offer guest writегs to ωrite contеnt for
you pеrsonally? Ι wοuldn't mind producing a post or elaborating on a few of the subjects you write regarding here. Again, awesome site!

my web page - pożyczki bez bik i komornika
My web page :: pożyczki pozabankowe tomaszów mazowiecki

Anonymous said...

Today, I went to the beach with my children. I found a sea shell and gave it
to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put
the shell to her ear and screamed. There was a hermit crab inside and it pinched her
ear. She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!


Feel free to surf to my web blog - FL local
Also see my website - wiki.underbonesphilippines.com

Anonymous said...

Goοԁ day! Dο уou use Tωitteг?

І'd like to follow you if that would be okay. I'm absοlutеly enϳoying youг blog and lοok fοrwаrԁ
to neω updates.

Feеl fгee to visit my blοg post :
: steroids definition

Anonymous said...

each time i used to read smaller posts that as well clear their motive, and that is also happening with this paragraph
which I am reading here.

Feel free to surf to my page; Ohio Moving

Anonymous said...

Hi there! I just wanted to ask if you ever have any issues with hackers?
My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no back up.
Do you have any methods to protect against hackers?

My weblog - http://atlaslm.com

Anonymous said...

This info is priceless. How can I find out more?


Also visit my homepage :: www.smitherscommunitydirectory.com/member/31900/

Anonymous said...

Asking questions are truly pleasant thing if you are not understanding anything fully, however this paragraph offers nice understanding even.


Look into my web blog: phone directory

Anonymous said...

Grains and other processed beverages are NOT allowed on the Slow Carb Diet was developed by Mark Sisson, Nora Gedgaudas, Dr.

Turns out, there are two different proteins that need to purchase in
order to dispense advice? Shrimp is seafood used in several Paleo Diet For Women recipes.

Do you have any yummy paleo diet for women-snacks to
share, please post in the comments section at the bottom of the bowl.
Beat eggs and mix in other ingredients.

Feel free to surf to my web blog; the amen solution

Anonymous said...

Bench seats are recognized on fishing fishing boats as well as much leisure boats.
A good replica will gasoline a little quite expensive than usual.
Peroxide pieces are very expensive to purchase and as well
as unpleasant on any pearly whites. They are generally noticed on
sky private boats also and runabouts. http://nottheads.
info/elgg/profile/TitusJasp

Anonymous said...

Good post. I absоlutely love this site.
Keep wгіting!

my webpage hcg extreme

Anonymous said...

Hi there fantaѕtic blog! Doеѕ running a blog such aѕ this
take a lot of wοrk? I've virtually no knowledge of coding however I was hoping to start my own blog in the near future. Anyway, if you have any recommendations or techniques for new blog owners please share. I know this is off topic however I simply wanted to ask. Appreciate it!

Have a look at my homepage; reputation management strategies

Anonymous said...

http://louisvuittonshoes.citationguide.net louis vuitton Outlet louis vuitton shoes with spikes for men

Anonymous said...

Amazing blog! Is your theme custom made or did you download it from somewhere?
A theme like yours with a few simple adjustements
would really make my blog stand out. Please let me know where you got your design.
With thanks

Also visit my web site ... NaturaCleanse Diets

Anonymous said...

The faltering economy and the repeal of the federal Center for Integrated Health Solutions,
vice president for quality and patient safety at
the organization, storage, inventory management and distribution of drugs and
commodities. Main responsibilities schools that offer
neonatal nurse practitioner programs The Programme Director will be responsible for reporting requirements
and budgets. I can't wait to watch the schools that offer neonatal nurse practitioner programs rest tomorrow! With more than 60 countries. Giving a patient their medicine and ensuring that timely actions are taken to paid dinners and conferences all at the expense of the formula company.

Take a look at my page; neonatalnursepractitionerprograms.us

Anonymous said...

Well, she claims, or rather, a breast augmentation
surgeon new york lack of resources to treat them. The result is a simple
process and has lesser or no chance of survival. Remove the guinea breast augmentation surgeon new york fowl pieces, season lightly with salt.
The term 'nerves' refers to the way events from childhood unconsciously produces attitudes and behaviors that propel people into destructive relationships in the present.
People with anxiety issues can become tense, this can be eliminated very quickly.


Here is my webpage :: breast reconstruction

Anonymous said...

I ѕimply сoulԁ not depart your sitе prior
to suggesting that I actually loved the stаndard informаtiоn аn inԁiviԁual suρρly for уouг guests?

Is gonna be again incessantly to investigate cross-сheck nеw posts

Feel free to ѕuгf to my blοg poѕt Lloyd Irvin

Anonymous said...

It's much cheaper and more easy to obtain. The black clutch featured a classic Gucci tassel as well as , soft luxurious leather material. The best thing is that you have acquired it for a reasonably priced price. So, what do you tell us a about Armani awful for you . that I might no know? http://www.pages.francoorientales.com/user_detail.php?u=theresemp

Anonymous said...

Gucci Footwear became amongst the companies active points. Armani jeans are
one brand that has done very certainly under Armani. Could affect silhouette of the
actual hobo handbags was less slouchy than what was shown for spring.
The sides of the shoulder bags advertised accordian pleats.
https://portal.stteresa.qld.edu.au/groups/test/wiki/3dd4b/Generally_Is_Nothing_For_Example__A_Genuine_Gucci_Handbag_Or_Wallet.
html

Anonymous said...

When inspecting the base of the board, be wary of cracks or deep cuts as these are difficult to repair.

Watch a few music videos from 80s pop mavens
on You - Tube to get inspiration for your outfit.
Synchronization Licensing Fee -Also implied as
the "Synch Fee", this is given to marked specialists who are qualified for synchronize their
music to movie.

Feel free to visit my web-site: Daft Punk - Random Access Memories FLAC

Anonymous said...

There is definately a lot to know about this issue.
I really like all of the points you made.


Here is my page; Boutique Air Max

Anonymous said...

Very great post. I just stumbled upon your weblog and wanted to
mention that I've truly enjoyed surfing around your blog posts. In any case I'll be subscribing to your
rss feed and I hope you write once more very soon!



Here is my web site ... Christian Louboutin UK

Anonymous said...

I'd like to thank you for the efforts you have put in writing this blog. I'm hoping to view the same high-grade
content by you later on as well. In fact, your creative
writing abilities has encouraged me to get my own, personal website now ;)

Here is my web-site; Cheap NFL Jerseys

Anonymous said...

Hi! This is my first comment here so I just wanted to give a quick shout
out and say I genuinely enjoy reading your blog posts.
Can you recommend any other blogs/websites/forums that
go over the same topics? Thank you so much!


Here is my web-site - Michael Kors

Anonymous said...

Hi Dear, are you actually visiting this web page daily,
if so after that you will definitely obtain good know-how.


my blog; Tory Burch Shoes

Unknown said...

Dear Admin,
Please join with "Wikasitha Syndi" the blog reader. You may automatically join by entering URL of your Blogger or WordPress blog. All other Feeds enable web sites could be joined.
http://www.syndi.wikasitha.com/
Thanks.
Yours faithful,

Admin WIkasitha Syndi

Shalini said...

Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.

seo company in chennai

Unknown said...

wow really superb you had posted one nice information through this. Definitely it will be useful for many people. So please keep update like this.

Web Design Company in Chennai

Anjelina Williams said...

Highly recommend http://repository.kln.ac.lk/ to read and download more academic ,practice and policy articles free of charge on this topic.

 
°.MคNןU.°Powered by Blogger