闲来生活闲来生活  2023-02-28 21:07 闲闲来来转转 隐藏边栏  261 

yum主要是用于安装以及升级rpm软件包的,它能自动查找并解决rpm包之间的依赖关系。对于可以连接公网的机器我们可以配置公网yum源(阿里yum,网易yum源等),但对于私有环境,不能连接公网的情况下,需要安装软件就需要本地yum源。或者是我们学习过程中安装一个本地yum源,可以让我们学习集群的时候软件安装版本统一,并且安装速度非常快,不用受网络影响。

1 配置http的yum源—yum服务端

1.1 创建目录

建一个本地仓库路径(如/etc/yum.repos.d/local_rpm)

mkdir /etc/yum.repos.d/local_rpm

1.2 安装createrepo软件:

yum -y install createrepo           

1.3 创建仓库

createrepo /etc/yum.repos.d/local_rpm/

1.4 上传yum安装包到目录

这里可以使用当前的yum 配置下载以下rpm 包 但是不安装。或者是直接准备好rpm包。

yum install --downloadonly --downloaddir=/etc/yum.repos.d/local_rpm vsftpd

后面添加rpm包可以更新

createrepo --update /etc/yum.repos.d/local_rpm

1.5 安装nginx

yum install nginx -y

1.6 修改nginx配置

vim /etc/nginx/conf.d/yum.conf
[root@yum88 ~]#cat /etc/nginx/conf.d/yum.conf 
server{
  listen 19988;
  server_name _;
  charset utf-8,gbk;
  location / {
  root /etc/yum.repos.d/local_rpm/;
  autoindex on;
  autoindex_localtime on;
  autoindex_exact_size off;
  
  }
}

1.7 启动nginx

systemctl start nginx

1.8   到此就是已经完成用nginx搭建在线下载yum源

使用nginx搭建本地yum源

2  客户端配置

2.1 配置yum config

cat > /etc/yum.repos.d/88.repo << 'EOF'
[88-rpm]
name=88 yum repo
baseurl=http://10.0.0.88:19988
enabled=1
gpgcheck=0
EOF

2.2 清除yum机制的本地缓存

yum clean all

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

闲来生活
闲来生活 关注:1    粉丝:3 最后编辑于:2023-03-11
分享经验
×

予人玫瑰,手有余香

打赏 闲来生活

打开支付宝扫一扫,即可进行扫码打赏哦