首页 > 代码库 > 搭建本地yum服务器
搭建本地yum服务器
在内网环境下,服务器通常不联网,这时候如果要下载什么软件,搭建本地yum服务器的话就很方便了。
创建挂载目录:
[root@Herry ~]# mkdir -p /local/yum
2.挂载你的光盘或者U盘到指定目录下,这里的/dev/cdrom可以是你的U盘,具体看你用什么了[root@Herry ~]# mount /dev/cdrom /local/yum
3.copy源yum的目录文件,我做实验需要还原的,这个不是必须
[root@Herry ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.aak
4.删除源Yum目录下的所有文件,这个不是必须
[root@Herry ~]# rm -f /etc/yum.repos.d/*
5.修改配置文件,你也可以直接在/etc/yum.repos.d/CentOS-Base.repo下增加以下配置,不过在使用yum的时候,它会从上往下匹配,比较耗时,所以这里我就直接删除源yum文件了,新增了以下local_yum.repo:
[root@Herry ~]# vim /etc/yum.repos.d/local_yum.repo
[local_yum]
name=this is local yum
baseurl=file:///local/yum
enabled=1 (是否启用该yum源,0为禁用)
gpgcheck=0 (是否检查gpgkey,0为不检查)
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6(gpgcheck=0时无需配置)
6.测试:卸载vim
[root@Herry ~]# yum remove -y vim
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
The program yum-complete-transaction is found in the yum-utils package.
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.2.411-1.8.el6 will be erased
--> Finished Dependency Resolution
local_yum | 4.0 kB 00:00 ...
local_yum/primary_db | 4.4 MB 00:00 ...
Dependencies Resolved
==========================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================
Removing:
vim-enhanced x86_64 2:7.2.411-1.8.el6 @anaconda-CentOS-201311272149.x86_64/6.5 1.8 M
Transaction Summary
==========================================================================================================================
Remove 1 Package(s)
Installed size: 1.8 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : 2:vim-enhanced-7.2.411-1.8.el6.x86_64 1/1
Verifying : 2:vim-enhanced-7.2.411-1.8.el6.x86_64 1/1
Removed:
vim-enhanced.x86_64 2:7.2.411-1.8.el6
7.命令vim无法使用了:
[root@Herry ~]# !v
vim /etc/yum.repos.d/local_yum.repo
-bash: /usr/bin/vim: 没有那个文件或目录
8.安装回来vim:
[root@Herry ~]# yum install -y vim
Loaded plugins: fastestmirror
Determining fastest mirrors
Setting up Install Process
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
The program yum-complete-transaction is found in the yum-utils package.
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.2.411-1.8.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================
Installing:
vim-enhanced x86_64 2:7.2.411-1.8.el6 local_yum 892 k
Transaction Summary
==========================================================================================================================
Install 1 Package(s)
Total download size: 892 k
Installed size: 1.8 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:vim-enhanced-7.2.411-1.8.el6.x86_64 1/1
Verifying : 2:vim-enhanced-7.2.411-1.8.el6.x86_64 1/1
Installed:
vim-enhanced.x86_64 2:7.2.411-1.8.el6
9.可以使用vim了 :
[root@Herry ~]# !v
vim /etc/yum.repos.d/local_yum.repo
[local_yum]
name=this is local yum
baseurl=file:///local/yum
enabled=1
gpgcheck=0
至此本地yum搭建完成。
本文出自 “飞奔的小GUI” 博客,请务必保留此出处http://9237101.blog.51cto.com/9227101/1913071
搭建本地yum服务器