yum配置的几种办法
Linux配置yum源
本地yum源光盘配置
装载光盘
将yum.repos.d下的所有文件打包成压缩包
光盘挂载:[root@1 ~]# rm -rf /mnt/*
[root@1 ~]# mount -o ro /dev/sr0 /mnt/
选项 -o 表示挂载⽅式 ro=readonly rw=read and write
[root@1 ~]# umount /mnt
永久挂载:[root@1 ~]# chmod +x /etc/rc.local
[root@1 ~]# echo 'mount -o ro /dev/sr0 /mnt' >> /etc/rc.local
编写本地仓库文件:[root@1 ~]# vim /etc/yum.repos.d/zz.repo
清理缓存:[root@1 ~]# yum clear all
创建缓存:[root@1 ~]# yum makecache
查看源仓库列表:[root@1 ~]# yum repolist
安装腾讯源
装载腾讯镜像
下载文件 :rm -rf /etc/yum.repos.d/CentOS-Base.repo
更新缓存: yum clean all
加载新的缓存: yum makecache
epel源配置
下载epel: yum -y install epel-release
查看: yum repolist all
安装小火车: yum -y install sl
特定软件源配置nginx
清除elep源:[root@c ~]# rem -rf /etc/yum.repos.d/epel*
清除缓存: yum clear all
加载新的缓存: yum makecache
搜document
搜install
下载
进入repo文件:vim /etc/yum.repos.d/nginx.repo
redhat安装:sudo yum install yum-utils
进入repo文件修改配置:vim /etc/yum.repos.d/nginx.repo
安装稳定版本:vim /etc/yum.repos.d/nginx.repo
创建缓存:yum clean all
yum makecache
安装: yum install nginx -y
启动nginx:nginx
缓存文件到本地
安装软件包:vim /etc/yum.conf
[main] cachedir=/var/cache/yum/$basearch/$releaserver # 定义软件包缓存路径
keepcache=1 #开启缓存
debuglevel=2
logfile=/var/log/yum.log
修改配置文件:vim /etc/yum.cong
keepcache=1
测试:yum -y. install tree
清除缓存: ./var/cache/yum/x66_32/7/base/packages/treeexxxxxx.rpm
安装nginx: yum install nginx -y
查找安装包: find /var/cache/ -name "*tree*" -type f
/var/cache/yum/x86_64/7/os/packages/tree-1.6.0-10.el7.x86_64.rpm
[root@localhost ~]# find /var/cache/ -name "*nginx*" -type f
/var/cache/yum/x86_64/7/nginx-stable/packages/nginx-1.26.1- 2.el7.ngx.x86_64.rpm
只下载不安装: yum install --downloadonly --downloaddir=./soft samba
安装createrepo制作仓库的软件
下载createrepo: yum -y install createrepo
下载samba安装包: yum install --downloadonly --downloaddir=./soft samba
把soft⽂件夹做成⼀个本地的⾃建仓库:createrepo soft/
进入soft目录查看: cd soft/
ls
在/etc/yum.repos.d/下创建 soft.repo
修改配置文件: vim /etc/yum.repos.d/soft.repo
[soft]
name=soft_local
gpgcheck=0
baseurl=file:///root/soft
enable=1
创建缓存: yum clean all
yum makecac
再次安装samba: yum -y install samba
练习
1.读取优盘数据
![](https://i-blog.csdnimg.cn/direct/ccbe2dd284d04293869e35cab62e2840.png)
![](https://i-blog.csdnimg.cn/direct/453ce54a3040487691e5735b02fbdb7e.png)
![](https://i-blog.csdnimg.cn/direct/bb1e5a55cddd412da763117463ecdab0.png)
[root@b ~]# mkdir /usb/
[root@b ~]# mount -o ro /dev/sdb1 /usb/
[root@b ~]# cd /us
usb/ usr/
[root@b ~]# cd /usb/
[root@b usb]# ls
![](https://i-blog.csdnimg.cn/direct/f54155c630c54eb28e0140a186c45c4b.png)
2.在vmware配置光盘iso⽂件,在linux系统中读取光盘⽂件
![](https://i-blog.csdnimg.cn/direct/41e85b2075724bea855e36c3a3e5038f.png)
[root@b ~]# mount -o ro /dev/sr0 /mnt/
3.配置阿⾥云yum仓库
[root@b ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@b ~]# yum clean all
[root@b ~]# yum makecache
[root@b ~]# ls /etc/yum.repos.d/
CentOS-Base.repo
[root@b ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d
/CentOS-Base.repo.aly
4.配置清华镜像仓库
[root@b ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/centos/7/readme
[root@b ~]# yum clean all
[root@b ~]# yum makecache
5.配置腾讯镜像仓库
[root@b ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
[root@b ~]# yum clean all
[root@b ~]# yum makecache
[root@b ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.tecent
6.⾃建仓库 包含 tree net-tools bash-completion nginx tree等包
[root@b ~]# cp /etc/yum.repos.d/CentOS-Base.repo.tecent /etc/yum.repos.d/CentOS-Base.repo
[root@b ~]# yum -y install epel-release
[root@b ~]# yum install --downloadonly --downloaddir=./soft/nginx nginx.x86_64
[root@b ~]# yum install --downloadonly --downloaddir=./soft/tree tree.x86_64
[root@b ~]# yum install --downloadonly --downloaddir=./soft/net-tools net-tools.x86_64
[root@b ~]# yum install --downloadonly --downloaddir=./soft/bash-completion bash-completion.noarch
[root@b ~]# yum -y install createrepo
[root@b ~]# createrepo soft/
[root@b ~]# vim /etc/yum.repos.d/soft.repo
![](https://i-blog.csdnimg.cn/direct/607619d5150449399ed58bf7405953b9.png)
[root@b ~]# rm -rf /etc/yum.repos.d/CentOS-Base.repo
[root@b ~]# yum clean all
[root@b ~]# yum makecache
[root@b ~]# ls /etc/yum.repos.d/
soft.repo
[root@b ~]# yum -y install nginx //测试