Saturday 4 June 2022

 Create a Yum Local repository

# yum install createrepo yum-utils epel-release nginx

# systemctl enable nginx

# systemctl start nginx

# systemctl status nginx

# firewall-cmd --zone=public --permanent --add-service=http

# firewall-cmd --reload

# mkdir -p /var/www/html/repos/{base,centosplus,extra,updates}

# reposync -g -l -d -m --repoid=base --newest-only --downloadcomps --download-metadata --download_path=/var/www/html/repos/

# reposync -g -l -d -m --repoid=centosplus --newest-only --downloadcomps --download-metadata --download_path=/var/www/html/repos/

# reposync -g -l -d -m --repoid=extras --newest-only --downloadcomps --download-metadata --download_path=/var/www/html/repos/

# reposync -g -l -d -m --repoid=updates --newest-only --downloadcomps --download-metadata --download_path=/var/www/html/repos/

# createrepo -v /var/www/html/repos/base/ -g comps.xml 

# createrepo -v /var/www/html/repos/centosplus/ -g comps.xml

# createrepo -v /var/www/html/repos/extras/ -g comps.xml

# createrepo -v /var/www/html/repos/updates/ -g comps.xml


Options error: --dh fails with 'dh2048.pem': No such file or directory (errno=2)

Options error: --cert fails with 'server.crt': No such file or directory (errno=2)

Options error: Please correct these errors.


-g – enables removing of packages that fail GPG signature checking after downloading.

-l – enables yum plugin support.

-d – enables deleting of local packages no longer present in the repository.

-m – enables downloading of comps.xml files.

--repoid – specifies the repository ID.

--newest-only – tell reposync to only pull the latest version of each package in the repos.

--download-metadata – enables downloading all the non-default metadata.

--download_path – specifies the path to download packages.


# vi /etc/nginx/conf.d/repos.conf

server {

        listen   80;

        server_name  192.168.10.1;  

        root   /var/www/html/repos;

        location / {

                index  index.php index.html index.htm;

                autoindex on;

        }

}


# systemctl restart nginx


Daily Update repository server

# vi /etc/cron.daily/update-localrepos

#!/bin/bash

##specify all local repositories in a single variable

LOCAL_REPOS=”base centosplus extras updates”

##a loop to update repos one at a time 

for REPO in ${LOCAL_REPOS}; do

reposync -g -l -d -m --repoid=$REPO --newest-only --download-metadata --download_path=/var/www/html/repos/

createrepo -g comps.xml /var/www/html/repos/$REPO/  

done

# chmod 755 /etc/cron.daily/update-localrepos


Client config


# vi /etc/yum.repos.d/local-repos.repo

[local-repo]

name=Local CentOS Repository

baseurl=http://192.168.10.1/base

gpgcheck=0

enabled=1


# yum repolist

# yum search nano

# yum install nano



No comments:

Post a Comment