CentOS7 本地私有YUM源配置简录

版权声明:本文为原创文章,转载请标明出处。 https://blog.csdn.net/zwjzqqb/article/details/83268903
# 依据《CentOS7实验机模板搭建部署》克隆实验主机,进行部署
HOSTNAME=LocalRepository
hostnamectl set-hostname "$HOSTNAME"
echo "$HOSTNAME">/etc/hostname
echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts
echo "$(ip a|grep "inet "|grep -v 127|awk -F'[ /]' '{print $6}') $HOSTNAME">>/etc/hosts

# 安装软件
yum -y install createrepo

# 上传需要共享的rpm包到共享目录
mkdir /YumRepository
cd /YumRepository
# scp USER@IP:/PATH /YumRepository

# 创建yum仓库的repodata目录和repomd.xml文件,repomd.xml是核心的配置文件
# 该文件指明了仓库中拥有的rpm包,当该文件不存在时,目录不能被识别成yum仓库
createrepo -pdo /YumRepository /YumRepository
# 当仓库中的rpm包有更新时,升级该文件
createrepo --update /YumRepository

# 使用nginx做局域网共享
yum -y install epel-release
yum -y install nginx
sed -i 's|/usr/share/nginx/html|/YumRepository|g' /etc/nginx/nginx.conf
systemctl enable nginx
systemctl restart nginx

# 测试
cd /tmp/
wget http://$(hostname -i)/kubectl-1.12.1-2.x86_64.rpm

# 客户端配置,在想要从该yum仓库中下载安装rpm包的机器上配置
echo '192.168.77.90 LocalRepository'>>/etc/hosts
cd /etc/yum.repos.d
cat >LocalRepository.repo<<EOF
[LocalRepository]
name=LocalRepository
baseurl=http://LocalRepository
enable=1
gpgcheck=0
EOF
yum clean all
yum makecache faster
# 安装yumdownloader命令
yum -y install yum-utils
cd /tmp/
yumdownloader kubectl
ls -l kubectl*.rpm

[TOC]

猜你喜欢

转载自blog.csdn.net/zwjzqqb/article/details/83268903