CentOS7利用yum缓存搭建本地源

环境说明

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@localhost ~]# hostnamectl --static set-hostname yum-cache
[root@yum-cache ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@yum-cache ~]# sestatus
SELinux status: disabled
[root@yum-cache ~]# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination Chain FORWARD (policy ACCEPT)
target prot opt source destination Chain OUTPUT (policy ACCEPT)
target prot opt source destination

配置yum缓存

[root@yum-cache ~]# egrep -v "^$|#" /etc/yum.conf
[main]
cachedir=/var/cache/yum # 设置rpm包缓存的路径
keepcache=1 # 默认为0,改为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
[root@yum-cache ~]#  yum -y install mysql-community-server mysql   # 这边用mysql做实验,下过mysql的都知道,没有rpm包,下载真的慢
[root@yum-cache ~]# pwd
/root
[root@yum-cache ~]# mkdir mysql-5.7.31
[root@yum-cache ~]# ls
anaconda-ks.cfg mysql-5.7.31
[root@yum-cache ~]# find /var/cache/yum/ -name "*.rpm" -exec cp {} /root/mysql-5.7.31/ \;
[root@yum-cache ~]# ls /root/mysql-5.7.31/
mysql-community-client-5.7.31-1.el7.x86_64.rpm mysql-community-server-5.7.31-1.el7.x86_64.rpm
mysql-community-common-5.7.31-1.el7.x86_64.rpm net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
mysql-community-libs-5.7.31-1.el7.x86_64.rpm postfix-2.10.1-9.el7.x86_64.rpm
mysql-community-libs-compat-5.7.31-1.el7.x86_64.rpm
[root@yum-cache ~]# yum -y install createrepo
[root@yum-cache ~]# createrepo -v mysql-5.7.31/
Spawning worker 0 with 7 pkgs
Worker 0: reading mysql-community-client-5.7.31-1.el7.x86_64.rpm
Worker 0: reading mysql-community-common-5.7.31-1.el7.x86_64.rpm
Worker 0: reading mysql-community-libs-5.7.31-1.el7.x86_64.rpm
Worker 0: reading mysql-community-libs-compat-5.7.31-1.el7.x86_64.rpm
Worker 0: reading mysql-community-server-5.7.31-1.el7.x86_64.rpm
Worker 0: reading net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
Worker 0: reading postfix-2.10.1-9.el7.x86_64.rpm
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Starting other db creation: Mon Jul 20 22:17:18 2020
Ending other db creation: Mon Jul 20 22:17:18 2020
Starting filelists db creation: Mon Jul 20 22:17:18 2020
Ending filelists db creation: Mon Jul 20 22:17:18 2020
Starting primary db creation: Mon Jul 20 22:17:18 2020
Ending primary db creation: Mon Jul 20 22:17:18 2020
Sqlite DBs complete
[root@yum-cache ~]# cd mysql-5.7.31/ # createrepo后,会产生repodata目录
[root@yum-cache mysql-5.7.31]# ls
mysql-community-client-5.7.31-1.el7.x86_64.rpm mysql-community-server-5.7.31-1.el7.x86_64.rpm
mysql-community-common-5.7.31-1.el7.x86_64.rpm net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
mysql-community-libs-5.7.31-1.el7.x86_64.rpm postfix-2.10.1-9.el7.x86_64.rpm
mysql-community-libs-compat-5.7.31-1.el7.x86_64.rpm repodata
[root@yum-cache mysql-5.7.31]# vim mysql-5.7.31.repo
[root@yum-cache mysql-5.7.31]# cat mysql-5.7.31.repo
[mysql]
name="mysql-5.7.31-local"
baseurl=file:///root/mysql-5.7.31/
enable=1
gpgcheck=0
[root@yum-cache ~]# tar czvf mysql-5.7.31.tar.gz mysql-5.7.31/ # 将rpm包和repo文件打包,放到其他机器上测试
[root@yum-cache ~]# ls
anaconda-ks.cfg mysql-5.7.31 mysql-5.7.31.tar.gz

测试

[root@localhost ~]# ls    # 将tar包上传到服务器上
anaconda-ks.cfg mysql-5.7.31.tar.gz
[root@localhost ~]# tar xf mysql-5.7.31.tar.gz
[root@localhost ~]# cd mysql-5.7.31/
[root@localhost mysql-5.7.31]# ls
mysql-5.7.31.repo mysql-community-server-5.7.31-1.el7.x86_64.rpm
mysql-community-client-5.7.31-1.el7.x86_64.rpm net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
mysql-community-common-5.7.31-1.el7.x86_64.rpm postfix-2.10.1-9.el7.x86_64.rpm
mysql-community-libs-5.7.31-1.el7.x86_64.rpm repodata
mysql-community-libs-compat-5.7.31-1.el7.x86_64.rpm
[root@localhost mysql-5.7.31]# cp mysql-5.7.31.repo /etc/yum.repos.d/ # 把写好的repo文件复制到yum.repos.d目录下
[root@localhost mysql-5.7.31]# yum clean all # 清除缓存
Loaded plugins: fastestmirror
Cleaning repos: base extras mysql updates
Cleaning up list of fastest mirrors
[root@localhost mysql-5.7.31]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mysql | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/13): base/7/x86_64/group_gz | 153 kB 00:00:01
(2/13): extras/7/x86_64/filelists_db | 217 kB 00:00:02
(3/13): extras/7/x86_64/other_db | 125 kB 00:00:00
(4/13): base/7/x86_64/other_db | 2.6 MB 00:00:03
(5/13): mysql/filelists_db | 6.5 kB 00:00:00
(6/13): mysql/other_db | 4.1 kB 00:00:00
(7/13): mysql/primary_db | 10 kB 00:00:00
(8/13): updates/7/x86_64/filelists_db | 1.7 MB 00:00:00
(9/13): updates/7/x86_64/other_db | 250 kB 00:00:00
(10/13): extras/7/x86_64/primary_db | 205 kB 00:00:02
(11/13): updates/7/x86_64/primary_db | 3.0 MB 00:00:01
(12/13): base/7/x86_64/filelists_db | 7.1 MB 00:00:10
(13/13): base/7/x86_64/primary_db | 6.1 MB 00:00:12
Metadata Cache Created
[root@localhost ~]# yum -y install mysql-community-server mysql # 然后你就会发现,直接开始installing了

CentOS7利用yum缓存搭建本地源的更多相关文章

  1. CentOS7基于http方式搭建本地yum源

    1.创建yum软件保存目录[root@localhost ~]# mkdir -p /www/share/yum 2. 修改yum配置文件先备份yum配置文件,修改yum配置文件中yum软件包保存目录 ...

  2. suse 12 利用缓存创建本地源供内网服务使用

    文章目录 服务端获取 添加源 刷新源 清除缓存 安装软件 获取rpm包 客户端测试 zypper --help 前言: 其实,咱也不知道为啥写了这篇博客,咱就是想学一学suse,咱也不会,咱也只能学, ...

  3. CentOS6.5使用createrepo搭建本地源

    本地搭建本地yum源采用的rpm全部来自CentOS-6.5-bin-DVD1&DVD2; 我的是在虚拟机环境安装,先检查我的操作系统版本: 1 2 3 4 [adam@ultraera ~] ...

  4. 在VMware CentOS7挂载系统光盘搭建本地仓库

    1.软件准备: 安装VMware环境,在这里我使用的是VMware15 一个虚拟机系统,在这里我使用的是CentOS7(版本不同可能会有一点出入,但是应该相差不大) 在这里还有一个前提是已经建立好了y ...

  5. CentOS7清理yum缓存和释放内存方法

    清理yum缓存 清理yum缓存使用yum clean 命令,yum clean 的参数有headers, packages, metadata, dbcache, plugins, expire-ca ...

  6. CentOS7使用yum详细搭建zabbix3.2过程

    本文引用于:http://blog.csdn.net/s3275492383/article/details/62417210 一.准备搭建环境: 1.系统:CentOS7 2.默认有使用linux服 ...

  7. redhat利用yum快速搭建LAMP环境

    LAMP LAMP环境,对于PHP开发及其开源的PHP项目的部署都很关键的. LAMP的含义: L   ---Linux A  ---Apache   web M ---Mysql     datab ...

  8. CentOS7用yum快速搭建LAMP平台

    实验环境: [root@nmserver-7 html]# cat /etc/redhat-release CentOS release 7.3.1611 (AltArch) [root@nmserv ...

  9. 利用nodeJs anywhere搭建本地服务器环境【转载】

    首先去nodeJs官网下载最新版nodeJs     https://nodejs.org/en/ 安装成功后win+r打开cmd 输入node -help 或者node -v查看是否安装成功 装好后 ...

随机推荐

  1. nuxt 相关

    https://github.com/xuqiang521/nuxt-ssr-demo https://www.cnblogs.com/laozhang-is-phi/p/10249248.html ...

  2. 灵雀云开源网络插件Kube-OVN 1.4.0 版发布!支持跨集群容器网络、NetworkPolicy 日志

    从 1.4 开始 Kube-OVN 支持将多个 Kubernetes 集群容器网络打通,不同集群之间的 Pod 可以通过 Pod IP 直接互相通信.本版本还支持 ACL 日志,可以记录因 Netwo ...

  3. 如何查看mysql的用户权限

    查询语句:select * from mysql.user where user='root'\G;user是用户名 <privileges>是一个用逗号分隔的你想要赋予的MySQL用户权 ...

  4. linux 下安装PostgreSql 并配置远程访问

    1.官网下载PostgreSql 安装包 (https://www.enterprisedb.com/downloads/postgres-postgresql-downloads) 我下载的是 9. ...

  5. 【Android】安卓中的存储

    [Android]安卓中的存储 1.存储在App内部 最简单的一种.在尝试过程中发现,手机中很多文件夹都没有权限读写.我们可以将我们需要写的文件存放到App中的files文件夹中,当然我们有权限在整个 ...

  6. 简述ASP.NET网站开发步骤

    新建解决方案 清除解决方案 重新生成解决方案 发布应用程序 设置配置文件 重命名配置文件 发布后生成的文件 IIS安装 安装完成后,输入http://localhost/出现 打开IIS 添加自己的网 ...

  7. Cesium入门8 - Configuring the Scene - 配置视窗

    Cesium入门8 - Configuring the Scene - 配置视窗 Cesium中文网:http://cesiumcn.org/ | 国内快速访问:http://cesium.coini ...

  8. DEEP LEARNING WITH PYTORCH: A 60 MINUTE BLITZ | NEURAL NETWORKS

    神经网络可以使用 torch.nn包构建. 现在你已经对autograd有所了解,nn依赖 autograd 定义模型并对其求微分.nn.Module 包括层,和一个返回 output 的方法 - f ...

  9. golang中如何退出goroutine

    package main import ( "fmt" "runtime" "time" ) func main() { // 用gorou ...

  10. Python实现查询12306火车票信息

    例子来源于马哥的公众号,看了几遍,有些地方存在些疑问,然后就自己查找些资料,重写的一下,但是对于获取到的信息,并不能有效的解析出来,而且对于中文字符处理,并不是很好,请大神指教下!谢过! 1.接口设置 ...