局域网搭建yum仓库
yum简介:yum就是一个rpm包管理工具,yum仓库包含存放rpm包的目录/base和仓库元数据信息的目录/repodata
场景:在局域网搭建yum仓库的场景:内网中只允许一台服务器(yum源服务器)访问外网,其他服务器的软件安装就需要通过yum源服务器来获取安装包,这就需要在yum源服务器有本地仓库。
方法思路:就是定期将yum源服务器的yum源仓库的rpm包同步到本地目录,然后搭建web
步骤:
- 登录yum源服务器,查看此服务器的yum源配置
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@VM-0-4-centos ~]# yum repolist
Repository extras is listed more than once in the configuration
repo id repo name
AppStream CentOS-8.5.2111 - AppStream - mirrors.aliyun.com
appstream CentOS Linux 8 - AppStream
base CentOS-8.5.2111 - Base - mirrors.aliyun.com
baseos CentOS Linux 8 - BaseOS
epel Extra Packages for Enterprise Linux 8 - x86_64
epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64
extras CentOS-8.5.2111 - Extras - mirrors.aliyun.com
mysql-connectors-community MySQL Connectors Community
mysql-tools-community MySQL Tools Community
mysql80-community MySQL 8.0 Community Server</code></pre>
|
- 创建本地yum仓库的目录,用以存放base和repodata
- 使用reposync命令,将指定yum源仓库的rpm包同步到/data目录中
reposync命令需要安装yum-util才会有
1
2
3
4
|
[root@VM-0-4-centos yum.repos.d]# reposync --repoid=AppStream --repoid=base -p /data
[root@VM-0-4-centos ~]# ll /data
total 8
drwxr-xr-x 3 root root 4096 Mar 5 20:06 base
|
- –repoid:指定所需同步仓库
- -p:指定存放目录
- 使用createrepo创建repodata,createrepo命令也需要另外安装
1
2
3
4
5
|
[root@VM-0-4-centos data]# createrepo -v /data
[root@VM-0-4-centos ~]# ll /data
total 8
drwxr-xr-x 3 root root 4096 Mar 5 20:06 base
drwxr-xr-x 2 root root 4096 Mar 5 20:11 repodata
|