构建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/

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值