下面分别对三个场景进行傻瓜式配置 :joy:html
将光盘插入,经过mount挂在光驱至/mnt/cdrom目录下linux
mkdir /mnt/cdrom
nginx
mount /dev/cdrom /mnt/cdrom
docker
echo "/dev/cdrom /mnt/cdrom iso9660 defaults 0 0" >> /etc/fstab
shell
测试是否生效vim
umount /dev/cdrom
centos
mount -a
<!--加载/etc/fstab配置的挂载项-->缓存
df -h
查看/dev/sr0已经被挂载,OKbash
vim Centos7.repo
服务器
[Centos7] #yum惟一标识 name=Centos7_iso #yum名称,任意 baseurl=file:///mnt/cdrom #yum镜像路径地址(还有ftp:// 和 http://) enable=1 #1启用,0禁用 gpgcheck=0 #1校验,0不校验
yum clean all && yum makecache
yum list | grep nginx
显示正常即OK
mv /etc/yum.repos.d/Centos-Base.repo /etc/yum.repos.d/Centos-Base.repo.bak20200709
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache
yum list | grep nginx
场景:若是须要安装的包在Base yum源没有,就须要安装外部扩展yum源,<u>以下以ansible安装为例</u>
yum install ansible -y
经过查看ansible 须要安装EPEL源
yum list | grep ansible
cat /etc/redhat-release
wget https://mirrors.aliyun.com/centos/7.8.2003/extras/x86_64/Packages/epel-release-7-11.noarch.rpm
rpm -ivh epel-release-7-11.noarch.rpm
yum clean all && yum makecache
yum install ansible -y
正常显示OK
场景:iso镜像只能本机使用,若是须要内网中其余服务器使用,就须要构建http yum源仓库,也是企业中经常使用的配置方式。(ftp 也是能够的)
yum install httpd httpd-devel -y
systemctl restart httpd.service
setenforce 0 #临时关闭SELinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config #永久关闭SELinux(重启生效) systemctl stop firewalld.service #临时关闭防火墙 systemctl disable firewalld.service #永久关闭防火墙
mkdir -p /var/www/html/yum/centos7.8
cp -R /mnt/cdrom/Packages/* /var/www/html/yum/centos7.8
yum install createrepo* -y
createrepo /var/www/html/yum/centos7.8/
建立完成会有repodata文件夹生产
vim /etc/yum.repos.d/Centos7.8-http.repo
[centos7.8] name=centos7.8-http baseurl=http://192.168.197.128/yum/centos7.8 enable=1 gpgcheck=0
yum clean all && yum makecache
yum list | grep nginx
客户端能正常获取yum服务器文件,OK
企业研发发布新rpm,如何更新yum服务器,让其余客户端正常获取,如下以docker安装为例
/var/www/html/yum/centos7.8
wget https://mirrors.aliyun.com/opensuse/history/20200218/tumbleweed/repo/oss/x86_64/docker-19.03.5_ce-4.1.x86_64.rpm
cp docker-19.03.5_ce-4.1.x86_64.rpm /var/www/html/yum/centos7.8/
createrepo --update /var/www/html/yum/centos7.8/
yum clean all
yum list | grep docker
yum install # 安装 yum remove #卸载 yum update #更新 yum clean all #清除缓存 yum makecache #加载缓存 yum info #查看信息 yum list #查看包列表