[toc]

制作企业级yum仓库

安装并启动vsftpd服务

1
2
yum install -y vsftpd		# 安装一个vsftpd服务,让机器编程网络服务
systemctl start vsftpd # 启动ftp服务

关闭seLinux和防火墙

1
2
3
4
5
6
7
# 关闭seLinux
getenforce 0 # 关闭selinux(临时关闭)
vim /etc/sysconfig/selinux # 永久关闭selinux
SELINUX=disabled ## 修改配置文件
# 关闭防火墙
systemctl stop firewalld # 停止防火墙(临时关闭)
systemctl disable firewalld # 永久关闭防火墙

准备base源目录和文件

1
2
3
4
mount /dev/cdrom /mnt/			# 挂载磁盘
df -h # 检查磁盘挂载状态
mkdir /var/ftp/base # 在ftp目录下创建好base目录
cp /mnt/Packages/* /var/ftp/base/ # 拷贝所有的安装包到仓库目录

制作仓库

1
2
yum install -y createrepo		# 安装一个仓库制作命令
createrepo /var/ftp/base # 将/var/ftp创建为仓库

配置并使用base源

1
2
3
4
5
6
7
gzip /etc/yum.repos.d/*							# 将原使用的源压缩
vim /etc/yum.repos.d/chaojibaolongzhanshi.repo # 创建新的源文件并进行配置
[chaojibaolongzhanshi]
name=chaojibaolongzhanshi_base
baseurl=ftp://10.0.0.100/base
gpgcheck=0
enabled=1

查看当前所有可用源

1
2
3
4
yum repolist		# 查看当前yum的源
repo id repo name status
chaojibaolongzhanshi chaojibaolongzhanshi_base 0
repolist: 0

检查源是否可用

1
2
3
4
5
6
7
8
9
10
11
yum reinstall -y tree			# 重新安装tree进行测试
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
chaojibaolongzhanshi | 2.9 kB 00:00
chaojibaolongzhanshi/primary_db | 3.1 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

制作base源和epel源并用另一台设备访问

10.0.0.100设备

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 安装并启动vsftpd服务
yum install -y vsftpd # 安装一个vsftpd服务,让机器编程网络服务
systemctl start vsftpd # 启动ftp服务

# 关闭selinux和防火墙
vim /etc/sysconfig/selinux # 永久关闭selinux
SELINUX=disabled ## 修改配置文件
systemctl disable firewalld # 永久关闭防火墙

# 准备base源和epel源目录和文件
## 准备base源目录和文件
mount /dev/cdrom /mnt/ # 挂载磁盘
df -h # 检查磁盘挂载状态
mkdir /var/ftp/base # 在ftp目录下创建好base目录
cp /mnt/Packages/* /var/ftp/base/ # 拷贝所有的安装包到仓库目录
## 准备epel源目录和文件
mkdir /var/ftp/epel # 创建epel仓库的目录
wget http://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm -P /var/ftp/epel/ # 将chree的包下载至epel仓库的路径下

# 制作仓库
yum install -y createrepo # 安装一个仓库制作命令
createrepo /var/ftp/base # 将/var/ftp创建为仓库
createrepo /var/ftp/epel # 将/var/ftp创建为仓库

10.0.0.101设备

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 配置并使用base源和epel源
gzip /etc/yum.repos.d/* # 将原来使用的源压缩

vim /etc/yum.repos.d/baolongzhanshi # 创建base源文件并进行配置
[baolongzhanshi]
name=baolongzhanshi_base
baseurl=ftp://10.0.0.100/base
gpgcheck=0
enabled=1
vim /etc/yum.repos.d/chaojibaolongzhanshi # 创建epel源文件并进行配置
[chaojibaolongzhanshi]
name=chaojibaolongzhanshi_epel
baseurl=ftp://10.0.0.100/epel
gpgcheck=0
enabled=1

yum repolist # 查看当前yum的源
repo id repo name status
baolongzhanshi baolongzhanshi_base 0
chaojibaolongzhanshi chaojibaolongzhanshi_epel 0
repolist: 0

# 检查源是否可用

​```bash
yum reinstall -y tree # 重新安装tree进行测试
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
Package Arch Version Repository Size
========================================================================================
Reinstalling:
tree x86_64 1.6.0-10.el7 baolongzhanshi 46 k

Transaction Summary
========================================================================================
Reinstall 1 Package

Total download size: 46 k
Installed size: 87 k
Downloading packages:
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tree-1.6.0-10.el7.x86_64 1/1
Verifying : tree-1.6.0-10.el7.x86_64 1/1

Installed:
tree.x86_64 0:1.6.0-10.el7

Complete!