自制YUM仓库
原创
©著作权归作者所有:来自51CTO博客作者少年已不年少的原创作品,请联系作者获取转载授权,否则将追究法律责任
一.YUM仓库配置文件
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
二.YUM仓库类型
http:// 端口:80
https:// 端口:443
ftp:// 端口:21
file:// 没有端口(本地协议)
http:// 端口:80
https:// 端口:443
ftp:// 端口:21
file:// 没有端口(本地协议)
三.本地YUM仓库(file://)
1)创建仓库的命令
- createrepo
2)还要有rpm包
- 网站获取
- 镜像获取
- yum源获取
3)yum源的配置文件
[root@localhost <sub>]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: ftp.sjtu.edu.cn
Package createrepo-0.9.9-28.el7.noarch already installed and latest version
Nothing to do
[root@localhost </sub>]
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost <sub>]
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.2G 18G 7% /
devtmpfs 476M 0 476M 0% /dev
tmpfs 487M 0 487M 0% /dev/shm
tmpfs 487M 7.6M 479M 2% /run
tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/sda1 497M 120M 378M 25% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /mnt
[root@localhost </sub>]
[root@localhost <sub>]
drwxr-xr-x. 2 root root 6 Apr 25 20:56 quanyi_yum_repo
[root@localhost </sub>]
[root@localhost <sub>]
[root@localhost </sub>]
[root@localhost <sub>]
[root@localhost </sub>]
total 1028
-rw-r--r--. 1 root root 47508 Apr 25 20:59 tree-1.6.0-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 173704 Apr 25 20:59 unzip-6.0-19.el7.x86_64.rpm
-rw-r--r--. 1 root root 560152 Apr 25 21:00 wget-1.14-18.el7.x86_64.rpm
-rw-r--r--. 1 root root 266160 Apr 25 20:59 zip-3.0-11.el7.x86_64.rpm
[root@localhost <sub>]
Spawning worker 0 with 4 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost </sub>]
drwxr-xr-x. 2 root root 4096 Apr 25 21:03 /quanyi_yum_repo/repodata/
[root@localhost <sub>]
[root@localhost </sub>]
total 28
-rw-r--r--. 1 root root 549 Nov 23 2018 CentOS-Base.repo.gz
-rw-r--r--. 1 root root 735 Nov 23 2018 CentOS-CR.repo.gz
-rw-r--r--. 1 root root 426 Nov 23 2018 CentOS-Debuginfo.repo.gz
-rw-r--r--. 1 root root 232 Nov 23 2018 CentOS-fasttrack.repo.gz
-rw-r--r--. 1 root root 381 Nov 23 2018 CentOS-Media.repo.gz
-rw-r--r--. 1 root root 506 Nov 23 2018 CentOS-Sources.repo.gz
-rw-r--r--. 1 root root 633 Nov 23 2018 CentOS-Vault.repo.gz
[root@localhost <sub>]
[lqy_local]
name=Local Repository By lqy
baseurl=file:///quanyi_yum_repo
gpgcheck=0
enabled=1
[root@localhost </sub>]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repolist: 0
[root@localhost <sub>]
[root@localhost </sub>]
[root@localhost <sub>]
[root@localhost </sub>]
[root@localhost ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
lqy | 2.9 kB 00:00:00
lqy/primary_db | 4.1 kB 00:00:00
repo id repo name status
lqy quanyiyuan enabled: 4
repolist: 4
四.远程ftp服务YUM仓库
1)创建仓库的命令
- createrepo
2)还要有rpm包
- 网站获取
- 镜像获取
- yum源获取
3)yum源的配置文件
[root@localhost <sub>]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: ftp.sjtu.edu.cn
* updates: ftp.sjtu.edu.cn
Package createrepo-0.9.9-28.el7.noarch already installed and latest version
Nothing to do
[root@localhost </sub>]
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost <sub>]
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.2G 18G 7% /
devtmpfs 476M 0 476M 0% /dev
tmpfs 487M 0 487M 0% /dev/shm
tmpfs 487M 7.6M 479M 2% /run
tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/sda1 497M 120M 378M 25% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /mnt
[root@localhost </sub>]
[root@localhost <sub>]
如果没有netstat 命令,则需要安装
[root@localhost </sub>]
[root@localhost ~]
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6859/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 7016/master
tcp6 0 0 :::21 :::* LISTEN 7619/vsftpd
tcp6 0 0 :::22 :::* LISTEN 6859/sshd
tcp6 0 0 ::1:25 :::* LISTEN 7016/master

[root@localhost <sub>]
[root@localhost </sub>]
[root@localhost <sub>]
[root@localhost </sub>]
total 0
drwxr-xr-x. 2 root root 6 Apr 25 20:58 base
drwxr-xr-x. 2 root root 6 Apr 25 20:58 epel
[root@localhost <sub>]
[root@localhost </sub>]
[root@localhost <sub>]
[root@localhost epel]
[root@localhost pub]
Spawning worker 0 with 3 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost pub]
Spawning worker 0 with 2 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost pub]
total 860
drwxr-xr-x. 2 root root 4096 Apr 25 21:54 repodata
-rw-r--r--. 1 root root 47508 Apr 25 21:01 tree-1.6.0-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 560152 Apr 25 21:02 wget-1.14-18.el7.x86_64.rpm
-rw-r--r--. 1 root root 266160 Apr 25 21:01 zip-3.0-11.el7.x86_64.rpm
[root@localhost pub]
total 200
-rw-r--r--. 1 root root 21966 Apr 10 2020 nagios-plugins-breeze-2.3.3-2.el7.x86_64.rpm
drwxr-xr-x. 2 root root 4096 Apr 25 21:54 repodata
-rw-r--r--. 1 root root 173704 Apr 25 21:13 unzip-6.0-19.el7.x86_64.rpm
[root@localhost </sub>]
[root@localhost <sub>]
total 28
-rw-r--r--. 1 root root 549 Nov 23 2018 CentOS-Base.repo.gz
-rw-r--r--. 1 root root 735 Nov 23 2018 CentOS-CR.repo.gz
-rw-r--r--. 1 root root 426 Nov 23 2018 CentOS-Debuginfo.repo.gz
-rw-r--r--. 1 root root 232 Nov 23 2018 CentOS-fasttrack.repo.gz
-rw-r--r--. 1 root root 381 Nov 23 2018 CentOS-Media.repo.gz
-rw-r--r--. 1 root root 506 Nov 23 2018 CentOS-Sources.repo.gz
-rw-r--r--. 1 root root 633 Nov 23 2018 CentOS-Vault.repo.gz
[root@localhost </sub>]
[quanyiyuan]
name=Local Repository By lqy
baseurl=ftp://10.0.0.100/pub/base
gpgcheck=0
enabled=1
[root@localhost <sub>]
[lqy_local]
name=Local Repository By Quanyi
baseurl=ftp://10.0.0.100/pub/epel
gpgcheck=0
enabled=1
[root@localhost </sub>]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
lqy_local | 2.9 kB 00:00:00
quanyiyuan | 2.9 kB 00:00:00
lqy_local/primary_db | 2.7 kB 00:00:00
repo id repo name status
lqy_local Local Repository By Quanyi 2
quanyiyuan Local Repository By lqy 3
repolist: 5

