构建Oracle linux R8 本地 yum源

1、创建repos目录

# mkdir -p /repos/ol8

2、安装yum-utils和createrepo工具

# yum install yum-utils createrepo

3、编辑yum配置文件,全部 enbaled=1 变为 enabled=0

# vi /etc/yum.repos.d/oracle-linux-ol8.repo

4、同步baseos_latest和appstream                

# reposync --repoid=ol8_baseos_latest --repoid=ol8_appstream -p /repos/ol8

5、生成元数据

# createrepo /repos/ol8/ol8_baseos_latest/getPackage/
# createrepo /repos/ol8/ol8_appstream/getPackage/

6、编辑自动更新文件

#!/bin/bash
LOG_FILE=/repos/logs/orayum-update_$(date +%Y.%m.%d).log
/usr/bin/reposync --repoid=ol8_baseos_latest --repoid=ol8_appstream -p /repos/ol8 >> $LOG_FILE 2>&1
/usr/bin/createrepo /repos/ol8/ol8_baseos_latest/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /repos/ol8/ol8_appstream/getPackage/ >> $LOG_FILE 2>&1

7、创建log和script目录,将脚本移动到script目录下 ,并+x

# mkdir -p /repos/logs
# mkdir -p /repos/scripts
# mv orayum-update.sh /repos/scripts
# chmod +x /repos/scripts/orayum-update.sh

8、编辑crontab,每天0点执行同步

# crontab -e
0 0 * * * /repos/scripts/orayum-update.sh

9、安装并配置httpd

# yum install nginx
# systemctl enable nginx
# systemctl start nginx
# vim /etc/nginx/nginx.conf
    server {
        autoindex on;# 显示目录
	autoindex_exact_size on;# 显示文件大小
	autoindex_localtime on;# 显示文件时间

	listen       80 default_server;
	listen       [::]:80 default_server;
.
.
.
# mkdir -p /usr/share/nginx/html/repo/OracleLinux/OL8/baseos/latest
# mkdir -p /usr/share/nginx/html/repo/OracleLinux/OL8/appstream
# ln -s /repos/ol8/ol8_baseos_latest/getPackage/ /usr/share/nginx/html/repo/OracleLinux/OL8/baseos/latest/x86_64
# ln -s /repos/ol8/ol8_appstream/getPackage/ /usr/share/nginx/html/repo/OracleLinux/OL8/appstream/x86_64
# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload
#setenforce 0
#vim /etc/selinux/config
    SELINUX=disabled 
# cd /var/www/html
# wget http://yum.oracle.com/RPM-GPG-KEY-oracle-ol8
#  vi /etc/yum.repos.d/oracle-linux-ol8.repo
[ol8_baseos_latest]
name=Oracle Linux 8 BaseOS Latest ($basearch)
baseurl=https://hostname/repo/OracleLinux/OL8/baseos/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

[ol8_appstream]
name=Oracle Linux 8 Application Stream ($basearch)
baseurl=https://hostname/repo/OracleLinux/OL8/appstream/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

update:

如果要镜像comps.xml 文件, 增加 --downloadcomps 选项:

/usr/bin/reposync --repoid=ol8_baseos_latest --repoid=ol8_appstream -p /repos/ol8  --downloadcomps >> $LOG_FILE 2>&1

并且需要在greaterepo加 -g 标志

#!/bin/bash
LOG_FILE=/repos/logs/orayum-update_$(date +%Y.%m.%d).log
/usr/bin/reposync --repoid=ol8_baseos_latest --repoid=ol8_appstream -p /repos/ol8 --downloadcomps >> $LOG_FILE 2>&1
/usr/bin/createrepo -g /repos/ol8/ol8_baseos_latest/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo -g /repos/ol8/ol8_appstream/getPackage/ >> $LOG_FILE 2>&1

参考:https://blog.hazrulnizam.com/local-mirror-of-oracle-public-yum/

 

你可能感兴趣的:(构建Oracle linux R8 本地 yum源)