1. 程式人生 > >配置本機的yum源

配置本機的yum源

pack arch The -c ica fall close nsa sys

配置本機的yum源

環境:操作系統CentOS6.5

1.掛在安裝光盤

[root@CentOS40 ~]# mkdir -p /mnt/cdrom
[root@CentOS40 ~]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@CentOS40 ~]#

2.修改yum配置文件

yum的配置文件在/etc/yum.repos.d/

[root@CentOS40 yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo

查看目錄有4個yum的配置文件。可以修改裏面的任何一個,這裏一修改CentOS-Base.repo為例,

修改之前可以先備份下該文件。

3.修改配置文件

[root@CentOS40 yum.repos.d]# vi CentOS-Base.repo
[root@CentOS40 yum.repos.d]#

會看到裏面有很多內容,因為我們配置的,本地yum源,可以只保留上面的部分

# 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-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

修改紅色標準的一行

baseurl=file:///mnt/cdrom

然後保存退出

4.查下yum源,如果可以看到,好多寶,就說明yum源,配置成功

[root@CentOS40 yum.repos.d]# yum list

5.測試安裝vim(如果看到下面內容,正常yum配置成功,可以正常使用。)

[root@CentOS40 yum.repos.d]# yum install vim
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=os error was
14: PYCURL ERROR 6 - "Couldn‘t resolve host ‘mirrorlist.centos.org‘"
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.i686 2:7.2.411-1.8.el6 will be installed

配置本機的yum源