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源
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
本文为原创文章,版权归闲闲来来转转所有,欢迎分享本文,转载请保留出处!