首页 技术 正文
技术 2022年11月12日
0 收藏 960 点赞 2,422 浏览 2627 个字

这篇博客是yum仓库的配置过程,如果是yum客户端配置请参考 http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_002.html

1 环境介绍

这里我有2个环境,一个centos7,一个centos6环境, 打算使用centos6作为yum仓库,然后使用centos7作为客户端。

2 环境准备

我们知道配置yum的时候我们需要指定baseurl的,只有三种协议支持的,分别是http,ftp,file。这里我们我们选择ftp方式,在centos6机器上安装ftp软件并提供服务。

2.1 安装ftp服务端软件

[root@centos6 ~]# yum install vsftpd -y                #安装vsftpd软件,没有yum配置的话,可以使用rpm安装
[root@centos6 ~]# chkconfig vsftpd on #开机启动
[root@centos6 ~]# service vsftpd start #启动ftp服务
Starting vsftpd for vsftpd: [ OK ]

2.2 禁用selinux

[root@centos6 ~]# getenforce                            #查看当前的selinux状态
Enforcing
[root@centos6 ~]# setenforce 0 #禁用
[root@centos6 ~]# sed -i 's@SELINUX=enforcing@SELINUX=permissive@' /etc/sysconfig/selinux #修改配置文件

2.3 关闭防火墙

[root@centos6 ~]# service iptables status                      #查看当前的防火墙设置
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
ACCEPT all -- 0.0.0.0/ 0.0.0.0/
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)
num target prot opt source destination
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)
num target prot opt source destination [root@centos6 ~]# service iptables stop #关闭防火墙
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@centos6 ~]# chkconfig iptables off #开机不启动ftp

2 提供yum仓库文件

2.1 把centos7的包复制到centos6的机器上

[root@centos6 os]# mkdir -pv /var/ftp/pub/yum/centos/7/os/x86_64            #创建对应目录, 这个目录是仿照aliyun的那个目录组织的,清晰,这样客户端可以使用$basearch,$releasevel变量
[root@centos6 os]# mount /dev/sr1 -r /var/ftp/pub/yum/centos//os/x86_64    #我这里就直接挂载个光盘,建议使用硬盘文件,而不是光盘
[root@centos6 os]# ll /var/ftp/pub/yum/centos//os/x86_64

3 测试ftp服务是否正常

由于我们的centos7没有ftp的软件,所以这里使用wget测试下

[root@centos7 yum.repos.d]$wget ftp://172.18.1.159/                          #下载下ftp页面
[root@centos7 yum.repos.d]$ cat index.html |grep pub #查看是否有pub,如果有那就是ftp服务是正常的了
Nov : Directory <a href="ftp://172.18.1.159:21/pub/" rel="external nofollow" >pub/</a>

测试发现,我们的centos6提供的ftp一切正常, 可以供centos7使用的。

4 centos7配置测试yum

4.1 配置yum配置文件

[root@centos7 yum.repos.d]$ vim network.repo      #编写repo文件
[root@centos7 yum.repos.d]$ cat network.repo
[network]
name=network
baseurl=ftp://172.18.1.159/pub/yum/centos/$releasever/os/$basearch/
gpgcheck=

4.2测试yum配置

[root@centos7 yum.repos.d]$ yum clean all                          #清空缓存
Loaded plugins: fastestmirror, langpacks
Cleaning repos: network
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors[root@centos7 yum.repos.d]$ yum -y install lftp #测试安装软件

5 如何给特定的rpm包生成仓库

[root@centos6 test]# yum install createrepo -y                   #创建仓库需要createrepo命令,有createrepo这个包提供
#copy一些rpm包到test目录中。
[root@centos6 test]# createrepo . #在rpm文件里面执行,就可以创建一个仓库

剩下的工作就是把这个目录作为baseurl提供出去了。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,494
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295