一、搭建yum仓库本地源
创建目录
[root@localhost ~]# mkdir -p /apps/httpd/htdocs/centos/7/os/x86_64/
我的服务器之前已经安装好了httpd,安装方法可以参考我的博文:https://www.cnblogs.com/kesu/p/15202223.html
挂载光盘
[root@localhost]# mount /dev/sr0 /apps/httpd/htdocs/centos/7/os/x86_64/ mount: /dev/sr0 is write-protected, mounting read-only [root@localhost]#
访问地址查看
备份系统自带的repo文件
[root@localhost ~]# mkdir /etc/yum.repos.d/backup && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
配置本地源,并安装软件
[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# less CentOS-Local.repo [base] name=CentOS-Local-Base baseurl=http://192.168.56.128/centos/7/os/x86_64/ gpgcheck=0 [root@localhost yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status base CentOS-Local-Base 447 repolist: 447 [root@localhost yum.repos.d]# yum -y install zip Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package zip.x86_64 0:3.0-11.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================= Installing: zip x86_64 3.0-11.el7 base 260 k Transaction Summary ============================================================================================================================================================================================= Install 1 Package Total download size: 260 k Installed size: 796 k Downloading packages: zip-3.0-11.el7.x86_64.rpm | 260 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zip-3.0-11.el7.x86_64 1/1 Verifying : zip-3.0-11.el7.x86_64 1/1 Installed: zip.x86_64 0:3.0-11.el7 Complete! [root@localhost yum.repos.d]#
二、搭建yum仓库网络源
修改系统自带repo文件,改为用清华大学源
[root@localhost ~]# sed -e ‘s|^mirrorlist=|#mirrorlist=|g‘ -e ‘s|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g‘ -i.bak /etc/yum.repos.d/CentOS-*.repo
清除软件包缓存
[root@localhost ~]# yum clean all
更新软件包缓存
[root@localhost ~]# yum makecache all
查看Base repo文件的配置
[root@localhost ~]# less /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
安装软件包tree
[root@localhost ~]# yum -y install tree Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package tree.x86_64 0:1.6.0-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================= Installing: tree x86_64 1.6.0-10.el7 base 46 k Transaction Summary ============================================================================================================================================================================================= Install 1 Package Total download size: 46 k Installed size: 87 k Downloading packages: tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : tree-1.6.0-10.el7.x86_64 1/1 Verifying : tree-1.6.0-10.el7.x86_64 1/1 Installed: tree.x86_64 0:1.6.0-10.el7 Complete! [root@localhost ~]#