码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS7本地yum源搭建

时间:2015-08-11 23:39:16      阅读:343      评论:0      收藏:0      [点我收藏+]

标签:centos 7基于http的本地yum源

CentOS 7基于HTTP的本地yum源

[root@localhost ~]# yum install  httpd

[root@localhost ~]# systemctl  status httpd
[root@localhost ~]# yum update && yum install createrepo 

[root@localhost ~]# mkdir -p /var/www/html/repos/centos/7/0   --------创建本地yum源目录

[root@localhost ~]# createrepo /var/www/html/repos/centos/7/0 --------创建本地yum源
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

[root@localhost ~]# mount -o loop /os/CentOS-7-x86_64-Everything-1503-01.iso  /mnt 

[root@localhost ~]# cp  -r /mnt/* /var/www/html/repos/centos/7/0  -------- 将挂在后镜像文件全部拷贝到本地yum源目录

[root@localhost ~]# du -sch /var/www/html/repos/centos/7/0/*
4.0K     /var/www/html/repos/centos/7/0/CentOS_BuildTag
6.1M     /var/www/html/repos/centos/7/0/EFI
4.0K     /var/www/html/repos/centos/7/0/EULA
20K     /var/www/html/repos/centos/7/0/GPL
438M     /var/www/html/repos/centos/7/0/images
72M     /var/www/html/repos/centos/7/0/isolinux
275M     /var/www/html/repos/centos/7/0/LiveOS
6.3G     /var/www/html/repos/centos/7/0/Packages
24M     /var/www/html/repos/centos/7/0/repodata
4.0K     /var/www/html/repos/centos/7/0/RPM-GPG-KEY-CentOS-7
4.0K     /var/www/html/repos/centos/7/0/RPM-GPG-KEY-CentOS-Testing-7
4.0K     /var/www/html/repos/centos/7/0/TRANS.TBL
7.1G     total

[root@localhost ~]# createrepo --update /var/www/html/repos/centos/7/0/   -------- 更新本地yum源
Spawning worker 0 with 361 pkgs
Spawning worker 1 with 361 pkgs
Spawning worker 2 with 361 pkgs
Spawning worker 3 with 361 pkgs
Spawning worker 4 with 361 pkgs
Spawning worker 5 with 361 pkgs
Spawning worker 6 with 361 pkgs
Spawning worker 7 with 361 pkgs
Spawning worker 8 with 361 pkgs
Spawning worker 9 with 361 pkgs
Spawning worker 10 with 361 pkgs
Spawning worker 11 with 361 pkgs
Spawning worker 12 with 360 pkgs
Spawning worker 13 with 360 pkgs
Spawning worker 14 with 360 pkgs
Spawning worker 15 with 360 pkgs
Spawning worker 16 with 360 pkgs
Spawning worker 17 with 360 pkgs
Spawning worker 18 with 360 pkgs
Spawning worker 19 with 360 pkgs
Spawning worker 20 with 360 pkgs
Spawning worker 21 with 360 pkgs
Spawning worker 22 with 360 pkgs
Spawning worker 23 with 360 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

[root@localhost ~]#
如果不用iptable可以直接禁用
[root@localhost ~]# yum install iptable*
Loaded plugins: fastestmirror, langpacks, priorities
Loading mirror speeds from cached hostfile
Package iptables-1.4.21-13.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package iptables-devel.x86_64 0:1.4.21-13.el7 will be installed
---> Package iptables-services.x86_64 0:1.4.21-13.el7 will be installed
---> Package iptables-utils.x86_64 0:1.4.21-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================
Package                                 Arch                         Version                                Repository                     Size
=================================================================================================================================================
Installing:
iptables-devel                          x86_64                       1.4.21-13.el7                          CentOS7                        53 k
iptables-services                       x86_64                       1.4.21-13.el7                          CentOS7                        49 k
iptables-utils                          x86_64                       1.4.21-13.el7                          CentOS7                        57 k

Transaction Summary
=================================================================================================================================================
Install  3 Packages

Total download size: 159 k
Installed size: 98 k
Is this ok [y/d/N]: y
Downloading packages:
-------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                            7.1 MB/s | 159 kB  00:00:00    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : iptables-devel-1.4.21-13.el7.x86_64                                                                                           1/3
  Installing : iptables-utils-1.4.21-13.el7.x86_64                                                                                           2/3
  Installing : iptables-services-1.4.21-13.el7.x86_64                                                                                        3/3
  Verifying  : iptables-services-1.4.21-13.el7.x86_64                                                                                        1/3
  Verifying  : iptables-utils-1.4.21-13.el7.x86_64                                                                                           2/3
  Verifying  : iptables-devel-1.4.21-13.el7.x86_64                                                                                           3/3

Installed:
  iptables-devel.x86_64 0:1.4.21-13.el7          iptables-services.x86_64 0:1.4.21-13.el7          iptables-utils.x86_64 0:1.4.21-13.el7        

Complete!
[root@localhost ~]# cd  /etc/sysconfig/
[root@localhost sysconfig]# ls -l ip
ip6tables         ip6tables-config  iptables          iptables-config  
[root@localhost sysconfig]# vi iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT   ---------开放HTTP端口(也可以直接禁用防火墙和iptable)

[root@localhost sysconfig]# systemctl restart iptables.service

[root@localhost sysconfig]# systemctl status iptables.service
iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled)
   Active: active (exited) since Wed 2015-08-05 23:48:46 EDT; 7s ago
  Process: 4138 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
Main PID: 4138 (code=exited, status=0/SUCCESS)

Aug 05 23:48:46 localhost.localdomain iptables.init[4138]: iptables: Applying firewall rules: [  OK  ]
Aug 05 23:48:46 localhost.localdomain systemd[1]: Started IPv4 firewall with iptables.
[root@localhost sysconfig]#

[root@localhost ~]# for i in `ls /etc/yum.repos.d/`;do mv /etc/yum.repos.d/$i /etc/yum.repos.d/$i.bak;done

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# vi CentOS7.repo
[Centos7]
name=Centos7
baseurl=http://172.16.1.131/repos/centos/7/0/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


OK!

CentOS7本地yum源搭建

标签:centos 7基于http的本地yum源

原文地址:http://xiaopingzi.blog.51cto.com/2797262/1683829

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!