- mirros.repo文件如下:
[base]
name=CentOS-Base
baseurl=http://192.168.18.105/base/Packages/
enabled=1
gpgcheck=0
[epel]
name=CentOS-Epel
baseurl=http://192.168.18.105/epel/Packages/
enabled=1
gpgcheck=0
[extras]
name=CentOS-Extras
baseurl=http://192.168.18.105/extras/Packages/
enabled=1
gpgcheck=0
[updates]
name=CentOS-Updates
baseurl=http://192.168.18.105/updates/Packages/
enabled=1
gpgcheck=0
###############################################################################拓展知识:
##yum仓库服务器搭建过程:
#仓库服务器上面的操作:
#root用户安装依赖
#安装web服务及搭建仓库的命令
yum install httpd yum-utils -y
yum install createrepo -y
#默认centos7没有epel仓库,所以提前安装epel库
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo && \
yum clean all && yum makecache
#从阿里云同步到本地rpm包,默认常用的4中类型仓库。
reposync -r base -p /var/www/html
reposync -r extras -p /var/www/html
reposync -r epel -p /var/www/html
reposync -r updates -p /var/www/html
#把下载好的rpm包,生成一个索引目录,为了更快的查找到它。
createrepo -p /var/www/html/base/Packages
createrepo -p /var/www/html/epel/Packages
createrepo -p /var/www/html/extras/Packages
createrepo -p /var/www/html/updates/Packages
#启动httpd服务,关闭默认防火墙
systemctl stop httpd
systemctl disable httpd
systemctl stop firewalld
systemctl disable firewalld
##########################################################
#客户端服务器
#需要使用此本地仓库的,服务器需要更改repo文件
#一般是机房无法上网的服务器使用此类本地仓库,所以删除其他所有repo文件,使用这一个即可!
cd /etc/yum.repos.d/
tar zcvf repos.tar.gz ./*
rm -f CentOS-*
touch mirros.repo #填写四个仓库的信息
yum clean all && yum makecache
####################################################
####################################################
#自定义安装yum仓库,如k8s的yum源:
#首先下载阿里云的K8SyumY源的rpm包到本地:
for ALrpm in $(curl -s https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/Packages/|grep rpm|awk -F '"' '{print $4}'); do wget https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/Packages/$ALrpm && echo download! ; done
#创建k8s的yum源索引文件
createrepo -p /var/www/html/k8s/Packages
需要使用的节点服务器,配置yum源:
[k8s]
name=CentOS-K8s
baseurl=http://192.168.18.105/k8s/Packages
enabled=1
gpgcheck=0
yum clean all && yum makecache
##############################################################################类似的方法,还可以设置docker的yum源:
略