一、配置yum源
本机cmd中执行
C:\Users\gdx19>d: //切换到d盘下D:\>dir //查看d盘下所有的目录和文件
驱动器 D 中的卷是 windows
卷的序列号是 CEA4-61A1D:\ 的目录 //部分目录 ,1 个文件 ,182 字节,33 个目录 256,526,708,736 可用字节
2024/06/25 20:58 <DIR> BaiduNetdiskDownload
2024/06/24 21:39 <DIR> CISCO
2024/01/22 19:11 <DIR> CloudMusic
2023/11/24 16:42 <DIR> DeliveryOptimization
D:\>scp
usage: scp [-346ABCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file]
[-J destination] [-l limit] [-o ssh_option] [-P port]
[-S program] source ... target
1.了解yum源安装软件包
yum 源安装软件包是在 Linux 系统中一种非常便捷和常用的软件安装方式
yum(Yellowdog Updater, Modified)是一个在众多 Linux 发行版中广泛使用的软件包管理器。它通过预先配置好的软件源来获取软件包的信息和进行安装。
2.yum 源的作用:
yum 源就像是一个软件仓库,包含了各种各样的软件包及其相关的依赖信息。常见的 Yum 源有系统默认提供的官方源,也有第三方维护的源。
3.yum 安装软件包的优点:
1.自动处理依赖关系:当您安装一个软件包时,如果它依赖于其他的软件包,yum 会自动安装这些依赖,无需您手动逐个查找和安装。例如,安装一个图形化界面软件时,它可能依赖于特定的库文件和其他支持组件,yum 会一并处理。
2.方便的软件搜索和浏览:您可以通过简单的命令搜索和查看可用的软件包。
3.软件包的更新管理:可以轻松更新已安装的软件包到最新版本,保持系统的安全性和稳定性。
4.安装过程中的关键步骤:
1.配置 yum 源:有些系统默认已经配置好常用的源,您也可以根据需要添加或修改源的配置。
2.执行安装命令
5.yum仓库
6.分类
本地yum源:yum仓库在本地,系统光盘/镜像文件
网络源: aliyun 163源 sohu源 清华源 redhat源 epel源 centos源
特定软件:nginx MySQL zabbix
7.查看现有的yum仓库镜像备份并删除
[root@alocalhost~]#ls-l /etc/yum.repos.d/
[root@alocalhost~]#yum repolist all #查看本地源
[root@alocalhost~]#yum makecache #创建缓存
[root@alocalhost~]#tar -zcvf /etc/yum.repos.d/bak.tar.gz /etc/yum.repos.d/* #备份仓库
[root@alocalhost~]# ls -l /etc/yum.repos.d/
-rw-r--r-- 1 root root 170 7月 16 09:54 bak.tar.gz
[root@alocalhost~]#rm -rf /etc/yum.repos.d/*.repo #删除
[root@alocalhost~]# yum repolist all
repolist:0 #所有的仓库都删除完了
二、镜像配置及下载
1.在VMware中装载光盘镜像
2.把光盘挂载到指定目录下
(1)删除/mnt目录下所有的文件
(2)lsblk
(3)mount -o ro /dev/sr0 /mnt
选项 -o 表示挂载方式
ro=readonly
rw=read and write
[root@localhost ~]# mount /dev/sr0 /mnt/ -o ro
[root@localhost ~]# ls /mnt
3. 将挂载添加到开机启动文件中
chmod +x /etc/rc.local #添加权限
echo 'mount -o ro /dev/sr0 /mnt' >> /etc/rc.local 向文件中添加一行
[root@localhost~]# echo 'mount -o ro /dev/sr0 /mnt' >> /etc/rc.local
[root@localhost ~]# ls -l /etc/rc.local
4.编写本地 repo文件
[root@localhost~]# vim /etc/yum.repos.d/local.repo #创建一个repo文件
[root@localhost ~]# yum clean all #清除缓存
[root@localhost~]# yum makecache #创建缓存
5.阿里镜像(新机)
[root@oneday ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@oneday ~]# yum makecache #生成缓存[root@oneday ~]# ls /etc/yum.repos.d/
[root@oneday ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
6.腾讯镜像
[root@oneday ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
7.下载epel
[root@oneday ~]# yum -y install epel-release
[root@oneday ~]# yum -y install sl[root@oneday ~]# sl
8.nginx的安装
第一种方式:
[root@oneday ~]# yum -y install nginx.x86_64
[root@oneday ~]# nginx
[root@oneday ~]# curl http://localhost
第二种方式:[root@oneday ~]# vim /etc/yum.repos.d/nginx.repo
[root@oneday ~]# yum clean all
[root@oneday ~]# yum makecache
[root@oneday ~]# yum -y install nginx.x86_64
9.自建缓存
[root@oneday ~]# cp /etc/yum.repos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-B[root@oneday ~]# yum clean all
[root@oneday ~]# vim /etc/yum.conf[root@oneday ~]# yum -y install tree
[root@oneday ~]# yum makecache
10.自建仓库
(1)下载samba的安装包
[root@oneday ~]# yum install --downloadonly --downloaddir=./soft/ samba #只下载不安装
(2)安装createrepo制作创库的软件
[root@oneday ~]# yum -y install createrepo
[root@oneday ~]# createrepo soft/ #使用createrepo指令
[root@oneday ~]# ls soft/ #出现repodata文件
(3)在/etc/yum.repos.d/soft.repo
[root@oneday ~]# vim /etc/yum.repos.d/soft.repo
[root@oneday ~]# yum clean all
[root@oneday ~]# yum makecache[root@oneday ~]# yum -y install samba