CentOS 添加本地yum源

时间:2023-11-09 17:31:35

1 创建保存RPM包的路径:

  mkdir -p /share/CentOS/7/local/x86_64/RPMS  

2 安装createrepo工具

  yum install createrepo

3 把RPM包拷贝到 /share/CentOS/7/local/x86_64//RPMS下,并更改目录权限

  mv  *.rpm /share/CentOS/7/local/x86_64/RPMS

chown -R root.root /share/CentOS/7/local

chmod -R o-w+r /share/CentOS/7/local

4 使用 createrepo 创建元数据

  createrepo /share/CentOS/7/local/x86_64

5 更改yum 配置文件

  [local]

name=CentOS-$releasever - local packages for $basearch

baseurl=file:///share/CentOS/$releasever/local/$basearch

  enabled=1

  gpgcheck=0

  protect=1

6 更新yum缓存

  yum clean all

  yum makecache

参考文档:https://wiki.centos.org/HowTos/CreateLocalRepos