linux中配置yum源

1、配置163或者阿里云yum源:



阿里云yum源地址:https://mirrors.aliyun.com/centos/6.9/os/x86_64/Packages/

阿里云给出的解决办法:https://mirrors.aliyun.com/centos 点击centos后面的帮助即可看到:

1、备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo   可以直接通过访问url下载到本地后上传到linux目录中,如果linux中不支持wget时,可以使用这种方法。
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之后运行yum makecache生成缓存

具体操作:

[[email protected] zyj]# cd /etc/yum.repos.d/  //yum源的配置文件,查看默认yum源,一般默认为centos官网下的yum源。
[[email protected] yum.repos.d]# ll
total 24
-rw-r--r--. 1 root root 1991 Mar 28 2017 CentOS-Base.repo
-rw-r--r--. 1 root root 647 Mar 28 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 Mar 28 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 7989 Mar 28 2017 CentOS-Vault.repo
-rw-r--r--. 1 root root 289 Mar 28 2017 CentOS-fasttrack.repo
[[email protected] yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.backup  //备份
[[email protected] yum.repos.d]# ll
total 24
-rw-r--r--. 1 root root 1991 Mar 28  2017 CentOS-Base.repo.backup
-rw-r--r--. 1 root root  647 Mar 28  2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  630 Mar 28  2017 CentOS-Media.repo
-rw-r--r--. 1 root root 7989 Mar 28  2017 CentOS-Vault.repo
-rw-r--r--. 1 root root  289 Mar 28  2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root    0 Apr 29 11:58 my.repos
[[email protected] yum.repos.d]#
[[email protected] yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo  //下载新的yum源到本地
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
102  2572  102  2572    0     0   7505      0 --:--:-- --:--:-- --:--:-- 11482
[[email protected] yum.repos.d]# ll
total 28
-rw-r--r--. 1 root root 2572 Apr 30 03:07 CentOS-Base.repo
[[email protected] yum.repos.d]# yum clean all //清除之前的缓存
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors

[[email protected] yum.repos.d]# yum makecache  //生成缓存
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.7 kB 00:00
base/group_gz | 226 kB 00:00
base/filelists_db | 6.4 MB 00:05
base/primary_db | 4.7 MB 00:06
base/other_db | 2.8 MB 00:03
extras | 3.4 kB 00:00
extras/filelists_db | 26 kB 00:00
extras/prestodelta | 1.7 kB 00:00
extras/primary_db | 30 kB 00:00
extras/other_db | 32 kB 00:00
updates | 3.4 kB 00:00
updates/filelists_db | 4.3 MB 00:05
updates/prestodelta | 245 kB 00:00
updates/primary_db | 7.0 MB 00:05
updates/other_db | 100 MB 01:27

 2、构建本地设置yum源:通过光盘方式。



1、插入完整版的IOS文件到光驱;将虚拟中mini版的linux虚拟机通过设置中的CD选择为完整版的镜像;

2、挂载光盘;mount /dev/cdrom /mnt

[[email protected] ~]# cd /mnt/  //查看挂载点目录
[[email protected] mnt]# ls
[[email protected] mnt]# mount /dev/cdrom /mnt //挂载光盘
mount: block device /dev/sr0 is write-protected, mounting read-only
[[email protected] mnt]# cd /dev
[[email protected] dev]# ls -l cdrom
lrwxrwxrwx. 1 root root 3 4月  30 18:52 cdrom -> sr0
[[email protected] dev]#
[[email protected] dev]# cd /mnt/ //查看挂载文件
[[email protected] mnt]# ls
CentOS_BuildTag  GPL       Packages                  RPM-GPG-KEY-CentOS-6           RPM-GPG-KEY-CentOS-Testing-6
EFI              images    RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Debug-6     TRANS.TBL
EULA             isolinux  repodata                  RPM-GPG-KEY-CentOS-Security-6
[[email protected] mnt]# cd Packages/   //查看挂载后的rpm文件
[[email protected] Packages]# ls
389-ds-base-1.2.11.15-89.el6.x86_64.rpm                             libreoffice-math-4.3.7.2-2.el6.x86_64.rpm
389-ds-base-libs-1.2.11.15-89.el6.x86_64.rpm                        libreoffice-ogltrans-4.3.7.2-2.el6.x86_64.rpm
abrt-2.0.8-43.el6.centos.x86_64.rpm                                 libreoffice-opensymbol-fonts-4.3.7.2-2.el6.noarch.rpm
abrt-addon-ccpp-2.0.8-43.el6.centos.x86_64.rpm                      libreoffice-pdfimport-4.3.7.2-2.el6.x86_64.rpm
abrt-addon-kerneloops-2.0.8-43.el6.centos.x86_64.rpm                libreoffice-pyuno-4.3.7.2-2.el6.x86_64.rpm
abrt-addon-python-2.0.8-43.el6.centos.x86_64.rpm                    libreoffice-ure-4.3.7.2-2.el6.x86_64.rpm
abrt-cli-2.0.8-43.el6.centos.x86_64.rpm                             libreoffice-wiki-publisher-4.3.7.2-2.el6.x86_64.rpm
abrt-desktop-2.0.8-43.el6.centos.x86_64.rpm                         libreoffice-writer-4.3.7.2-2.el6.x86_64.rpm
abrt-gui-2.0.8-43.el6.centos.x86_64.rpm                             libreoffice-xsltfilter-4.3.7.2-2.el6.x86_64.rpm
abrt-libs-2.0.8-43.el6.centos.x86_64.rpm                            libreport-2.0.9-33.el6.centos.x86_64.rpm
abrt-python-2.0.8-43.el6.centos.x86_64.rpm                          libreport-cli-2.0.9-33.el6.centos.x86_64.rpm
abrt-tui-2.0.8-43.el6.centos.x86_64.rpm                             libreport-compat-2.0.9-33.el6.centos.x86_64.rpm
abyssinica-fonts-1.0-5.1.el6.noarch.rpm                             libreport-filesystem-2.0.9-33.el6.centos.x86_64.rpm
acl-2.2.49-7.el6.x86_64.rpm                                         libreport-gtk-2.0.9-33.el6.centos.x86_64.rpm
acpid-1.0.10-3.el6.x86_64.rpm                                       libreport-newt-2.0.9-33.el6.centos.x86_64.rpm
adcli-0.8.1-1.el6.x86_64.rpm                                        libreport-plugin-kerneloops-2.0.9-33.el6.centos.x86_64.rpm
aic94xx-firmware-30-2.el6.noarch.rpm                                libreport-plugin-logger-2.0.9-33.el6.centos.x86_64.rpm
aide-0.14-11.el6.x86_64.rpm                                         libreport-plugin-mailx-2.0.9-33.el6.centos.x86_64.rpm
akonadi-1.2.1-3.el6.x86_64.rpm                                      libreport-plugin-reportuploader-2.0.9-33.el6.centos.x86_64.rpm
alacarte-0.12.4-1.el6.noarch.rpm                                    libreport-plugin-rhtsupport-2.0.9-33.el6.centos.x86_64.rpm
alsa-lib-1.1.0-4.el6.x86_64.rpm                                     libreport-plugin-ureport-2.0.9-33.el6.centos.x86_64.rpm
alsa-lib-devel-1.1.0-4.el6.x86_64.rpm                               libreport-python-2.0.9-33.el6.centos.x86_64.rpm
alsa-plugins-pulseaudio-1.1.0-1.el6.x86_64.rpm                      librepository-1.0.0-2.OOo31.1.el6.x86_64.rpm
alsa-utils-1.1.0-10.el6.x86_64.rpm                                  libreswan-3.15-7.3.el6.x86_64.rpm

3、修改/etc/yum.repos.d/CentOS-Base.repo;

4、该目录下的其他配置文件删除,清除缓存文件并生成缓存;

5、yum源配置完成后,可使用yum install 安装应用程序。

[[email protected] yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.backup  //备份原有配置文件
[[email protected] yum.repos.d]# ll
总用量 28
-rw-r--r--. 1 root root 1991 3月  28 2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1991 4月  30 19:03 CentOS-Base.repo.backup
-rw-r--r--. 1 root root  647 3月  28 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  289 3月  28 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 3月  28 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 7989 3月  28 2017 CentOS-Vault.repo
[[email protected] yum.repos.d]#
[[email protected] yum.repos.d]#
[[email protected] yum.repos.d]# vi CentOS-Base.repo //修改配置文件
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?  release=$releasever&arch=$basearch&repo=os&infra=$infra  //将原有的注释,并复制一行进行修改
baseurl=file:///mnt/           //file://表示本地获取
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1  //启用检测gpg签名,验证rpm文件的安全性。
gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-6  //gpg签名文件路径

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0    //不启用的意思。
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
:wq //保存后退出

[[email protected] yum.repos.d]# yum clean all
已加载插件:fastestmirror
Cleaning repos: base extras updates
清理一切
Cleaning up list of fastest mirrors

[[email protected] yum.repos.d]# yum makecache //生成缓存
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* extras: mirrors.sohu.com
* updates: mirrors.aliyun.com
base | 4.0 kB 00:00 ...
base/group_gz | 226 kB 00:00 ...
base/filelists_db | 6.3 MB 00:01 ...
base/primary_db | 4.7 MB 00:00 ...
base/other_db | 2.7 MB 00:00 ..

注意:使用挂载光盘中的rpm文件作为yum源,由于光盘不能写以及重启后可能需要重新挂载,这时候可以通过将网络上的所有rpm文件下载到本地目录中,如/opt文件中即可。

[[email protected] ~]# cp /mnt/ /opt/
cp: 略过目录"/mnt/"

3、构建本地设置yum源:通过下载rpm文件到本地目录的方式。



1、下载网络上yum源中的rpm文件到本地目录中;下载完成后通过crt自带的文件传输功能上传到linux对应的目录中;具体不在这里示范;

[[email protected] ~]# mkdir mirrors
[[email protected] ~]# cd mirrors/
[[email protected] mirrors]# mkdir base
[[email protected] mirrors]# ls
base

安装yum-utils工具后,可以提供reposync命令。

[[email protected] ~]# yum search yum-util //忘记名字时,可以通过search查寻下;
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * extras: mirrors.aliyun.com
 * updates: mirrors.sohu.com
====================================================== N/S Matched: yum-util ======================================================
yum-utils.noarch : Utilities based around the yum package manager

  Name and summary matches only, use "search all" for everything.
[[email protected] ~]# yum install yum-utils -y  //安装时不用手动确认yes
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
 * extras: mirrors.aliyun.com
 * updates: mirrors.sohu.com
解决依赖关系
--> 执行事务检查
---> Package yum-utils.noarch 0:1.1.30-40.el6 will be 安装
--> 处理依赖关系 libxml2-python,它被软件包 yum-utils-1.1.30-40.el6.noarch 需要
--> 执行事务检查
---> Package libxml2-python.x86_64 0:2.7.6-21.el6_8.1 will be 安装
--> 完成依赖关系计算

依赖关系解决

===================================================================================================================================
 软件包                             架构                       版本                                 仓库                      大小
===================================================================================================================================
正在安装:
 yum-utils                          noarch                     1.1.30-40.el6                        base                     113 k
为依赖而安装:
 libxml2-python                     x86_64                     2.7.6-21.el6_8.1                     base                     325 k

事务概要
===================================================================================================================================
Install       2 Package(s)

总下载量:437 k
Installed size: 2.2 M
下载软件包:
-----------------------------------------------------------------------------------------------------------------------------------
总计                                                                                               1.3 MB/s | 437 kB     00:00
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
  正在安装   : libxml2-python-2.7.6-21.el6_8.1.x86_64                                                                          1/2
  正在安装   : yum-utils-1.1.30-40.el6.noarch                                                                                  2/2
  Verifying  : yum-utils-1.1.30-40.el6.noarch                                                                                  1/2
  Verifying  : libxml2-python-2.7.6-21.el6_8.1.x86_64                                                                          2/2 

已安装:
  yum-utils.noarch 0:1.1.30-40.el6                                                                                                 

作为依赖被安装:
  libxml2-python.x86_64 0:2.7.6-21.el6_8.1                                                                                         

完毕!

2、修改/etc/yum.repos.d/CentOS-Base.repo;

3、该目录下的其他配置文件删除,清除缓存文件并生成缓存;

4、yum源配置完成后,可使用yum install 安装应用程序。

Linux下设置目录网络共享

服务器端配置:

1、安装nfs-utils和rpcbind

yum install -y nfs-utils rpcbind

2、设置开机启动服务

Chkconfig nfs on

Chkconfig rpcbind on

3、启动相关服务

Service rpcbind start

Service nfs start

4、创建共享目录

Mkdir /share

5、编辑/etc/exports文件添加如下内容:

Vim /etc/exports

/share client_ip(rv,no_root_squash,no_subtree_check)

客户端的指定方式:

指定ip地址的主机:192.168.0.100

指定子网中的所有主机:192.168.0.0/24或192.168.0.0/255.255.255.0

指定域名的主机:nfs.test.com

指定域中的所有主机:*.test.com

所有主机:*

原文地址:https://www.cnblogs.com/zhaoyujiao/p/8973803.html

时间: 2024-08-27 12:57:45

linux中配置yum源的相关文章

在RHEL6中配置YUM源

1 创建rhel-debuginfo.repo,如果有则先备份再删除 cd /etc/yum.repos.d rm rhel-debuginfo.repo vi rhel-debuginfo.repo 插入以下内容: [Server] name=Red Hat Enterprise Linux Server baseurl=file:///home/redhat-iso #本地iso的挂载路径 enabled=1 #可以使用yum gpgcheck=0 #设置不检查gpgkey gpgkey=f

LINUX安装32位运行库【LINUX配置YUM源的几种办法】

前言:本帖仅适用于RedHat.CentOS的64位系统 很多时候我们需要用linux运行或测试程序,然而我们发现64位linux系统在检测32位程序的动态链接库文件时(也就是ldd一个so文件)会报错: 不是动态可执行文件[或英文提示:not a dynamic executable file] 这是因为系统没有安装32位兼容库的缘故,我们分两大方法解决这个问题→有网络/无网络 一.当前使用linux系统已连接网络情况下,可进行在线安装 yum在线安装:sudo yum install xul

Linux 配置yum源(互联网)

Linux 配置yum源(互联网) 环境:操作系统Redhat 7.5 1.卸载现有的yum源 rpm -qa|grep yum|xargs rpm -e --nodeps     #移除与原yum有关的东西 2.  下载新的yum源包. 我是从网易上下载的,镜像网址:http://mirrors.163.com ,下载以下软件包(我的系统是Redhat7.5 64位,下载的也是相应的软件,其它系统,我不确定是否 可用) wget http://mirrors.163.com/centos/7/

RHEL 7.0 本地配置yum源

RHEL 7.0 本地配置yum源  yum简介  yum = Yellow dog Updater, Modified 主要功能是更方便的添加/删除/更新RPM包. 它能自动解决包的倚赖性问题. 它能便于管理大量系统的更新问题 当前linux版本 rhel7.0 前提mount DVD光盘到/mnt   因为配置时候路径名里面不能有空格,否则不能识别 首先设置IP地址.网关DNS 说明:RHEL 7.0默认安装好之后是没有自动开启网络连接的! cd  /etc/sysconfig/networ

配置yum源、epel源及其查看系统性能的命令

第1章 配置yum源.epel源1.1 配置linux yum源软件仓库百度应用商城yum源?google应用商城应用宝1.2 查看系统当前的yum源yum repolistLoaded plugins: fastestmirror, securityDetermining fastest mirrors base: mirrors.huaweicloud.com extras: mirrors.huaweicloud.com updates: mirrors.shu.edu.cn (系统默认的

RHEL / CentOS 配置YUM源 及YUM介绍

RHEL / CentOS 配置YUM源 及 YUM介绍 Table of Contents 1. 前言 2. 关于yum 2.1. YUM是什么 2.2. YUM特点 2.3. 安装yum 2.4. YUM配置 2.5. 软件源 2.6. YUM使用 2.7. YUM常用问题解决 2.7.1. 超时退出 2.7.2. YUM Existing lock 3. 重新安装yum 3.1. 卸载yum 3.2. 确定下载文件 3.3. 安装 4. 配置网络YUM源 4.1. 配置阿里云源 4.2.

Linux创建私有yum源仓库

创建yum私有库 简述 ? 在Linux系统中安装软件的方法有三种,分别是rpm软件包安装.yum源安装与源代码编译安装,在用rpm软件包安装软件时会经常出现依赖性问题,导致安装繁琐,用源代码编译安装就更不用说了,相信很多小伙伴也都感受过源代码编译安装的各种花样报错,导致精神崩溃,因此我们在Linux操作系统中安装软件的首先方法就是利用yum源安装软件. ? yum是一个基于rpm的软件包管理器,它包含一些命令:查找.安装.删除----软件包.使用yum安装软件包它可以自动查找软件包,包括软件安

shell脚本快速配置yum源

我们在使用Red Hat系列与CentOS系列的Linux系统时经常要配置yum源,本文档提出一个快速配置yum源的方法,就是用shell脚本来实现. 首先确保系统已挂载好镜像文件,然后执行vim rhel7.repo.sh命令,这个命令是创建一个脚本. 在打开的文件中添加以下内 [[email protected] ~]# vim rhel7.repo.sh  1 #!/bin/bash 2 3 cd /etc/yum.repos.d 4 5 cat >>rhel7.repo<<

配置yum源

配置yum源 yum源正常请忽略这一步 01. 在安装完RedHat Enterprise Linux系统后, 由于 redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,请配置其他YUM源,以下为详细过程.(此过程不需卸载RedHat Enterprise Linux (RHEL) 自己的YUM程序) 02. 安装的RedHat Enterprise Lunux系统版本 # lsb_release -a (适用于所有的linux,包括Redhat.SuSE.Debian等