首页 > 系统相关 >本地和网络yum源的配置,以及自建yum仓库

本地和网络yum源的配置,以及自建yum仓库

时间:2024-07-16 16:54:46浏览次数:12  
标签:自建 仓库 repo nginx yum tdr root localhost

本地和网络yum源的配置
rpm -ivh xxx
手动添加依赖,yum不执行安装,自动处理依赖管理
yum优点
rpm安装(下载软件,单独安装,需要解决依赖关系)
源码安装configure make make install
yum基于rpm,相当于rpm升级版,自动解决依赖关系


1.使用光盘作为yum源仓库


1)在vmware中装载centos7光盘镜像


将原有的yum备份或改名
[root@tdr ~]# cd /etc/yum.repos.d/
[root@tdr yum.repos.d]# ls
haha.repo
[root@tdr yum.repos.d]# mv haha.repo haha.repo.q
[root@tdr yum.repos.d]# ls
haha.repo.q
[root@tdr yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
repolist: 0     //yum已全部被清除
2)把光盘挂载到指定⽬录下
[root@tdr ~]# rm -rf /mnt/*
[root@tdr ~]# mount -o ro /dev/sr0 /mnt                     //-o表示挂载方式,ro表示readonly
将光盘数据挂载到/mnt目录中,就可以在该目录中读取光盘的数据
[root@tdr ~]# df -h
3)将挂载添加到开机启动⽂件中
[root@tdr ~]# vim /etc/rc.local                  //开机自动执行挂载
mount -o ro /dev/sr0 /mnt 
或[root@tdr ~]# vim /etc/fstab                       //也是开机自动挂载
/dev/cdrom  /mnt    iso9660     defaults 0 0
4)编写本地repo⽂件
[root@tdr ~]# vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enable=1 
5)清理缓存,查看源列表
[root@tdr ~]# yum clean all               //清除缓存
[root@tdr ~]# yum makecache        //生成缓存
6)测试yum
[root@tdr ~]# yum -y remove httpd
[root@tdr ~]# yum -y install httpd


2.配置网络源


1)阿里云


[root@tdr ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@tdr ~]# yum clean all
[root@tdr ~]# yum makecache 
[root@tdr ~]# yum list | grep python3

2)腾讯云


[root@localhost yum.repos.d]# rm -rf /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# 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

3)epel源配置


对官⽅和官⽹源的扩展,有些软件找不到
[root@localhost ~]# yum -y install epel-release
安装⼩⽕⻋
[root@localhost ~]# yum -y install sl
移除epel源,如果不⾏就全清空
[root@localhost ~]# rm -rf /etc/yum.repos.d/epel.repo 
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache 

4)安装特定软件源配置nginx


https://nginx.org/

找到repo文件内容

安装稳定版本
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache 
[root@localhost ~]# yum -y install nginx 
[root@localhost ~]# nginx                  //启动服务
[root@localhost ~]# whereis nginx           //查看指令
浏览器访问本机IP
 [root@localhost ~]# nginx -s stop            //停⽤nginx


5)自建yum源仓库


[root@localhost ~]# vim /etc/yum.conf 
[main]
cachedir=/var/cache/yum/$basearch/$releasever                     //定义软件包缓存路径
keepcache=1           //修改为1,开启缓存
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?
project_id=23&ref=http://bugs.centos.org/bug_report_page.php?
category=yum
distroverpkg=centos-release

卸载,然后安装nginx 查看缓存⽂件
[root@localhost ~]# yum -y remove nginx.x86_64           //卸载
[root@localhost ~]# yum install nginx -y                   //安装
[root@localhost ~]# find /var/cache/ -name "*nginx*" -type f                     //查找安装包
 /var/cache/yum/x86_64/7/os/packages/tree-1.6.0-10.el7.x86_64.rpm      

只下载不安装
[root@localhost ~]# yum install --downloadonly --downloaddir=./soft samba
[root@localhost ~]# ls soft/                      //安装包的位置

(1)安装createrepo制作仓库的软件


[root@localhost ~]# yum -y install createrepo


(2)把soft⽂件夹做成⼀个本地的⾃建仓库


[root@localhost ~]# createrepo soft/
[root@localhost ~]# cd soft/
[root@localhost soft]# ls


(3)在/etc/yum.repos.d/下创建soft.repo


[root@localhost soft]# rm -rf /etc/yum.repos.d/*.repo            //删除其他仓库⽂件
[root@localhost soft]# vim /etc/yum.repos.d/soft.repo              //配置仓库文件
[soft]
name=soft_local
gpgcheck=0
baseurl=file:///root/soft
enable=1
[root@localhost soft]# yum clean all
[root@localhost soft]# yum makecache 
[root@localhost soft]# yum -y install samba         //再次安装samba,不用再次下载
 

标签:自建,仓库,repo,nginx,yum,tdr,root,localhost
From: https://blog.csdn.net/m0_70848838/article/details/140470450

相关文章

  • 本地代码推送远程仓库(gitee实例)
    https://www.cnblogs.com/shijiehaiyang/p/14147899.htmlhttps://www.cnblogs.com/maojunyi/p/7735723.html1.首先安装Git及Tortoisegit2.安装完成后手动创建.gitignore文件,用来排除不上传文件(如bin,obj等)3.在本地代码文件夹创建本地仓库4.提交master 5.创建远程仓库后,......
  • apollo访问阿里云下载YUM的RPM包及其依赖项
     1.确定需要下载的RPM包对于CentOS7,主要需要下载的包包括yum、yum-utils以及它们的依赖。依赖可能包括python-iniparse等。2.使用wget从阿里云镜像下载阿里云的镜像仓库提供了CentOS的软件包,您可以使用以下命令格式从阿里云镜像下载所需的RPM包:1wgethttp://mirrors.al......
  • 云计算【第一阶段(30)】部署Yum仓库及NFS共享服务
    一、Yum仓库1.1、Yum仓库概念学习YUM软件仓库,可以完成安装、卸载、自动升级rpm软件包等任务,能够自动查找并解决rpm包之间的依赖关系,而无须管理员逐个、手工地去安装每个rpm包,使管理员在维护大量Linux服务器时更加轻松自如。特别是在拥有大量Linux主机的本地网络中......
  • CentOS 7.9 arm64架构配置在线yum源 —— 筑梦之路
    阿里云源cat<CentOS-aliyun.repo<<'EOF'#CentOS-Base.repo##ThemirrorsystemusestheconnectingIPaddressoftheclientandthe#updatestatusofeachmirrortopickmirrorsthatareupdatedtoand#geographicallyclosetothecli......
  • ts vue3 element-plus 自建可配置表单弹窗实现
    当然可以!下面是使用TypeScript语法的动态表单弹出组件示例。1.创建动态表单弹出组件(TypeScript)<template><el-dialog:visible.sync="visible"title="表单"@close="handleClose"><el-form:model="formData":rules="rules"......
  • 如何pr到别人仓库(无废话)
    如何PR到别人仓库(指定分支)记录一下,之前都是直接master分支,现在记录如何pr到别人仓库的其他分支首先进入别人仓库然后点击fork到自己仓库步骤(以博主自己一个例子为例)(1)拉取你fork到你仓库gitclonehttps://github.com/dragonforward/MaixCDK.git(2)添加原始仓库(也就是你fork......
  • 建设yum源仓库
     1、服务器端:挂载镜像mkdir/root/isomount/dev/cdrom/root/iso创建一个本地目录存储RPM包:sudomkdir-p/var/www/html/repo复制镜像到创建的目录cp/root/iso/Packages/*/var/www/html/repo/安装yum及相关软件包sudoyuminstallcreaterepoyum-utils创建YUM仓......
  • P2120 [ZJOI2007] 仓库建设
    题目大意\(n\)个工厂,每个工厂有\(p_i\)的货物,货物运输一个单位距离的费用是\(1\),工厂可以建造仓库,费用为\(c_i\)。工厂与工厂\(1\)的距离为\(x_i\)。要求将货物运送到下一个最近的仓库,求最小费用。\(1\leqn\leq10^6\)思路先考虑最基本的动规:设\(f_i\)表示在这里......
  • centos7 镜像仓库都失效了,怎么办?
    1、centos7镜像仓库都失效了,怎么办?背景:我刚才使用yum命令安装软件是,失败了。错误信息如下: 很明显,就是http://mirrorlist.centos.org无法访问到,出现了404。原因:CentOSLinux7的生命周期(EOL)于2024年6月30日终止。了解红帽帮助您轻松迁移的选项,包括支持第三方Linux......
  • git切换远程仓库地址
    git更换远程仓库地址三种方法总结一、前言由于之前项目管理使用私服的gitlab,现在换成了Gitea,需要修改远端仓库地址。二、环境windows10gitversion2.34.0.windows.1三、帮助文档GitHub文档四、三种修改方法方法一:不删除远程仓库修改(最方便)#查看远端地址git......