赞
踩
- 1、挂载dvd镜像或将镜像拷贝到机器中
- mkdir /yum-repo
- mount /dev/cdrom /yum-repo # 如果我们在设置中挂载了镜像使用这个方法
- mount 镜像的路径 /yum-repo # 如果我们拷贝镜像到了系统中,可以用这种方法
-
- 2、准备本地yum源文件
- vim /etc/yum.repos.d/xa2401.repo # 源文件必须以.repo结尾
- # 源标识
- [xa2401]
- # 源名字
- name=xa2401-base
- # 源地址,本地用file://
- baseurl=file:///yum-repo
- # 是否检查
- gpgcheck=0
- # 是否开启
- enabled=1

- 1、你可以在网上下载包,或在其他机器上缓存包并拷贝到一个目录中。可以看到我的这个目录下全都是rpm包
- [root@localhost ~]# ls /package/ | head -2
- adcli-0.8.1-16.el7_9.1.x86_64.rpm
- at-3.1.13-25.el7_9.x86_64.rpm
-
- 2、安装制作yum源的工具
- yum install -y createrepo
-
- 3、制作源
- createrepo /package
-
- 4、创建源文件
- # 源标识
- [xa2401]
- # 源名字
- name=xa2401-base
- # 源地址,本地用file://
- baseurl=file:///package
- # 是否检查
- gpgcheck=0
- # 是否开启
- enabled=1

- 1、关闭防火墙和selinux
- systemctl stop firewalld
- setenforce 0
-
- 2、安装vsftpd
- yum install -y vsftpd
-
- 3、创建目录并拷贝包,然后授权
- mkdir /var/ftp/xa2401-ftp
- ls /yum-repo/Packages/* | head -100 | xargs -i cp {} /var/ftp/xa2401-ftp/ # 拷贝一些包过来
- createrepo /var/ftp/xa2401-ftp/ # 创建为yum源
- chown ftp.ftp -R /var/ftp/xa2401-ftp
-
- 4、启动并访问测试
- systemctl start vsftpd
- 打开此电脑,地址栏访问 ftp://ip地址,如果可以看到,表示配置正确
-
-
- 5、客户端配置源文件
- vim /etc/yum.repos.d/xa2401-ftp.repo # 源文件必须以.repo结尾
- # 源标识
- [xa2401-ftp]
- # 源名字
- name=xa2401-ftp
- # 源地址,远程用ftp://
- baseurl=ftp://192.168.75.248
- # 是否检查
- gpgcheck=0
- # 是否开启
- enabled=1

- [root@localhost ~]# yum install -y yum-utils
- [root@localhost ~]# yum repolist
- 已加载插件:fastestmirror
- Loading mirror speeds from cached hostfile
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.aliyun.com
- 源标识 源名称 状态
- base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
- epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,785
- extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 519
- updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 5,766
- xa2401-ftp xa2401-ftp 100
- repolist: 30,242
-
- [root@localhost ~]# reposync -r base -r epel -r extras -r updates

安装:
rpm -ivh 包名 卸载:
rpm -e 包名 # 有一个好处,不卸载其他依赖 查询:
rpm -qa #查询有多少包被安装
rpm -ql 包名 #查询某个包都安装了哪些内容
rpm -qf 文件名 # 查看某个文件是哪个软件包提供的
rpm -qc 包名 #查询这个包都有哪些配置文件
阿里云源 cd /etc/yum.repos.d && rm -rf * && curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
yum yellowdog #yum 仓库目录 /etc/yum.repos.d
/var/cache/yum 缓存存放
yum repolist # 查看都有哪些源和源的信息 yum list # 查看源里面都有哪些包,哪些是以安装的 yum search 关键字 # 在软件包的名字和介绍中找到关键字 yum provides 命令 # 查看命令是在哪个软件包中提供的 yum install 软件包 # 安装软件包,-y可以不提示 yum reinstall 软件包 # 重装软件包 yum erase 软件包 # 卸载 yum remove 软件包 # 卸载 yum clean all # 清空缓存,一般在重新配置了源的时候使用 yum makecache # 重新创建缓存,一般在 yum clean all 之后使用 yum history # 查看操作记录 yum history undo 序号 # 回滚安装操作
vim /etc/yum.conf keepcache=1 # 修改此配置可以不删除安装包
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。