[TOC]
本文将讲解常用yum源离线包的制作。
## **准备工作**
* 准备一台主机,可以连接外网
* 执行以下命令在主机上安装`reposync`工具(在`yum-utils`包中)与`createrepo`工具
```
$ sudo yum -y install yum-utils createrepo
```
* 新建一个目录offline-yum,并进入到该目录下
## **基础yum源**
#### **添加repo文件**
在`/etc/yum.repos.d/`目录下创建文件`ustc-base.repo`,内容如下
```
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=0
enabled=1
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=0
enabled=1
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=0
enabled=1
```
#### **同步base**
进入到`offline-yum`目录下,创建目录`base/os`,然后执行以下命令同步`[base]`的rpm包到`base/os`目录下:
```
$ mkdir -p base/os
$ reposync --repoid base --download_path ./base/os --norepopath --delete --newest-only
```
上面的reposync命令中:
* `--repoid`:表示同步哪个repoid的rpm包,ustc.repo文件中`[base]`、`[updates]`、`[extras]`就是repoid,所有.repo文件的repoid不能冲突
* `--download_path`:表示把rpm下载到哪个目录下
* `--norepopath`表示不在`--download_path`下新建以`--repoid`为名字的目录;比如上面的命令就不会在`base/os/`下再新建`base`目录
* `--delete`:如果本地`base/os/`目录下有rpm包,但是在远程yum源已经没有了,则删除本地的rpm包
* `--newest-only`:对于同一个软件,只下载最新的rpm包
由于我们不需要`i386`与`i686`的包,所以删除这些包
```
$ rm -vf base/os/*i386.rpm
$ rm -vf base/os/*i686.rpm
```
然后执行以下命令创建repodata数据,此时会在`base/os/`目录下创建一个目录`repodata`
```
$ createrepo -d base/os
```
#### **同步updates**
创建目录`base/updates`,然后执行以下命令同步`[updates]`的rpm包到`base/updates`目录下:
```
$ mkdir base/updates
$ reposync --repoid updates --download_path ./base/updates --norepopath --delete --newest-only
```
删除i386与i686的包,然后创建repodata数据
```
$ rm -vf base/updates/*i386.rpm
$ rm -vf base/updates/*i686.rpm
$ createrepo -d base/updates
```
#### **同步extras**
创建目录`base/extras`,然后执行以下命令同步`[extras]`的rpm包到`base/extras`目录下:
```
$ mkdir base/extras
$ reposync --repoid extras --download_path ./base/extras --norepopath --delete --newest-only
```
删除i386与i686的包,然后创建repodata数据
```
$ rm -vf base/extras/*i386.rpm
$ rm -vf base/extras/*i686.rpm
$ createrepo -d base/extras
```
## **EPEL源**
在`/etc/yum.repos.d/`目录下创建文件`ustc-epel.repo`,内容如下:
```
[epel]
name=epel - $basearch
baseurl=http://mirrors.ustc.edu.cn/epel/7/$basearch
enabled=1
gpgcheck=0
```
创建目录epel,然后执行以下命令同步rpm包
```
$ reposync --repoid epel --download_path ./epel --norepopath --delete --newest-only
```
然后清理掉i386与i686的包,然后创建repodata
```
$ rm -vf epel/*/*i386.rpm
$ rm -vf epel/*/*i686.rpm
$ createrepo -d ./epel
```
## **CEPH源**
- 常用命令
- 用户与用户组
- 创建用户与用户组
- 快速脚本
- umask
- Yum源
- 基础Yum源
- Epel源
- 制作Yum源
- 同步Yum源
- 为Yum源配置代理
- 下载RPM及依赖
- 系统与内核
- 获取内核的rpm包
- 升级内核
- Iptables
- 基本语法
- 匹配条件
- 基础匹配条件
- 扩展匹配条件
- Addrtype
- Set
- TCP
- Mark
- Multiport
- 目标
- 基本目标
- 扩展目标
- DNAT
- LOG
- CT
- NOTRACK
- MARK
- IP set
- 连接追踪
- 初识连接追踪
- 连接追踪详解
- NAT
- 思路与参考汇总
- 数据结构
- FAQ
- Keepalived
- 单网卡多VIP
- 安装Keepalived
- 双网卡绑VIP
- 别名VIP和辅助VIP
- LVS
- 安装LVS
- Ipvsadm命令
- 磁盘与分区
- 基础知识
- 创建分区
- 格式化与挂载
- Fstab
- LVM
- LVM扩容
- Swap分区
- Tmpfs
- 网络相关
- 重命名网卡
- resolv.conf
- Tcpdump
- nslookup与dig
- ifcg-xxx
- 主机名
- 软件安装
- NFS
- Squid
- Redsocks
- Shadowsocks
- 时钟同步
- Chrony
- FTP
- 文件句柄
- 简介
- 设置文件句柄
- 其他
- SSH密钥登录
- 进程组-会话-终端
- X11转发
- 环境变量
- 常见问题
- 系统进程数
- 系统调用
- 系统调用FAQ
- 用户程序如何进行系统调用