目录
自制yum仓库
yum仓库配置文件
# 仓库名称
[base]
# 仓库描述
name=CentOS-$releasever - Base - mirrors.aliyun.com
# 仓库地址
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
# 检测签名机制(1:开启检测 0:关闭检测)
gpgcheck=1
# 签名机制秘钥地址
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
yum仓库类型
# 1.远程仓库
http:// 端口:80
https:// 端口:443
ftp:// 端口:21
# 2.本地仓库
file:// 没有端口(本地协议)
创建本地yum仓库(file://)
# 前提条件
1.创建仓库的命令
- createrepo
2.还要有rpm包
- 网站获取
- 镜像获取
- yum源获取
3.yum源的配置文件
# 1.安装创建仓库的命令
[root@localhost ~]# yum install -y createrepo
# 2.通过镜像,获取rpm包
1).挂载镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
2).创建一个仓库目录
[root@localhost ~]# mkdir /local_yum_repo
3).拷贝所有rpm包到仓库目录中
[root@localhost ~]# cp /mnt/Packages/*.rpm /local_yum_repo/
4).把目录变成仓库
[root@localhost ~]# createrepo /local_yum_repo/
Spawning worker 0 with 4070 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
5).检查是否把目录变成了仓库
[root@localhost ~]# ll -d /local_yum_repo/repodata/
drwxr-xr-x. 2 root root 4096 Apr 25 13:12 /local_yum_repo/repodata/
6).压缩其它yum源
[root@localhost ~]# gzip -r /etc/yum.repos.d/
7).手写yum源配置文件(必须与.repo结尾)
[root@localhost ~]# vim /etc/yum.repos.d/local.repo
# 仓库名称
[lza_local]
# 仓库描述
name=Local Repository By lza
# 仓库的地址
baseurl=file:///local_yum_repo
# 关闭签名检测机制
gpgcheck=0
# 开启仓库
enabled=1
8).使用yum源
[root@localhost ~]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
lza_local | 2.9 kB 00:00
lza_local/primary_db | 3.2 MB 00:00
repo id repo name status
lza_local Local Repository By lza enabled: 4,070
repolist: 4,070
创建远程yum仓库
# 前提条件
1.创建仓库的命令
- createrepo
2.还要有rpm包
- 网站获取
- 镜像获取
- yum源获取
3.yum源的配置文件
# 1.安装创建仓库的命令
[root@localhost ~]# yum install -y createrepo
# 2.通过镜像,获取rpm包
1).挂载镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
2).安装vsftpd服务
[root@localhost ~]# yum install -y vsftpd
3).启动服务
[root@localhost ~]# systemctl start vsftpd
4).检查端口
如果没有netstat命令,则需要安装
[root@localhost ~]# yum install -y net-tools
[root@localhost ~]# netstat -lntup|grep vsftpd
tcp6 0 0 :::21 :::* LISTEN 1274/vsftpd
5).打开浏览器访问
ftp://IP
6).关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
7).创建仓库目录
[root@localhost ~]# mkdir /var/ftp/pub/{base,epel}
[root@localhost ~]# ll /var/ftp/pub/
total 0
drwxr-xr-x. 2 root root 6 Apr 25 16:36 base
drwxr-xr-x. 2 root root 6 Apr 25 16:36 epel
8).拷贝rpm包到base目录下
[root@localhost ~]# cp /mnt/Packages/* /var/ftp/pub/base/
9).下载rpm包到epel源
[root@localhost epel]# wget https://mirrors.aliyun.com/epel/7/x86_64/Packages/n/nginx-1.20.1-9.el7.x86_64.rpm
[root@localhost epel]# curl -s https://mirrors.aliyun.com/epel/7/x86_64/Packages/z/|awk -F '"' '/.rpm/{print "wget https://mirrors.aliyun.com/epel/7/x86_64/Packages/z/"$4}'|bash
10).把目录变成仓库
[root@localhost pub]# createrepo /var/ftp/pub/base
[root@localhost pub]# createrepo /var/ftp/pub/epel
11).在其它机器上先压缩其它yum源,在手写.repo配置文件
[root@localhost ~]# gzip -r /etc/yum.repos.d/
[root@localhost ~]# vi /etc/yum.repos.d/base.repo
[lza_base]
name=The Base Repository By lza
baseurl=ftp://10.0.0.103/pub/base/
gpgcheck=0
enabled=1
[root@localhost yum.repos.d]# vi epel.repo
[lza_epel]
name=The Epel Repository By lza
baseurl=ftp://10.0.0.103/pub/epel/
gpgcheck=0
enabled=1
12).检查yum仓库
清除所有缓存
[root@localhost yum.repos.d]# yum clean all
重新加载缓存
[root@localhost yum.repos.d]# yum makecache
查看仓库所有安装包
[root@localhost ~]# yum repolist all
Loaded plugins: fastestmirror
Determining fastest mirrors
lza_base | 2.9 kB 00:00
lza_epel | 2.9 kB 00:00
(1/2): lza_base/primary_db | 3.2 MB 00:00
(2/2): lza_epel/primary_db | 3.0 kB 00:00
repo id repo name status
lza_base base Repository By lza enabled: 4,070
lza_epel epel Repository By lza enabled: 1
repolist: 4,071
13).使用yum安装rpm包,查看安装路径
标签:epel,仓库,自制,yum,lza,root,localhost
From: https://www.cnblogs.com/LZA1218/p/16769929.html