ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux 配置本地yum

Linux 配置本地yum

原创 Linux操作系统 作者:Oc_Chxin 时间:2015-12-15 15:11:27 0 删除 编辑
RedHat5.5

[root@orcl11g Server]# mkdir -p /yum/Server
[root@orcl11g Server]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              21G  7.5G   12G  39% /
tmpfs                1006M     0 1006M   0% /dev/shm
/dev/hdb              3.5G  3.5G     0 100% /media/RHEL_5.5 x86_64 DVD
[root@orcl11g Server]# mount /dev/hdb /yum
mount: block device /dev/hdb is write-protected, mounting read-only
[root@orcl11g Server]# cd /etc/yum.repos.d/
[root@orcl11g yum.repos.d]# ls
rhel-debuginfo.repo

[root@orcl11g yum.repos.d]# cp rhel-debuginfo.repo rhel-debuginfo.repo.bak

[root@orcl11g yum.repos.d]# vi rhel-debuginfo.repo

[base]
name=local
baseurl=file:///yum/Server
gpgcheck=0
enabled=1



CentOS 7

[root@web-loadbalance soft]# mkdir /mnt/cdrom/
[root@web-loadbalance soft]# mount /dev/cdrom /mnt/cdrom/
[root@web-loadbalance soft]# cd /etc/yum.repos.d/
[root@web-loadbalance yum.repos.d]# ls
CentOS-Media.repo  DD  -->把多余的文件放入DD目录下
[root@web-loadbalance yum.repos.d]# vim CentOS-Media.repo 
[Media]
name=Centos-Media
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1

[root@web-loadbalance yum.repos.d]# yum -y install  vim   -->测试

[root@DB01 ~]# mount -t iso9660 -o loop CentOS-7-x86_64-DVD-1503-01.iso /yum   #ISO文件挂载方法

配置本地yum源的方法

1.利用光驱挂载镜像配置

1.1首先把光盘放在光驱中,若此时光驱已经挂载请用umount命令先把光驱umount掉

1.2建立相关目录,创建local.repo 文件
[root@tip01 ~]# mkdir /yum/Server/
[root@tip01 ~]# mount  /dev/hdc  /yum/
[root@tip01 ~]# vi /etc/yum.repos.d/local.repo 

#添加以下内容

[base]
name=local
baseurl=file:///yum/Server
gpgcheck=0
enabled=1

1.3 查看配置的yum源
[root@tip01 ~]# yum  list
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
base                                                                       | 1.3 kB     00:00     
base/primary            ####################################                                             


这样 yum仓库就建好了



2.利用本地文件目录建立yum 仓库

2.1把光盘放入光驱
mount  /dev/hdc  /mnt
[root@tip01 ~]# mount /dev/hdc  /mnt/
mount: block device /dev/hdc is write-protected, mounting read-only

注意:存放YUM源的目录必须有可写权限,不然在createrepo时会报错。

2.2将光盘文件复制到YUM目录
[root@tip01 ~]# umount /dev/hdc
[root@tip01 ~]# mount /dev/hdc  /mnt/
mount: block device /dev/hdc is write-protected, mounting read-only
[root@tip01 ~]# mount
/dev/sda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda2 on /home type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt type iso9660 (ro)

[root@tip01 ~]# cd /mnt/
[root@tip01 mnt]# ls -ld Server/
dr-xr-xr-x 3 root root 217088 05-19 05:11 Server/

2.2 拷贝Server目录
[root@tip01 mnt]# cp -r Server/ /yum/

2.3安装createrepo
[root@tip01 ~]# cd /yum/Server/
[root@tip01 Server]# rpm  -ivh createrepo-0.4.11-3.el5.noarch.rpm 
warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
        package createrepo-0.4.11-3.el5.noarch is  installed

2.4创建本地源
# createrepo  -g  /yum/Server/repodata/comps-rhel5-server-core.xml  /yum/Server

[root@tip01 ~]# vi /etc/yum.repos.d/local.repo 

[base]
name=local
baseurl=file:///yum/Server
gpgcheck=0
enabled=1


[root@tip01 ~]# yum  list
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
base                                                                       | 1.3 kB     00:00     
base/primary            ####################################                       

以同样的方式建立VT,CLUSTER,CLUSTERSTORAGE的yum源
要注意baseurl后为file:/// “三个斜杠”

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30560130/viewspace-1872681/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-11-11

  • 博文量
    10
  • 访问量
    21676