纯内网配置本地源更新安装包-aoaolinux-aoaoubuntu-aoaocentos-aoaoredhat

发布于 2024年07月18日


一些更新源

网易163 yum源,安装方法查看:http://mirrors.163.com/.help/

中科大的 yum源,安装方法查看:https://lug.ustc.edu.cn/wiki/mirrors/help

sohu的 yum源,安装方法查看: http://mirrors.sohu.com/help/

阿里云的 yum源,安装方法查看: https://opsx.alibaba.com/mirror

清华大学的 yum源,安装方法查看: https://mirrors.tuna.tsinghua.edu.cn/

浙江大学的 yum源,安装方法查看: http://mirrors.zju.edu.cn/

中国科技大学yum源,安装方法查看: http://centos.ustc.edu.cn/

网易163源配置更新

增加163repo

# vi /etc/yum.repo.d/163.repo

[163.repo]

name=mirrors.163.com.repo

baseurl=http://mirrors.163.com/centos/7/os/x86_64/

enabled=1

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

清除缓存生成缓存

yum clean all

yum make cache

CentOS 7 配置163**源**

具体的操作步骤:

1、打开终端,输入su指令切换到aoao.club用户:su

2、切换到系统yum源的目录下,即:cd /etc/yum.repos.d

3、备份系统默认yum源(也可直接删除):mv CentOS-Base.repo CentOS-Base.repo.backup

4、下载163网易的yum源:wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

5、yum源更新:yum clean all && yum makecache

6、完成

排除部分组件

yum update --exclude=kernel

yum**添加源**

yum -y install yum-utils

$ sudo yum-config-manager \

--add-repo \

https://download.docker.com/linux/centos/docker-ce.repo

可以选择国内的一些源地址:

阿里云

$ sudo yum-config-manager \

--add-repo \

http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

清华大学源

$ sudo yum-config-manager \

--add-repo \

https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo

一、私有yum源yum源创建过程

1.**创建工作目录**

mkdir /aoao.club/epeltest mkdir /aoao.club/epeltest/Packages

2.**将相应的rpm包放到/aoao.club/epeltest/Packages 目录**

采用yum下载软件包,以ansible为例:

(1)安装epel yum源,方便下载ansible

yum -y install epel-release

(2)安装createrepo,用于制作yum源

yum -y install createrepo

(3)通过yum下载ansible相关的软件包,存放到/aoao.club/epeltest/Packages目录

yum install ansible --downloadonly --downloaddir=/aoao.club/epeltest/Packages

3.**执行命令创建yum源**

createrepo /aoao.club/epeltest/

命令执行后将在/aoao.club/epeltest目录下生成repodata,该目录存储的是yum源的信息。至此,yum源已制作完毕,通过repo文件制定/aoao.club/epeltest/目录即可进行本地安装ansible。

二、将自制yum源制作ISO镜像

1.**安装mkisofs**

yum -y install mkisofs

2.**将自制的yum源制作iso镜像**

mkisofs -r -o epel7.iso /aoao.club/epeltest

三、通过本地yum源安装ansible

提示:将章节一中/aoao.club/epeltest目录拷贝到需要安装ansible机器,并配置yum源配置文件即可。本节重点介绍如何挂载iso文件作为本地yum源。

1.**将章节二中制作的iso文件拷贝到目标机器,并挂载**

#挂载目录可自行定义 mount -o loop epel7.iso /mnt

2.**配置yum源**

(1)将/etc/yum.repos.d/ 目录中的文件备份,然后删除所有的repo文件。此步骤主要是为了防止其他repo对测试有干扰

(2)创建repo文件,如local.repo,内容如下:

[epel] name=epel baseurl=file:///mnt/ gpgcheck=0 enabled=1

(3)清除yum源缓存

yum clean all yum makecache

3.**安装程序ansible**

yum install ansible

1,强制卸载所有包

rpm -qa|grep yum|xargs rpm -e --nodeps

2,查看是否卸载完全

rpm -qa|grep yum

3,下载相关的rpm插件,

mkdir software

cd software

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.11.3-43.el7.x86_64.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-43.el7.x86_64.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-43.el7.x86_64.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-167.el7.centos.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-filter-data-1.1.31-53.el7.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-53.el7.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-53.el7.noarch.rpm

4,安装所有插件

rpm -ivh *.rpm --force --nodeps

5,修改yum配置

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

6,修改CentOS-Base.repo文件

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

$releasever全局替换成7执行

:%s/$releasever/7/g

mirrors.aliyuncs.com 全部改成 mirrors.aliyun.com 不然后面会报错,mirrors.aliyuncs.com这个域名好像有问题,具体情况不明:

:s/aliyuncs/aliyun/g

:wq 保存退出

7,#yum clean all

#yum makecache 生成元数据缓存

测试

yum -y install tree 用tree查看文件夹结构

下面分享一下利用 iso 镜像搭建本地 yum 仓库的简单步骤:

一、准备工作

下载或拷贝 CentOS 或 RedHat 的 iso 镜像到本地,比如 /usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso

二、挂载 iso 镜像

①、新建挂载目录:

mkdir -p /mnt/cdrom1

②、直接编辑/etc/fstab 文件(编辑请请备份),在后面添加:

#挂载iso

/usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom1 iso9660 loop,defaults 0 0

②、执行 mount -a 自动检测并激活挂载,若未报错,执行 df -h 即可看到结果。

三、配置并刷新 yum 仓库

①、新增 yum 配置文件:

Ps:完全离线使用,新增之前建议先删除(移走)所有在线 yum 源:mv -f /etc/yum.repos.d/* /home/

vim /etc/yum.repos.d/local.repo

粘贴以下内容,第 3 行表示 iso 挂载目录:

[local-yum]

name=Local Repository

baseurl=file:///mnt/cdrom1

enabled=1

gpgcheck=0

②、刷新查看 yum 是否生效:

yum clean all && yum list

以上要是没要报错,那么本地 yum 仓库就搭建好了,就可以使用【 yum install 软件名】来安装所需软件,而不需要联网了。

四、多个 iso 镜像的做法:

Ps:下面只说有区别的部分。

①、挂载的时候,有几个 iso 就挂载几个,比如 CentOS 6.4 有 2 个 iso:

#创建2个挂载目录

mkdir -p /mnt/cdrom{1,2}

#挂载iso

/usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom1 iso9660 loop,defaults 0 0/usr/local/src/CentOS-6.4-x86_64-bin-DVD2.iso /mnt/cdrom2 iso9660 loop,defaults 0 0

#激活挂载

mount -a

②、编辑 yum 配置文件的时候,路径需要改成上一级路径,比如:

[local-yum]

name=Local Repository

baseurl=file:///mnt/

enabled=1

gpgcheck=0

③、使用 createrepo 命令创建 yum 仓库:

cd /mnt/

createrepo .

最经比较忙, 还没来得及截图,先凑合发布了,等有空了再来补充。

Redhat 6.0 CentOS6.0

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client. You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-vault-6.10 - Base - mirrors.163.com

failovermethod=priority

baseurl=http://mirrors.163.com/centos-vault/6.10/os/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos-vault/RPM-GPG-KEY-CentOS-6

#released updates

[updates]

name=CentOS-vault-6.10 - Updates - mirrors.163.com

failovermethod=priority

baseurl=http://mirrors.163.com/centos-vault/6.10/updates/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-vault-6.10 - Extras - mirrors.163.com

failovermethod=priority

baseurl=http://mirrors.163.com/centos-vault/6.10/extras/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-vault-6.10 - Plus - mirrors.163.com

failovermethod=priority

baseurl=http://mirrors.163.com/centos-vault/6.10/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://mirrors.163.com/centos-vault/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users

[contrib]

name=CentOS-vault-6.10 - Contrib - mirrors.163.com

failovermethod=priority

baseurl=http://mirrors.163.com/centos-vault/6.10/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://mirrors.163.com/centos-vault/RPM-GPG-KEY-CentOS-6

网络需求说明

为了加速漏洞的修复,建议临时开通网络权限,允许服务器在线进行补丁和kernel更新,不同类型的Linux版本需要开通的网络地址分别如下:

Centos

https://developer.aliyun.com/mirror/?spm=a2c6h.12883283.J_5404914170.29.5f1f4307VgaBI9

http/https

80/443

Redhat

https://developer.aliyun.com/mirror/?spm=a2c6h.12883283.J_5404914170.29.5f1f4307VgaBI9

http/https

80/443

Redhat跟CentOS可以使用同一个源

Ubuntu

https://developer.aliyun.com/mirror/?spm=a2c6h.12883283.J_5404914170.29.5f1f4307VgaBI9

http/https

80/443

配置在线更新源

各个版本操作系统配置在线源方法如下:

Centos

1、备份

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

2、下载新的repo

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

3、运行yum makecache

Redhat

同CentOS

Ubuntu

1、编辑/etc/apt/sources.list

http://archive.ubuntu.com/ 修改为 mirrors.aliyun.com

2、

ubuntu 16.04 配置如下

deb http://mirrors.aliyun.com/ubuntu/ xenial main

deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe

deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main

deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

ubuntu 18.04(bionic) 配置如下

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

# deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

ubuntu 20.04(focal) 配置如下

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

# deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

# deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

安装包重复问题处理

#运行重复传输

yum-complete-transaction

# 运行 yum-complete-transaction

yum-complete-transaction –cleanup-only

#查看可能重复包

package-cleanup

# 清除可能存在的重复包

package-cleanup --dupes

# 清除可能存在的损坏包

package-cleanup --problems



评论