搭建本地YUM源
从外网yum安装,很费时间,也占用流量。在局域网搭建YUM 服务器即可解决此问题。步骤如下:
服务器端安装配置如下:
1、挂载镜像和创建包目录,拷贝rpm包到创建的目录下
[root@data-1-1 ~]# mount /dev/sr0 /mnt mount: block device /dev/sr0 is write-protected, mounting read-only [root@data-1-1 ~]# mkdir /home/data/Centos -p [root@data-1-1 ~]# cp -a /mnt/Packages/ /home/data/Centos/
2、安装creatrepo,并生成repodata目录
[root@data-1-1 ~]# yum install createrepo -y Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.7 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package createrepo.noarch 0:0.9.9-24.el6 will be installed Installing : deltarpm-3.5-0.5.20090913git.el6.x86_64 1/3 Installing : python-deltarpm-3.5-0.5.20090913git.el6.x86_64 2/3 Installing : createrepo-0.9.9-24.el6.noarch 3/3 Verifying : python-deltarpm-3.5-0.5.20090913git.el6.x86_64 1/3 Verifying : deltarpm-3.5-0.5.20090913git.el6.x86_64 2/3 Verifying : createrepo-0.9.9-24.el6.noarch 3/3 Installed: createrepo.noarch 0:0.9.9-24.el6 Dependency Installed: deltarpm.x86_64 0:3.5-0.5.20090913git.el6 python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6 Complete! [root@data-1-1 ~]# cd /home/data/ [root@data-1-1 data]# ls Centos [root@data-1-1 data]# createrepo Centos/ Spawning worker 0 with 4184 pkgs Workers Finished Gathering worker results Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@data-1-1 data]# ll total 4 drwxr-xr-x 4 root root 4096 Jan 25 00:32 Centos [root@data-1-1 data]# cd Centos/ [root@data-1-1 Centos]# ll total 268 dr-xr-xr-x 2 root root 270336 Oct 24 2014 Packages drwxr-xr-x 2 root root 4096 Jan 25 00:32 repodata
3、安装和配置httpd
[root@data-1-1 Centos]# yum install httpd -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Updated:
  httpd.x86_64 0:2.2.15-56.el6.centos.3                                                                 
Dependency Updated:
  httpd-tools.x86_64 0:2.2.15-56.el6.centos.3                                                           
Complete!
[root@data-1-1 Centos]# vim +292 /etc/httpd/conf/httpd.conf 
[root@data-1-1 Centos]# /etc/init.d/httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for data-1-1
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]
[root@data-1-1 Centos]# 
修改292行为如下结果
[root@data-1-1 Centos]# sed -n '292p' /etc/httpd/conf/httpd.conf DocumentRoot "/home/data" [root@data-1-1 Centos]#
 
4、服务端配置防火墙、关闭selinux
客户端修改配置如下:ip换为sever ip
cat >>/etc/yum.repos.d/CentOS-Base.repo<<EOF [base] name=myiso repo baseurl=http://10.0.1.81/Centos gpgcheck=0 enabled=1 [updates] name=myiso update baseurl=http://10.0.1.81/Centos gpgcheck=0 enabled=1 EOF yum clean all yum makecache
执行如下
[root@data-1-2 ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.ori [root@data-1-2 ~]# cat >>/etc/yum.repos.d/CentOS-Base.repo<<EOF > [base] > name=myiso repo > baseurl=http://10.0.1.81/Centos > gpgcheck=0 > enabled=1 > [updates] > name=myiso update > baseurl=http://10.0.1.81/Centos > gpgcheck=0 > enabled=1 > EOF [root@data-1-2 ~]# yum clean all Loaded plugins: fastestmirror, refresh-packagekit, security Cleaning repos: base extras updates Cleaning up Everything Cleaning up list of fastest mirrors [root@data-1-2 ~]# yum makecache Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors * base: 10.0.1.81 * extras: mirrors.aliyun.com * updates: 10.0.1.81 base | 2.9 kB 00:00 base/filelists_db | 4.4 MB 00:00 base/primary_db | 3.4 MB 00:00 base/other_db | 1.9 MB 00:00 extras | 3.4 kB 00:00 extras/filelists_db | 38 kB 00:00 extras/prestodelta | 1.3 kB 00:00 extras/primary_db | 37 kB 00:00 extras/other_db | 51 kB 00:00 updates | 2.9 kB 00:00 updates/filelists_db | 4.4 MB 00:00 updates/primary_db | 3.4 MB 00:00 updates/other_db | 1.9 MB 00:00 Metadata Cache Created [root@data-1-2 ~]# > /etc/yum.repos.d/CentOS-Base.repo [root@data-1-2 ~]# cat >>/etc/yum.repos.d/CentOS-Base.repo<<EOF [base] name=myiso repo baseurl=http://10.0.1.81/Centos gpgcheck=0 enabled=1 [updates] name=myiso update baseurl=http://10.0.1.81/Centos gpgcheck=0 enabled=1 EOF [root@data-1-2 ~]# yum clean all Loaded plugins: fastestmirror, refresh-packagekit, security Cleaning repos: base updates Cleaning up Everything Cleaning up list of fastest mirrors [root@data-1-2 ~]# yum makecache Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors base | 2.9 kB 00:00 base/filelists_db | 4.4 MB 00:00 base/primary_db | 3.4 MB 00:00 base/other_db | 1.9 MB 00:00 updates | 2.9 kB 00:00 updates/filelists_db | 4.4 MB 00:00 updates/primary_db | 3.4 MB 00:00 updates/other_db | 1.9 MB 00:00 Metadata Cache Created [root@data-1-2 ~]# cd /etc/yum.repos.d/ [root@data-1-2 yum.repos.d]# ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Base.repo.ori CentOS-fasttrack.repo CentOS-Vault.repo [root@data-1-2 yum.repos.d]# yum install httpd Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Package httpd-2.2.15-39.el6.centos.x86_64 already installed and latest version Nothing to do [root@data-1-2 yum.repos.d]# rpm -qa | grep nmap nmap-5.51-4.el6.x86_64 [root@data-1-2 yum.repos.d]# rpm -e nmap-5.51-4.el6.x86_64 --nodeps [root@data-1-2 yum.repos.d]# rpm -qa | grep nmap [root@data-1-2 yum.repos.d]# yum install nmap -y Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package nmap.x86_64 2:5.51-4.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================== Package Arch Version Repository Size ======================================================================================================== Installing: nmap x86_64 2:5.51-4.el6 base 2.8 M Transaction Summary ======================================================================================================== Install 1 Package(s) Total download size: 2.8 M Installed size: 9.7 M Downloading Packages: nmap-5.51-4.el6.x86_64.rpm | 2.8 MB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : 2:nmap-5.51-4.el6.x86_64 1/1 Verifying : 2:nmap-5.51-4.el6.x86_64 1/1 Installed: nmap.x86_64 2:5.51-4.el6 Complete!
5、测试下,把10.0.1.81这个机器,也就是data-1-1机器的httpd服务停止,然后重新安装nmap
[root@data-1-1 Centos]# /etc/init.d/httpd stop Stopping httpd: [ OK ] [root@data-1-1 Centos]#
data-1-2机器重新安装nmap,报错,说明我们配置的yum源是生效的,没问题
[root@data-1-2 yum.repos.d]# rpm -e nmap-5.51-4.el6.x86_64 --nodeps [root@data-1-2 yum.repos.d]# yum install nmap -y Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package nmap.x86_64 2:5.51-4.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================== Package Arch Version Repository Size ======================================================================================================== Installing: nmap x86_64 2:5.51-4.el6 base 2.8 M Transaction Summary ======================================================================================================== Install 1 Package(s) Total download size: 2.8 M Installed size: 9.7 M Downloading Packages: http://10.0.1.81/Centos/Packages/nmap-5.51-4.el6.x86_64.rpm: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host" Trying other mirror. Error Downloading Packages: 2:nmap-5.51-4.el6.x86_64: failure: Packages/nmap-5.51-4.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try. [root@data-1-2 yum.repos.d]#
                    
                
                
            
        
浙公网安备 33010602011771号