Linux(Redhat )的源配置

Redhat 6或者麒麟,

配置163源,在线安装程序,也可以配置其他源

/etc/yum.repos.d目录下新建文件CentOS7-Base-163.repo,文件拓展名必须是.repo,文件中内容包含如下

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-6 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

一般在公司没有网络的话,还可以用前辈的网络配置代理,

在/etc/yum.conf添加代理

在末尾添加:proxy=http://IP:port

本地源配置:

扫描二维码关注公众号,回复: 13543825 查看本文章

/etc/yum.repos.d目录下新建拓展名为.repo的文件,文件包含以下内容

[local] rhel(仓库)的名字,可自定义,但不可重名

name=local 对于上面[local]的具体描述,可自己进行根据实际情况描述

baseurl=url 这个是非常重要的一环,表明了你未来从repositry仓库中获取东西的地址,支持ftp协议,http协议和file协议(这里更详细的写法下其讨论)

gpgcheck=0/1 有1和0两个选择,分别代表是否是否进行gpg校验,检查与否自行决定

enabled=0/1 这里就是本期问题的罪魁祸首,一定要写成1,如果是0,就证明你的仓库都不开启的,执行yum repolist为0就很正常了

gpgkey=url 后面接的是gpgkey的地址,如果前面定义gpgcheck=1的话。

永久挂载,在/etc/fstab文件末尾添加,挂载之后记得重启系统

/dev/sr0               /work/DVD_soure          ext4    defaults        0 0
DVD镜像             目标路径

临时挂载

mount -f dev/sr0 /work/DVD_soure

yum clean all #清理yum缓存,使设置生效

yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度

执行之后可以看到DVD-soure,就说明本地源配置成功了

yum search ftp #查看可安装的包

yum install #安装

yum indo #查看程序信息

猜你喜欢

转载自blog.csdn.net/qq_40788199/article/details/103149200