CentOS7常用yum仓库操作及安装

        日常使用到的YUM仓库作整理,包括:YUM仓库常用命令、搭建本地YUM仓库、常见YUM仓库(CentOS-Base、EPEL、nux-dextop、elrepo、MySQL、GoogleChrome、OracleVirtualBox、Zabbix、Grafana等)

目录

1、YUM仓库操作

1.1、YUM仓库常用命令

1.2、搭建本地YUM仓库

2、常见YUM仓库及安装

2.1、CentOS-Base

2.2、EPEL

2.3、nux-dextop

2.4、ELRepo

2.5、MySQL

2.6、Google-Chrome

2.7、Oracle-VirtualBox

2.8、Zabbix

2.9、Grafana


操作系统:CentOS-7.9-2009-x86_64

1、YUM仓库操作

1.1、YUM仓库常用命令

YUM仓库常用命令,请根据实际需求组合使用。

# 清理yum仓库下载的rpm包缓存(路径:/var/cache/yum/x86_64/7/*/package/*.rpm)
yum clean all
# 重新加载yum仓库的metadata数据,并生成文件目录缓存
yum makecache


# 查看仓库信息列表
yum repolist
# 查看本地指定仓库信息
yum repoinfo YUM仓库名.repo


# 显示指定软件信息
yum info 软件包名
# 查询rpm文件是由什么软件包提供(即被依赖)
yum whatprovides 软件包名

# 查询软件包列表
yum list
# 查询系统中已安装的软件包
yum list installed
# 查询仓库中尚未安装的软件包
yum list available
# 查询可以升级版本的软件包
yum list updates


# 查询安装历史
yum history list
# 查看指定ID(如:18)做了什么
yum history info 18 
# 回滚指定ID(如:18)的操作
yum history undo 18


# 安装指定的软件
yum install 软件包名
# 重新安装指定的软件
yum reinstall 软件包名
# 卸载指定的软件
yum remove 软件包名


# 查看已安装的软件包组
yum grouplist
# 查看指定的软件包组
yum groupinfo 软件包名
# 安装指定的软件包组
yum groupinstall 软件包名
# 移除指定的软件包组
yum groupremove 软件包名


# 卸载指定的软件及依赖
yum autoremove 软件包名


# 更新指定的软件
yum update 软件包名
yum update 软件包名 check-update

1.2、搭建本地YUM仓库

使用场景:一个服务器集群,只有一台服务器能连接外网。连接外网那台服务器把外网源的包全部同步到本地,集群中其他服务器以该服务器为YUM仓库源。同步完包后,使用 createrepo 来生成本地的repodata数据。

# 同步整个源到指定目录(注意:系统自动创建相关目录,并下载,时间较长请耐心等待)
reposync -p /YUM仓库目录

# 同步指定仓库源到指定目录
reposync  --repoid=仓库ID -p /YUM仓库目录

# 只更新指定仓库源中已下载的软件包的最新版本
reposync -n --repoid=仓库ID -p /YUM仓库目录



# (局域网客户机)搭建本地YUM仓库
# 安装 createrepo 创建本地YUM仓库工具
yum install createrepo
createrepo  --version

# 挂载局域网离线仓库到本地
# mount /内网主机IP/YUM仓库目录  /本地YUM仓库目录

# 创建本地(局域网离线)仓库
createrepo --v /本地YUM仓库目录
createrepo --update /本地YUM仓库目录

# 创建本地仓库文件
vi /etc/yum.repos.d/intranet-offline.repo

[local]
name=CentOS-$releasever-$basearch-local
baseurl=file:///mnt/intranet-offline-yum/
gpgcheck=0
enabled=1



# 清除yum缓存
yum clean all
# 重新加载yum仓库的metadata数据,并生成文件目录缓存
yum makecache

reposync命令及参数:

reposync --help

Usage: 
    Reposync is used to synchronize a remote yum repository to a local 
    directory using yum to retrieve the packages.
    
    /usr/bin/reposync [options]
    

Options:
  -h, --help            show this help message and exit
  -c CONFIG, --config=CONFIG
                        config file to use (defaults to /etc/yum.conf)
  -a ARCH, --arch=ARCH  act as if running the specified arch (default: current
                        arch, note: does not override $releasever. x86_64 is a
                        superset for i*86.)
  --source              operate on source packages
  -r REPOID, --repoid=REPOID
                        specify repo ids to query, can be specified multiple
                        times (default is all enabled)
  -e CACHEDIR, --cachedir=CACHEDIR
                        directory in which to store metadata
  -t, --tempcache       Use a temp dir for storing/accessing yum-cache
  -d, --delete          delete local packages no longer present in repository
  -p DESTDIR, --download_path=DESTDIR
                        Path to download packages to: defaults to current dir
  --norepopath          Don't add the reponame to the download path. Can only
                        be used when syncing a single repository (default is
                        to add the reponame)
  -g, --gpgcheck        Remove packages that fail GPG signature checking after
                        downloading
  -u, --urls            Just list urls of what would be downloaded, don't
                        download
  -n, --newest-only     Download only newest packages per-repo
  -q, --quiet           Output as little as possible
  -l, --plugins         enable yum plugin support
  -m, --downloadcomps   also download comps.xml
  --download-metadata   download all the non-default metadata
  --allow-path-traversal
                        Allow packages stored outside their repo directory to
                        be synced (UNSAFE, USE WITH CAUTION!)

2、常见YUM仓库及安装

2.1、CentOS-Base

CentOS官方默认源。

rpm -Uvh http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-7.1908.0.el7.centos.x86_64.rpm -- force

The CentOS Projecthttps://www.centos.org/centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站阿里巴巴开源镜像站为您提供免费的centos下载地址及centos安装教程,centos镜像简介:CentOS,是基于Red Hat Linux提供的可自由使用源代码的企业级Linux发行版本,是RHEL(Red Hat Enterprise Linux)源代码再编译的产物,是一个免费的企业级计算平台;CentOS 定期发行及更新版本,以便支持新的硬件,从而建立一个安全、低维护、稳定、高预测性、高重复性的Linux环境。阿里巴巴开源镜像站,持续同步CentOS、CentOC-altarch等最新版镜像文件,为用户提供极致的下载体验。阿里巴巴开源镜像站icon-default.png?t=M666https://developer.aliyun.com/mirror/centos

2.2、EPEL

EPEL是Extra Packages for Enterprise Linux的缩写,其为EL6或EL7提供重建的Fedora组件,并且不会替换base中的包。EPEL算得上是最著名的第三方软件源,几乎各个云服务器厂商提供的CentOS 系统均会自带该源并默认启用。其收录了web中常用的Nginx软件包。

# 安装EPEL仓库
yum install epel-release

# 替换为国内镜像源(如:阿里云)
sed -i 's|^#baseurl=http://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*

注意:如果CentOS-Base安装的阿里云源(https://mirrors.aliyun.com/repo/Centos-7.repo),则需要手工修改 epel.repo 中的 baseUrl;否则请直接安装epel-release。

2.3、nux-dextop

nux-dextop 用于 EL 的面向桌面和多媒体的 RPM 存储库。它包含许多图形程序,例如 Ardour,还有基于文本的应用程序 line Cone。Nux-Dextop库依赖于EPEL库。

# 安装nux-dextop YUM仓库
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

注意:该仓库与 EPEL 共存时,它可能会与 Repoforge/RPMforge 和 ATrpms 以及其他 repos 发生严重冲突。

Index of /download/nux/dextopicon-default.png?t=M666http://li.nux.ro/download/nux/dextop/

My GNU/Linux related projectsicon-default.png?t=M666http://li.nux.ro/

2.4、ELRepo

ELRepo是The Community Enterprise Linux Repository的缩写,旨在提供驱动程序来增强系统的硬件支持(包括:显示、文件系统、硬件监控、网络、音效、网络摄像镜驱动程序)

# 导入仓库指纹文件
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

# 安装 ELRepo YUM仓库
rpm -Uvh https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

ELRepo | HomePageELRepohttp://elrepo.org/tiki/HomePage

2.5、MySQL

MySQL一种OLTP、OLAP开源数据库服务。

# 导入仓库指纹文件
#rpm --import http://repo.mysql.com/RPM-GPG-KEY-mysql
rpm --import http://repo.mysql.com/RPM-GPG-KEY-mysql-2022

# 安装 MySQL5.7社区版 YUM仓库
# http://repo.mysql.com/mysql57-community-release-el7.rpm
rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm

# 安装 MySQL8.x社区版 YUM仓库
# Install mysql80-community-release-el7 repository
# http://repo.mysql.com/mysql80-community-release-el8.rpm
rpm -Uvh http://repo.mysql.com/mysql80-community-release-el7-6.noarch.rpm

# 安装 MySQL集群社区版 YUM仓库
# http://repo.mysql.com/mysql-cluster-community-minimal-release-el7.rpm
rpm -Uvh http://repo.mysql.com/mysql-cluster-community-minimal-release-el7-1.noarch.rpm

MySQL :: Download MySQL Yum Repositoryhttps://dev.mysql.com/downloads/repo/yum/MySQL :: MySQL Community Downloadshttps://dev.mysql.com/downloads/

2.6、Google-Chrome

Google Chrome是一款由Google公司开发的网页浏览器,基于其他开源软件撰写,包括WebKit,目标是提升稳定性、速度和安全性,并创造出简单且有效率的使用者界面。软件的名称来自称作Chrome的网络浏览器GUI(图形用户界面)。

# 导入仓库指纹文件
rpm --import http://dl.google.com/linux/linux_signing_key.pub

# 创建google-chrome YUM仓库
vi /etc/yum.repos.d/google-chrome.repo


[google-chromel]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enable=1
gpgcheck=1
gpgkey=http://dl.google.com/linux/linux_signing_key.pub

注意:部分运营商网络下,连接http://dl.google.com/可能失败,是被墙的原因。

Google Chrome 网络浏览器得益于 Google 智能工具,Chrome 现在更易用、更安全、更快速。https://www.google.cn/chrome/thank-you.html

2.7、Oracle-VirtualBox

Oracle VM VirtualBox、虚拟机扩展包和软件开发工具包 (SDK)。

# 导入仓库指纹文件
rpm --import https://www.virtualbox.org/download/oracle_vbox.asc

# 下载Oracle VirtualBox仓库
wget -O /etc/yum.repos.d/virtualbox.repo  https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo

Oracle VM VirtualBox https://www.virtualbox.org/

2.8、Zabbix

Zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案,能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

Zabbix官方仓库提供Red Hat Enterprise Linux、CentOS、Oracle Linux、Ubuntu、Debian、SUSE Linux Enterprise Server 甚至 Raspbian 的安装包。

# 安装 Zabbix YUM仓库
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-2.el7.noarch.rpm

zabbix开源地址icon-default.png?t=M666https://github.com/zabbix/zabbix

Zabbix :: The Enterprise-Class Open Source Network Monitoring SolutionZabbix is a mature and effortless enterprise-class open source monitoring solution for network monitoring and application monitoring of millions of metrics.https://www.zabbix.com/

2.9、Grafana

Grafana 能够查询、可视化、警告和探索存储在任何位置的指标、日志和跟踪,并提供了将时间序列数据库 (TSDB) 数据转换为富有洞察力的图表和可视化的工具。

grafana开源地址icon-default.png?t=M666https://github.com/grafana/grafana

Grafana: The open observability platform | Grafana LabsGrafana is the open source analytics & monitoring solution for every database.https://grafana.com/

# 官方安装参考 https://grafana.com/docs/grafana/next/setup-grafana/installation/rpm/#install-from-yum-repository
# 新建Grafana YUM仓库文件
# 以下两项配置实际需要配置任一即可
vi /etc/yum.repos.d/grafana.repo

# #################### OSS版本 ####################
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

# #################### 企业版 ####################
[grafana]
name=grafana
baseurl=https://packages.grafana.com/enterprise/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

以上是自己常用的YUM仓库源,欢迎留言补充……

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狂龙骄子

独码乐,不如众码乐,乐享其中

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值